OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ios/cronet_environment.h" | 5 #include "components/cronet/ios/cronet_environment.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/atomicops.h" | 10 #include "base/atomicops.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/feature_list.h" | 12 #include "base/feature_list.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
15 #include "base/files/scoped_file.h" | 15 #include "base/files/scoped_file.h" |
16 #include "base/json/json_writer.h" | 16 #include "base/json/json_writer.h" |
17 #include "base/mac/bind_objc_block.h" | 17 #include "base/mac/bind_objc_block.h" |
18 #include "base/mac/foundation_util.h" | 18 #include "base/mac/foundation_util.h" |
19 #include "base/macros.h" | 19 #include "base/macros.h" |
20 #include "base/memory/ptr_util.h" | 20 #include "base/memory/ptr_util.h" |
21 #include "base/metrics/statistics_recorder.h" | 21 #include "base/metrics/statistics_recorder.h" |
22 #include "base/path_service.h" | 22 #include "base/path_service.h" |
23 #include "base/single_thread_task_runner.h" | 23 #include "base/single_thread_task_runner.h" |
24 #include "base/synchronization/waitable_event.h" | 24 #include "base/synchronization/waitable_event.h" |
25 #include "base/sys_info.h" | |
26 #include "base/task_scheduler/task_scheduler.h" | 25 #include "base/task_scheduler/task_scheduler.h" |
27 #include "base/threading/worker_pool.h" | 26 #include "base/threading/worker_pool.h" |
28 #include "components/cronet/histogram_manager.h" | 27 #include "components/cronet/histogram_manager.h" |
29 #include "components/cronet/ios/version.h" | 28 #include "components/cronet/ios/version.h" |
30 #include "components/prefs/json_pref_store.h" | 29 #include "components/prefs/json_pref_store.h" |
31 #include "components/prefs/pref_filter.h" | 30 #include "components/prefs/pref_filter.h" |
32 #include "ios/net/cookies/cookie_store_ios.h" | 31 #include "ios/net/cookies/cookie_store_ios.h" |
33 #include "ios/web/public/user_agent.h" | 32 #include "ios/web/public/user_agent.h" |
34 #include "net/base/network_change_notifier.h" | 33 #include "net/base/network_change_notifier.h" |
35 #include "net/cert/cert_verifier.h" | 34 #include "net/cert/cert_verifier.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 return main_context_getter_.get(); | 111 return main_context_getter_.get(); |
113 } | 112 } |
114 | 113 |
115 // static | 114 // static |
116 void CronetEnvironment::Initialize() { | 115 void CronetEnvironment::Initialize() { |
117 // DCHECK_EQ([NSThread currentThread], [NSThread mainThread]); | 116 // DCHECK_EQ([NSThread currentThread], [NSThread mainThread]); |
118 // This method must be called once from the main thread. | 117 // This method must be called once from the main thread. |
119 if (!g_at_exit_) | 118 if (!g_at_exit_) |
120 g_at_exit_ = new base::AtExitManager; | 119 g_at_exit_ = new base::AtExitManager; |
121 | 120 |
122 base::TaskScheduler::CreateAndSetSimpleTaskScheduler( | 121 base::TaskScheduler::CreateAndSetSimpleTaskScheduler("Cronet"); |
robliao
2017/03/13 23:56:05
CronetIos might be more specific.
Remoting in a l
fdoray
2017/03/14 15:08:22
Done.
| |
123 base::SysInfo::NumberOfProcessors()); | |
124 | 122 |
125 url::Initialize(); | 123 url::Initialize(); |
126 base::CommandLine::Init(0, nullptr); | 124 base::CommandLine::Init(0, nullptr); |
127 | 125 |
128 // Without doing this, StatisticsRecorder::FactoryGet() leaks one histogram | 126 // Without doing this, StatisticsRecorder::FactoryGet() leaks one histogram |
129 // per call after the first for a given name. | 127 // per call after the first for a given name. |
130 base::StatisticsRecorder::Initialize(); | 128 base::StatisticsRecorder::Initialize(); |
131 | 129 |
132 // Create a message loop on the UI thread. | 130 // Create a message loop on the UI thread. |
133 DCHECK(!base::MessageLoop::current()); | 131 DCHECK(!base::MessageLoop::current()); |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
376 event->Signal(); | 374 event->Signal(); |
377 } | 375 } |
378 | 376 |
379 std::string CronetEnvironment::getDefaultQuicUserAgentId() const { | 377 std::string CronetEnvironment::getDefaultQuicUserAgentId() const { |
380 return base::SysNSStringToUTF8([[NSBundle mainBundle] | 378 return base::SysNSStringToUTF8([[NSBundle mainBundle] |
381 objectForInfoDictionaryKey:@"CFBundleDisplayName"]) + | 379 objectForInfoDictionaryKey:@"CFBundleDisplayName"]) + |
382 " Cronet/" + CRONET_VERSION; | 380 " Cronet/" + CRONET_VERSION; |
383 } | 381 } |
384 | 382 |
385 } // namespace cronet | 383 } // namespace cronet |
OLD | NEW |