Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Side by Side Diff: sync/internal_api/http_bridge.cc

Issue 311393002: Add URLRequestJobFactories to URLRequestContexts without one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comment Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/base/url_request_context.cc ('k') | sync/internal_api/public/http_bridge.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "sync/internal_api/public/http_bridge.h" 5 #include "sync/internal_api/public/http_bridge.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "net/base/load_flags.h" 10 #include "net/base/load_flags.h"
11 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
12 #include "net/cookies/cookie_monster.h" 12 #include "net/cookies/cookie_monster.h"
13 #include "net/http/http_cache.h" 13 #include "net/http/http_cache.h"
14 #include "net/http/http_network_layer.h" 14 #include "net/http/http_network_layer.h"
15 #include "net/http/http_response_headers.h" 15 #include "net/http/http_response_headers.h"
16 #include "net/url_request/static_http_user_agent_settings.h" 16 #include "net/url_request/static_http_user_agent_settings.h"
17 #include "net/url_request/url_fetcher.h" 17 #include "net/url_request/url_fetcher.h"
18 #include "net/url_request/url_request_context.h" 18 #include "net/url_request/url_request_context.h"
19 #include "net/url_request/url_request_job_factory_impl.h"
19 #include "net/url_request/url_request_status.h" 20 #include "net/url_request/url_request_status.h"
20 #include "sync/internal_api/public/base/cancelation_signal.h" 21 #include "sync/internal_api/public/base/cancelation_signal.h"
21 22
22 namespace syncer { 23 namespace syncer {
23 24
24 HttpBridge::RequestContextGetter::RequestContextGetter( 25 HttpBridge::RequestContextGetter::RequestContextGetter(
25 net::URLRequestContextGetter* baseline_context_getter, 26 net::URLRequestContextGetter* baseline_context_getter,
26 const std::string& user_agent) 27 const std::string& user_agent)
27 : baseline_context_getter_(baseline_context_getter), 28 : baseline_context_getter_(baseline_context_getter),
28 network_task_runner_( 29 network_task_runner_(
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 baseline_request_context_getter_ = NULL; 116 baseline_request_context_getter_ = NULL;
116 request_context_getter_ = NULL; 117 request_context_getter_ = NULL;
117 } 118 }
118 119
119 HttpBridge::RequestContext::RequestContext( 120 HttpBridge::RequestContext::RequestContext(
120 net::URLRequestContext* baseline_context, 121 net::URLRequestContext* baseline_context,
121 const scoped_refptr<base::SingleThreadTaskRunner>& 122 const scoped_refptr<base::SingleThreadTaskRunner>&
122 network_task_runner, 123 network_task_runner,
123 const std::string& user_agent) 124 const std::string& user_agent)
124 : baseline_context_(baseline_context), 125 : baseline_context_(baseline_context),
125 network_task_runner_(network_task_runner) { 126 network_task_runner_(network_task_runner),
127 job_factory_(new net::URLRequestJobFactoryImpl()) {
126 DCHECK(!user_agent.empty()); 128 DCHECK(!user_agent.empty());
127 129
128 // Create empty, in-memory cookie store. 130 // Create empty, in-memory cookie store.
129 set_cookie_store(new net::CookieMonster(NULL, NULL)); 131 set_cookie_store(new net::CookieMonster(NULL, NULL));
130 132
131 // We don't use a cache for bridged loads, but we do want to share proxy info. 133 // We don't use a cache for bridged loads, but we do want to share proxy info.
132 set_host_resolver(baseline_context->host_resolver()); 134 set_host_resolver(baseline_context->host_resolver());
133 set_proxy_service(baseline_context->proxy_service()); 135 set_proxy_service(baseline_context->proxy_service());
134 set_ssl_config_service(baseline_context->ssl_config_service()); 136 set_ssl_config_service(baseline_context->ssl_config_service());
135 137
138 // Use its own job factory, which only supports http and https.
139 set_job_factory(job_factory_.get());
140
136 // We want to share the HTTP session data with the network layer factory, 141 // We want to share the HTTP session data with the network layer factory,
137 // which includes auth_cache for proxies. 142 // which includes auth_cache for proxies.
138 // Session is not refcounted so we need to be careful to not lose the parent 143 // Session is not refcounted so we need to be careful to not lose the parent
139 // context. 144 // context.
140 net::HttpNetworkSession* session = 145 net::HttpNetworkSession* session =
141 baseline_context->http_transaction_factory()->GetSession(); 146 baseline_context->http_transaction_factory()->GetSession();
142 DCHECK(session); 147 DCHECK(session);
143 set_http_transaction_factory(new net::HttpNetworkLayer(session)); 148 set_http_transaction_factory(new net::HttpNetworkLayer(session));
144 149
145 // TODO(timsteele): We don't currently listen for pref changes of these 150 // TODO(timsteele): We don't currently listen for pref changes of these
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 int64 sane_time_ms = 0; 396 int64 sane_time_ms = 0;
392 if (base::StringToInt64(sane_time_str, &sane_time_ms)) { 397 if (base::StringToInt64(sane_time_str, &sane_time_ms)) {
393 network_time_update_callback_.Run( 398 network_time_update_callback_.Run(
394 base::Time::FromJsTime(sane_time_ms), 399 base::Time::FromJsTime(sane_time_ms),
395 base::TimeDelta::FromMilliseconds(1), 400 base::TimeDelta::FromMilliseconds(1),
396 fetch_state_.end_time - fetch_state_.start_time); 401 fetch_state_.end_time - fetch_state_.start_time);
397 } 402 }
398 } 403 }
399 404
400 } // namespace syncer 405 } // namespace syncer
OLDNEW
« no previous file with comments | « remoting/base/url_request_context.cc ('k') | sync/internal_api/public/http_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698