OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/sync/glue/http_bridge.h" | 5 #include "chrome/browser/sync/glue/http_bridge.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 HttpBridge::RequestContextGetter::RequestContextGetter( | 28 HttpBridge::RequestContextGetter::RequestContextGetter( |
29 net::URLRequestContextGetter* baseline_context_getter) | 29 net::URLRequestContextGetter* baseline_context_getter) |
30 : baseline_context_getter_(baseline_context_getter) { | 30 : baseline_context_getter_(baseline_context_getter) { |
31 } | 31 } |
32 | 32 |
33 HttpBridge::RequestContextGetter::~RequestContextGetter() {} | 33 HttpBridge::RequestContextGetter::~RequestContextGetter() {} |
34 | 34 |
35 net::URLRequestContext* | 35 net::URLRequestContext* |
36 HttpBridge::RequestContextGetter::GetURLRequestContext() { | 36 HttpBridge::RequestContextGetter::GetURLRequestContext() { |
37 // Lazily create the context. | 37 // Lazily create the context. |
38 if (!context_) { | 38 if (!context_.get()) { |
39 net::URLRequestContext* baseline_context = | 39 net::URLRequestContext* baseline_context = |
40 baseline_context_getter_->GetURLRequestContext(); | 40 baseline_context_getter_->GetURLRequestContext(); |
41 context_ = new RequestContext(baseline_context); | 41 context_.reset(new RequestContext(baseline_context)); |
42 baseline_context_getter_ = NULL; | 42 baseline_context_getter_ = NULL; |
43 } | 43 } |
44 | 44 |
45 // Apply the user agent which was set earlier. | 45 // Apply the user agent which was set earlier. |
46 if (is_user_agent_set()) | 46 if (is_user_agent_set()) |
47 context_->set_user_agent(user_agent_); | 47 context_->set_user_agent(user_agent_); |
48 | 48 |
49 return context_; | 49 return context_.get(); |
50 } | 50 } |
51 | 51 |
52 scoped_refptr<base::MessageLoopProxy> | 52 scoped_refptr<base::MessageLoopProxy> |
53 HttpBridge::RequestContextGetter::GetIOMessageLoopProxy() const { | 53 HttpBridge::RequestContextGetter::GetIOMessageLoopProxy() const { |
54 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 54 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
55 } | 55 } |
56 | 56 |
57 HttpBridgeFactory::HttpBridgeFactory( | 57 HttpBridgeFactory::HttpBridgeFactory( |
58 net::URLRequestContextGetter* baseline_context_getter) { | 58 net::URLRequestContextGetter* baseline_context_getter) { |
59 DCHECK(baseline_context_getter != NULL); | 59 DCHECK(baseline_context_getter != NULL); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 // URLFetcher, so it seems most natural / "polite" to let the stack unwind. | 301 // URLFetcher, so it seems most natural / "polite" to let the stack unwind. |
302 MessageLoop::current()->DeleteSoon(FROM_HERE, fetch_state_.url_poster); | 302 MessageLoop::current()->DeleteSoon(FROM_HERE, fetch_state_.url_poster); |
303 fetch_state_.url_poster = NULL; | 303 fetch_state_.url_poster = NULL; |
304 | 304 |
305 // Wake the blocked syncer thread in MakeSynchronousPost. | 305 // Wake the blocked syncer thread in MakeSynchronousPost. |
306 // WARNING: DONT DO ANYTHING AFTER THIS CALL! |this| may be deleted! | 306 // WARNING: DONT DO ANYTHING AFTER THIS CALL! |this| may be deleted! |
307 http_post_completed_.Signal(); | 307 http_post_completed_.Signal(); |
308 } | 308 } |
309 | 309 |
310 } // namespace browser_sync | 310 } // namespace browser_sync |
OLD | NEW |