OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/string_util.h" | 9 #include "base/string_util.h" |
9 #include "chrome/browser/chrome_thread.h" | 10 #include "chrome/browser/chrome_thread.h" |
10 #include "chrome/browser/profile.h" | 11 #include "chrome/browser/profile.h" |
11 #include "chrome/browser/chrome_thread.h" | 12 #include "chrome/browser/chrome_thread.h" |
12 #include "net/base/cookie_monster.h" | 13 #include "net/base/cookie_monster.h" |
13 #include "net/base/load_flags.h" | 14 #include "net/base/load_flags.h" |
14 #include "net/http/http_cache.h" | 15 #include "net/http/http_cache.h" |
15 #include "net/http/http_network_layer.h" | 16 #include "net/http/http_network_layer.h" |
16 #include "net/http/http_response_headers.h" | 17 #include "net/http/http_response_headers.h" |
17 #include "net/proxy/proxy_service.h" | 18 #include "net/proxy/proxy_service.h" |
(...skipping 17 matching lines...) Expand all Loading... |
35 baseline_context_getter_ = NULL; | 36 baseline_context_getter_ = NULL; |
36 } | 37 } |
37 | 38 |
38 // Apply the user agent which was set earlier. | 39 // Apply the user agent which was set earlier. |
39 if (is_user_agent_set()) | 40 if (is_user_agent_set()) |
40 context_->set_user_agent(user_agent_); | 41 context_->set_user_agent(user_agent_); |
41 | 42 |
42 return context_; | 43 return context_; |
43 } | 44 } |
44 | 45 |
| 46 scoped_refptr<MessageLoopProxy> |
| 47 HttpBridge::RequestContextGetter::GetIOMessageLoopProxy() { |
| 48 return ChromeThread::GetMessageLoopProxyForThread(ChromeThread::IO); |
| 49 } |
| 50 |
45 HttpBridgeFactory::HttpBridgeFactory( | 51 HttpBridgeFactory::HttpBridgeFactory( |
46 URLRequestContextGetter* baseline_context_getter) { | 52 URLRequestContextGetter* baseline_context_getter) { |
47 DCHECK(baseline_context_getter != NULL); | 53 DCHECK(baseline_context_getter != NULL); |
48 request_context_getter_ = | 54 request_context_getter_ = |
49 new HttpBridge::RequestContextGetter(baseline_context_getter); | 55 new HttpBridge::RequestContextGetter(baseline_context_getter); |
50 } | 56 } |
51 | 57 |
52 HttpBridgeFactory::~HttpBridgeFactory() { | 58 HttpBridgeFactory::~HttpBridgeFactory() { |
53 } | 59 } |
54 | 60 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // figure out if we need to give the user explicit control over policies etc. | 97 // figure out if we need to give the user explicit control over policies etc. |
92 accept_language_ = baseline_context->accept_language(); | 98 accept_language_ = baseline_context->accept_language(); |
93 accept_charset_ = baseline_context->accept_charset(); | 99 accept_charset_ = baseline_context->accept_charset(); |
94 | 100 |
95 // We default to the browser's user agent. This can (and should) be overridden | 101 // We default to the browser's user agent. This can (and should) be overridden |
96 // with set_user_agent. | 102 // with set_user_agent. |
97 user_agent_ = webkit_glue::GetUserAgent(GURL()); | 103 user_agent_ = webkit_glue::GetUserAgent(GURL()); |
98 } | 104 } |
99 | 105 |
100 HttpBridge::RequestContext::~RequestContext() { | 106 HttpBridge::RequestContext::~RequestContext() { |
| 107 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
101 delete http_transaction_factory_; | 108 delete http_transaction_factory_; |
102 } | 109 } |
103 | 110 |
104 HttpBridge::HttpBridge(HttpBridge::RequestContextGetter* context_getter) | 111 HttpBridge::HttpBridge(HttpBridge::RequestContextGetter* context_getter) |
105 : context_getter_for_request_(context_getter), | 112 : context_getter_for_request_(context_getter), |
106 url_poster_(NULL), | 113 url_poster_(NULL), |
107 created_on_loop_(MessageLoop::current()), | 114 created_on_loop_(MessageLoop::current()), |
108 request_completed_(false), | 115 request_completed_(false), |
109 request_succeeded_(false), | 116 request_succeeded_(false), |
110 http_response_code_(-1), | 117 http_response_code_(-1), |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 // URLFetcher, so it seems most natural / "polite" to let the stack unwind. | 236 // URLFetcher, so it seems most natural / "polite" to let the stack unwind. |
230 MessageLoop::current()->DeleteSoon(FROM_HERE, url_poster_); | 237 MessageLoop::current()->DeleteSoon(FROM_HERE, url_poster_); |
231 url_poster_ = NULL; | 238 url_poster_ = NULL; |
232 | 239 |
233 // Wake the blocked syncer thread in MakeSynchronousPost. | 240 // Wake the blocked syncer thread in MakeSynchronousPost. |
234 // WARNING: DONT DO ANYTHING AFTER THIS CALL! |this| may be deleted! | 241 // WARNING: DONT DO ANYTHING AFTER THIS CALL! |this| may be deleted! |
235 http_post_completed_.Signal(); | 242 http_post_completed_.Signal(); |
236 } | 243 } |
237 | 244 |
238 } // namespace browser_sync | 245 } // namespace browser_sync |
OLD | NEW |