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

Side by Side Diff: ios/crnet/crnet_environment.mm

Issue 1882433002: Removing NSS files and USE_OPENSSL flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 8 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 "ios/crnet/crnet_environment.h" 5 #include "ios/crnet/crnet_environment.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/at_exit.h" 11 #include "base/at_exit.h"
12 #include "base/atomicops.h" 12 #include "base/atomicops.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
16 #include "base/files/scoped_file.h" 16 #include "base/files/scoped_file.h"
17 #include "base/i18n/icu_util.h" 17 #include "base/i18n/icu_util.h"
18 #include "base/json/json_writer.h" 18 #include "base/json/json_writer.h"
19 #include "base/mac/bind_objc_block.h" 19 #include "base/mac/bind_objc_block.h"
20 #include "base/mac/foundation_util.h" 20 #include "base/mac/foundation_util.h"
21 #include "base/mac/scoped_block.h" 21 #include "base/mac/scoped_block.h"
22 #include "base/macros.h" 22 #include "base/macros.h"
23 #include "base/memory/ptr_util.h" 23 #include "base/memory/ptr_util.h"
24 #include "base/metrics/statistics_recorder.h" 24 #include "base/metrics/statistics_recorder.h"
25 #include "base/path_service.h" 25 #include "base/path_service.h"
26 #include "base/threading/worker_pool.h" 26 #include "base/threading/worker_pool.h"
27 #include "components/prefs/json_pref_store.h" 27 #include "components/prefs/json_pref_store.h"
28 #include "components/prefs/pref_filter.h" 28 #include "components/prefs/pref_filter.h"
29 #include "crypto/nss_util.h" 29 #include "crypto/nss_util.h"
Eugene But (OOO till 7-30) 2016/04/19 15:00:12 Do you still need this include?
svaldez 2016/04/19 15:12:25 Done.
30 #include "ios/crnet/sdch_owner_pref_storage.h" 30 #include "ios/crnet/sdch_owner_pref_storage.h"
31 #include "ios/net/cookies/cookie_store_ios.h" 31 #include "ios/net/cookies/cookie_store_ios.h"
32 #include "ios/net/crn_http_protocol_handler.h" 32 #include "ios/net/crn_http_protocol_handler.h"
33 #include "ios/net/empty_nsurlcache.h" 33 #include "ios/net/empty_nsurlcache.h"
34 #include "ios/net/http_cache_helper.h" 34 #include "ios/net/http_cache_helper.h"
35 #include "ios/net/request_tracker.h" 35 #include "ios/net/request_tracker.h"
36 #include "ios/web/public/user_agent.h" 36 #include "ios/web/public/user_agent.h"
37 #include "net/base/net_errors.h" 37 #include "net/base/net_errors.h"
38 #include "net/base/network_change_notifier.h" 38 #include "net/base/network_change_notifier.h"
39 #include "net/base/sdch_manager.h" 39 #include "net/base/sdch_manager.h"
40 #include "net/cert/cert_verifier.h" 40 #include "net/cert/cert_verifier.h"
41 #include "net/cert_net/nss_ocsp.h" 41 #include "net/cert_net/nss_ocsp.h"
Eugene But (OOO till 7-30) 2016/04/19 15:00:12 And this
svaldez 2016/04/19 15:12:25 Done.
42 #include "net/cookies/cookie_store.h" 42 #include "net/cookies/cookie_store.h"
43 #include "net/http/http_auth_handler_factory.h" 43 #include "net/http/http_auth_handler_factory.h"
44 #include "net/http/http_cache.h" 44 #include "net/http/http_cache.h"
45 #include "net/http/http_server_properties_impl.h" 45 #include "net/http/http_server_properties_impl.h"
46 #include "net/http/http_stream_factory.h" 46 #include "net/http/http_stream_factory.h"
47 #include "net/http/http_util.h" 47 #include "net/http/http_util.h"
48 #include "net/log/net_log.h" 48 #include "net/log/net_log.h"
49 #include "net/log/write_to_file_net_log_observer.h" 49 #include "net/log/write_to_file_net_log_observer.h"
50 #include "net/proxy/proxy_service.h" 50 #include "net/proxy/proxy_service.h"
51 #include "net/sdch/sdch_owner.h" 51 #include "net/sdch/sdch_owner.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 // static 147 // static
148 void CrNetEnvironment::Initialize() { 148 void CrNetEnvironment::Initialize() {
149 DCHECK_EQ([NSThread currentThread], [NSThread mainThread]); 149 DCHECK_EQ([NSThread currentThread], [NSThread mainThread]);
150 if (!g_at_exit_) 150 if (!g_at_exit_)
151 g_at_exit_ = new base::AtExitManager; 151 g_at_exit_ = new base::AtExitManager;
152 152
153 CHECK(base::i18n::InitializeICU()); 153 CHECK(base::i18n::InitializeICU());
154 url::Initialize(); 154 url::Initialize();
155 base::CommandLine::Init(0, nullptr); 155 base::CommandLine::Init(0, nullptr);
156 156
157 #if defined(USE_NSS_VERIFIER)
158 // This needs to happen on the main thread. NSPR's initialization sets up its
159 // memory allocator; if this is not done before other threads are created,
160 // this initialization can race to cause accidental free/allocation
161 // mismatches.
162 crypto::EnsureNSPRInit();
163 #endif
164
165 // Without doing this, StatisticsRecorder::FactoryGet() leaks one histogram 157 // Without doing this, StatisticsRecorder::FactoryGet() leaks one histogram
166 // per call after the first for a given name. 158 // per call after the first for a given name.
167 base::StatisticsRecorder::Initialize(); 159 base::StatisticsRecorder::Initialize();
168 160
169 // Create a message loop on the UI thread. 161 // Create a message loop on the UI thread.
170 base::MessageLoop* main_message_loop = 162 base::MessageLoop* main_message_loop =
171 new base::MessageLoop(base::MessageLoop::TYPE_UI); 163 new base::MessageLoop(base::MessageLoop::TYPE_UI);
172 #pragma unused(main_message_loop) 164 #pragma unused(main_message_loop)
173 base::MessageLoopForUI::current()->Attach(); 165 base::MessageLoopForUI::current()->Attach();
174 } 166 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 new base::Thread("Chrome File User Blocking Thread")); 277 new base::Thread("Chrome File User Blocking Thread"));
286 file_user_blocking_thread_->StartWithOptions( 278 file_user_blocking_thread_->StartWithOptions(
287 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); 279 base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
288 280
289 // The network change notifier must be initialized so that registered 281 // The network change notifier must be initialized so that registered
290 // delegates will receive callbacks. 282 // delegates will receive callbacks.
291 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); 283 network_change_notifier_.reset(net::NetworkChangeNotifier::Create());
292 proxy_config_service_ = net::ProxyService::CreateSystemProxyConfigService( 284 proxy_config_service_ = net::ProxyService::CreateSystemProxyConfigService(
293 network_io_thread_->task_runner(), nullptr); 285 network_io_thread_->task_runner(), nullptr);
294 286
295 #if defined(USE_NSS_VERIFIER)
296 net::SetURLRequestContextForNSSHttpIO(main_context_.get());
297 #endif
298 main_context_getter_ = new CrNetURLRequestContextGetter( 287 main_context_getter_ = new CrNetURLRequestContextGetter(
299 main_context_.get(), network_io_thread_->task_runner()); 288 main_context_.get(), network_io_thread_->task_runner());
300 base::subtle::MemoryBarrier(); 289 base::subtle::MemoryBarrier();
301 PostToNetworkThread(FROM_HERE, 290 PostToNetworkThread(FROM_HERE,
302 base::Bind(&CrNetEnvironment::InitializeOnNetworkThread, 291 base::Bind(&CrNetEnvironment::InitializeOnNetworkThread,
303 base::Unretained(this))); 292 base::Unretained(this)));
304 293
305 SetRequestFilterBlock(nil); 294 SetRequestFilterBlock(nil);
306 } 295 }
307 296
308 void CrNetEnvironment::InstallIntoSessionConfiguration( 297 void CrNetEnvironment::InstallIntoSessionConfiguration(
309 NSURLSessionConfiguration* config) { 298 NSURLSessionConfiguration* config) {
310 config.protocolClasses = @[ [CRNPauseableHTTPProtocolHandler class] ]; 299 config.protocolClasses = @[ [CRNPauseableHTTPProtocolHandler class] ];
311 } 300 }
312 301
313 CrNetEnvironment::~CrNetEnvironment() { 302 CrNetEnvironment::~CrNetEnvironment() {
314 net::HTTPProtocolHandlerDelegate::SetInstance(nullptr); 303 net::HTTPProtocolHandlerDelegate::SetInstance(nullptr);
315 #if defined(USE_NSS_VERIFIER)
316 net::SetURLRequestContextForNSSHttpIO(nullptr);
317 #endif
318 } 304 }
319 305
320 net::URLRequestContextGetter* CrNetEnvironment::GetMainContextGetter() { 306 net::URLRequestContextGetter* CrNetEnvironment::GetMainContextGetter() {
321 return main_context_getter_.get(); 307 return main_context_getter_.get();
322 } 308 }
323 309
324 void CrNetEnvironment::SetHTTPProtocolHandlerRegistered(bool registered) { 310 void CrNetEnvironment::SetHTTPProtocolHandlerRegistered(bool registered) {
325 if (registered) { 311 if (registered) {
326 // Disable the default cache. 312 // Disable the default cache.
327 [NSURLCache setSharedURLCache:[EmptyNSURLCache emptyNSURLCache]]; 313 [NSURLCache setSharedURLCache:[EmptyNSURLCache emptyNSURLCache]];
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 476
491 return user_agent_settings->GetUserAgent(); 477 return user_agent_settings->GetUserAgent();
492 } 478 }
493 479
494 void CrNetEnvironment::ClearCache(ClearCacheCallback callback) { 480 void CrNetEnvironment::ClearCache(ClearCacheCallback callback) {
495 PostToNetworkThread( 481 PostToNetworkThread(
496 FROM_HERE, 482 FROM_HERE,
497 base::Bind(&net::ClearHttpCache, main_context_getter_, 483 base::Bind(&net::ClearHttpCache, main_context_getter_,
498 network_io_thread_->task_runner(), base::BindBlock(callback))); 484 network_io_thread_->task_runner(), base::BindBlock(callback)));
499 } 485 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698