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

Side by Side Diff: components/cronet/android/cronet_url_request_context_adapter.cc

Issue 1303493002: Make UrlRequestContextBuilder take scoped_ptr's (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync and fix tiny resulting build failure Created 5 years, 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/cronet/android/cronet_url_request_context_adapter.h" 5 #include "components/cronet/android/cronet_url_request_context_adapter.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 void CronetURLRequestContextAdapter::InitializeOnNetworkThread( 159 void CronetURLRequestContextAdapter::InitializeOnNetworkThread(
160 scoped_ptr<URLRequestContextConfig> config, 160 scoped_ptr<URLRequestContextConfig> config,
161 const base::android::ScopedJavaGlobalRef<jobject>& 161 const base::android::ScopedJavaGlobalRef<jobject>&
162 jcronet_url_request_context) { 162 jcronet_url_request_context) {
163 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); 163 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread());
164 DCHECK(!is_context_initialized_); 164 DCHECK(!is_context_initialized_);
165 DCHECK(proxy_config_service_); 165 DCHECK(proxy_config_service_);
166 // TODO(mmenke): Add method to have the builder enable SPDY. 166 // TODO(mmenke): Add method to have the builder enable SPDY.
167 net::URLRequestContextBuilder context_builder; 167 net::URLRequestContextBuilder context_builder;
168 168
169 scoped_ptr<net::NetLog> net_log(new net::NetLog); 169 net_log_.reset(new net::NetLog);
170 scoped_ptr<net::NetworkDelegate> network_delegate(new BasicNetworkDelegate()); 170 scoped_ptr<net::NetworkDelegate> network_delegate(new BasicNetworkDelegate());
171 #if defined(DATA_REDUCTION_PROXY_SUPPORT) 171 #if defined(DATA_REDUCTION_PROXY_SUPPORT)
172 DCHECK(!data_reduction_proxy_); 172 DCHECK(!data_reduction_proxy_);
173 // For now, the choice to enable the data reduction proxy happens once, 173 // For now, the choice to enable the data reduction proxy happens once,
174 // at initialization. It cannot be disabled thereafter. 174 // at initialization. It cannot be disabled thereafter.
175 if (!config->data_reduction_proxy_key.empty()) { 175 if (!config->data_reduction_proxy_key.empty()) {
176 data_reduction_proxy_.reset( 176 data_reduction_proxy_.reset(new CronetDataReductionProxy(
177 new CronetDataReductionProxy( 177 config->data_reduction_proxy_key, config->data_reduction_primary_proxy,
178 config->data_reduction_proxy_key, 178 config->data_reduction_fallback_proxy,
179 config->data_reduction_primary_proxy, 179 config->data_reduction_secure_proxy_check_url, config->user_agent,
180 config->data_reduction_fallback_proxy, 180 GetNetworkTaskRunner(), net_log_.get()));
181 config->data_reduction_secure_proxy_check_url,
182 config->user_agent,
183 GetNetworkTaskRunner(),
184 net_log.get()));
185 network_delegate = 181 network_delegate =
186 data_reduction_proxy_->CreateNetworkDelegate(network_delegate.Pass()); 182 data_reduction_proxy_->CreateNetworkDelegate(network_delegate.Pass());
187 ScopedVector<net::URLRequestInterceptor> interceptors; 183 ScopedVector<net::URLRequestInterceptor> interceptors;
188 interceptors.push_back(data_reduction_proxy_->CreateInterceptor()); 184 interceptors.push_back(data_reduction_proxy_->CreateInterceptor());
189 context_builder.SetInterceptors(interceptors.Pass()); 185 context_builder.SetInterceptors(interceptors.Pass());
190 } 186 }
191 #endif // defined(DATA_REDUCTION_PROXY_SUPPORT) 187 #endif // defined(DATA_REDUCTION_PROXY_SUPPORT)
192 context_builder.set_network_delegate(network_delegate.release()); 188 context_builder.set_network_delegate(network_delegate.Pass());
193 context_builder.set_net_log(net_log.release()); 189 context_builder.set_net_log(net_log_.get());
194 context_builder.set_proxy_config_service(proxy_config_service_.release()); 190 context_builder.set_proxy_config_service(proxy_config_service_.Pass());
195 config->ConfigureURLRequestContextBuilder(&context_builder); 191 config->ConfigureURLRequestContextBuilder(&context_builder);
196 192
197 // Set up pref file if storage path is specified. 193 // Set up pref file if storage path is specified.
198 if (!config->storage_path.empty()) { 194 if (!config->storage_path.empty()) {
199 base::FilePath filepath(config->storage_path); 195 base::FilePath filepath(config->storage_path);
200 filepath = filepath.Append(FILE_PATH_LITERAL("local_prefs.json")); 196 filepath = filepath.Append(FILE_PATH_LITERAL("local_prefs.json"));
201 json_pref_store_ = new JsonPrefStore( 197 json_pref_store_ = new JsonPrefStore(
202 filepath, GetFileThread()->task_runner(), scoped_ptr<PrefFilter>()); 198 filepath, GetFileThread()->task_runner(), scoped_ptr<PrefFilter>());
203 context_builder.SetFileTaskRunner(GetFileThread()->task_runner()); 199 context_builder.SetFileTaskRunner(GetFileThread()->task_runner());
204 200
205 // Set up HttpServerPropertiesManager. 201 // Set up HttpServerPropertiesManager.
206 base::PrefServiceFactory factory; 202 base::PrefServiceFactory factory;
207 factory.set_user_prefs(json_pref_store_); 203 factory.set_user_prefs(json_pref_store_);
208 scoped_refptr<PrefRegistrySimple> registry(new PrefRegistrySimple()); 204 scoped_refptr<PrefRegistrySimple> registry(new PrefRegistrySimple());
209 registry->RegisterDictionaryPref(kHttpServerProperties, 205 registry->RegisterDictionaryPref(kHttpServerProperties,
210 new base::DictionaryValue()); 206 new base::DictionaryValue());
211 pref_service_ = factory.Create(registry.get()).Pass(); 207 pref_service_ = factory.Create(registry.get()).Pass();
212 208
213 scoped_ptr<net::HttpServerPropertiesManager> http_server_properties_manager( 209 scoped_ptr<net::HttpServerPropertiesManager> http_server_properties_manager(
214 new net::HttpServerPropertiesManager(pref_service_.get(), 210 new net::HttpServerPropertiesManager(pref_service_.get(),
215 kHttpServerProperties, 211 kHttpServerProperties,
216 GetNetworkTaskRunner())); 212 GetNetworkTaskRunner()));
217 http_server_properties_manager->InitializeOnNetworkThread(); 213 http_server_properties_manager->InitializeOnNetworkThread();
218 http_server_properties_manager_ = http_server_properties_manager.get(); 214 http_server_properties_manager_ = http_server_properties_manager.get();
219 context_builder.SetHttpServerProperties( 215 context_builder.SetHttpServerProperties(
220 http_server_properties_manager.Pass()); 216 http_server_properties_manager.Pass());
221 } 217 }
222 218
223 context_.reset(context_builder.Build()); 219 context_ = context_builder.Build().Pass();
224 220
225 default_load_flags_ = net::LOAD_DO_NOT_SAVE_COOKIES | 221 default_load_flags_ = net::LOAD_DO_NOT_SAVE_COOKIES |
226 net::LOAD_DO_NOT_SEND_COOKIES; 222 net::LOAD_DO_NOT_SEND_COOKIES;
227 if (config->load_disable_cache) 223 if (config->load_disable_cache)
228 default_load_flags_ |= net::LOAD_DISABLE_CACHE; 224 default_load_flags_ |= net::LOAD_DISABLE_CACHE;
229 225
230 if (config->enable_sdch) { 226 if (config->enable_sdch) {
231 DCHECK(context_->sdch_manager()); 227 DCHECK(context_->sdch_manager());
232 sdch_owner_.reset( 228 sdch_owner_.reset(
233 new net::SdchOwner(context_->sdch_manager(), context_.get())); 229 new net::SdchOwner(context_->sdch_manager(), context_.get()));
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 } 413 }
418 414
419 static jint SetMinLogLevel(JNIEnv* env, jclass jcaller, jint jlog_level) { 415 static jint SetMinLogLevel(JNIEnv* env, jclass jcaller, jint jlog_level) {
420 jint old_log_level = static_cast<jint>(logging::GetMinLogLevel()); 416 jint old_log_level = static_cast<jint>(logging::GetMinLogLevel());
421 // MinLogLevel is global, shared by all URLRequestContexts. 417 // MinLogLevel is global, shared by all URLRequestContexts.
422 logging::SetMinLogLevel(static_cast<int>(jlog_level)); 418 logging::SetMinLogLevel(static_cast<int>(jlog_level));
423 return old_log_level; 419 return old_log_level;
424 } 420 }
425 421
426 } // namespace cronet 422 } // namespace cronet
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698