| 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" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 return main_context_.get(); | 105 return main_context_.get(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 net::URLRequestContextGetter* CronetEnvironment::GetURLRequestContextGetter() | 108 net::URLRequestContextGetter* CronetEnvironment::GetURLRequestContextGetter() |
| 109 const { | 109 const { |
| 110 return main_context_getter_.get(); | 110 return main_context_getter_.get(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 // static | 113 // static |
| 114 void CronetEnvironment::Initialize() { | 114 void CronetEnvironment::Initialize() { |
| 115 // DCHECK_EQ([NSThread currentThread], [NSThread mainThread]); | |
| 116 // This method must be called once from the main thread. | 115 // This method must be called once from the main thread. |
| 116 DCHECK_EQ([NSThread currentThread], [NSThread mainThread]); |
| 117 if (!g_at_exit_) | 117 if (!g_at_exit_) |
| 118 g_at_exit_ = new base::AtExitManager; | 118 g_at_exit_ = new base::AtExitManager; |
| 119 | 119 |
| 120 base::TaskScheduler::CreateAndStartWithDefaultParams("CronetIos"); | 120 base::TaskScheduler::CreateAndStartWithDefaultParams("CronetIos"); |
| 121 | 121 |
| 122 url::Initialize(); | 122 url::Initialize(); |
| 123 base::CommandLine::Init(0, nullptr); | 123 base::CommandLine::Init(0, nullptr); |
| 124 | 124 |
| 125 // Without doing this, StatisticsRecorder::FactoryGet() leaks one histogram | 125 // Without doing this, StatisticsRecorder::FactoryGet() leaks one histogram |
| 126 // per call after the first for a given name. | 126 // per call after the first for a given name. |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 const net::HttpUserAgentSettings* user_agent_settings = | 343 const net::HttpUserAgentSettings* user_agent_settings = |
| 344 main_context_->http_user_agent_settings(); | 344 main_context_->http_user_agent_settings(); |
| 345 if (!user_agent_settings) { | 345 if (!user_agent_settings) { |
| 346 return nullptr; | 346 return nullptr; |
| 347 } | 347 } |
| 348 | 348 |
| 349 return user_agent_settings->GetUserAgent(); | 349 return user_agent_settings->GetUserAgent(); |
| 350 } | 350 } |
| 351 | 351 |
| 352 std::vector<uint8_t> CronetEnvironment::GetHistogramDeltas() { | 352 std::vector<uint8_t> CronetEnvironment::GetHistogramDeltas() { |
| 353 base::StatisticsRecorder::Initialize(); | 353 DCHECK(base::StatisticsRecorder::IsActive()); |
| 354 std::vector<uint8_t> data; | 354 std::vector<uint8_t> data; |
| 355 if (!HistogramManager::GetInstance()->GetDeltas(&data)) | 355 if (!HistogramManager::GetInstance()->GetDeltas(&data)) |
| 356 return std::vector<uint8_t>(); | 356 return std::vector<uint8_t>(); |
| 357 return data; | 357 return data; |
| 358 } | 358 } |
| 359 | 359 |
| 360 void CronetEnvironment::SetHostResolverRules(const std::string& rules) { | 360 void CronetEnvironment::SetHostResolverRules(const std::string& rules) { |
| 361 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, | 361 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 362 base::WaitableEvent::InitialState::NOT_SIGNALED); | 362 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 363 PostToNetworkThread( | 363 PostToNetworkThread( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 375 event->Signal(); | 375 event->Signal(); |
| 376 } | 376 } |
| 377 | 377 |
| 378 std::string CronetEnvironment::getDefaultQuicUserAgentId() const { | 378 std::string CronetEnvironment::getDefaultQuicUserAgentId() const { |
| 379 return base::SysNSStringToUTF8([[NSBundle mainBundle] | 379 return base::SysNSStringToUTF8([[NSBundle mainBundle] |
| 380 objectForInfoDictionaryKey:@"CFBundleDisplayName"]) + | 380 objectForInfoDictionaryKey:@"CFBundleDisplayName"]) + |
| 381 " Cronet/" + CRONET_VERSION; | 381 " Cronet/" + CRONET_VERSION; |
| 382 } | 382 } |
| 383 | 383 |
| 384 } // namespace cronet | 384 } // namespace cronet |
| OLD | NEW |