Chromium Code Reviews| 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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 | 242 |
| 243 main_context_getter_ = new CronetURLRequestContextGetter( | 243 main_context_getter_ = new CronetURLRequestContextGetter( |
| 244 this, network_io_thread_->task_runner()); | 244 this, network_io_thread_->task_runner()); |
| 245 base::subtle::MemoryBarrier(); | 245 base::subtle::MemoryBarrier(); |
| 246 PostToNetworkThread(FROM_HERE, | 246 PostToNetworkThread(FROM_HERE, |
| 247 base::Bind(&CronetEnvironment::InitializeOnNetworkThread, | 247 base::Bind(&CronetEnvironment::InitializeOnNetworkThread, |
| 248 base::Unretained(this))); | 248 base::Unretained(this))); |
| 249 } | 249 } |
| 250 | 250 |
| 251 CronetEnvironment::~CronetEnvironment() { | 251 CronetEnvironment::~CronetEnvironment() { |
| 252 // net::HTTPProtocolHandlerDelegate::SetInstance(nullptr); | 252 // net::HTTPProtocolHandlerDelegate::SetInstance(nullptr); |
|
mef
2017/05/01 19:12:58
Please add TODO to make unregistering of HTTPProto
lilyhoughton
2017/05/01 19:28:12
Done.
| |
| 253 | 253 |
| 254 // TODO(lilyhoughton) right now this is relying on there being | 254 // TODO(lilyhoughton) this can only be run once, so right now leaking it. |
| 255 // only one CronetEnvironment (per process). if (when?) that | 255 // Should be be called when the _last_ CronetEnvironment is destroyed. |
| 256 // changes, so will this have to. | 256 // base::TaskScheduler* ts = base::TaskScheduler::GetInstance(); |
|
mef
2017/05/01 19:12:58
Do we actually need to call this at all?
lilyhoughton
2017/05/01 19:28:12
I will do more research to check.
| |
| 257 base::TaskScheduler* ts = base::TaskScheduler::GetInstance(); | 257 // if (ts) |
| 258 if (ts) | 258 // ts->Shutdown(); |
| 259 ts->Shutdown(); | 259 |
| 260 // TODO(lilyhoughton) this should be smarter about making sure there are no | |
| 261 // pending requests, etc. | |
| 262 | |
| 263 network_io_thread_->task_runner().get()->DeleteSoon(FROM_HERE, | |
| 264 main_context_.release()); | |
| 260 } | 265 } |
| 261 | 266 |
| 262 void CronetEnvironment::InitializeOnNetworkThread() { | 267 void CronetEnvironment::InitializeOnNetworkThread() { |
| 263 DCHECK(network_io_thread_->task_runner()->BelongsToCurrentThread()); | 268 DCHECK(network_io_thread_->task_runner()->BelongsToCurrentThread()); |
| 264 base::FeatureList::InitializeInstance(std::string(), std::string()); | 269 base::FeatureList::InitializeInstance(std::string(), std::string()); |
| 265 | 270 |
| 266 static bool ssl_key_log_file_set = false; | 271 static bool ssl_key_log_file_set = false; |
| 267 if (!ssl_key_log_file_set && !ssl_key_log_file_name_.empty()) { | 272 if (!ssl_key_log_file_set && !ssl_key_log_file_name_.empty()) { |
| 268 ssl_key_log_file_set = true; | 273 ssl_key_log_file_set = true; |
| 269 base::FilePath ssl_key_log_file; | 274 base::FilePath ssl_key_log_file; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 371 event->Signal(); | 376 event->Signal(); |
| 372 } | 377 } |
| 373 | 378 |
| 374 std::string CronetEnvironment::getDefaultQuicUserAgentId() const { | 379 std::string CronetEnvironment::getDefaultQuicUserAgentId() const { |
| 375 return base::SysNSStringToUTF8([[NSBundle mainBundle] | 380 return base::SysNSStringToUTF8([[NSBundle mainBundle] |
| 376 objectForInfoDictionaryKey:@"CFBundleDisplayName"]) + | 381 objectForInfoDictionaryKey:@"CFBundleDisplayName"]) + |
| 377 " Cronet/" + CRONET_VERSION; | 382 " Cronet/" + CRONET_VERSION; |
| 378 } | 383 } |
| 379 | 384 |
| 380 } // namespace cronet | 385 } // namespace cronet |
| OLD | NEW |