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

Side by Side Diff: components/cronet/ios/cronet_environment.mm

Issue 2836063005: [cronet] Add mechanism for restarting CronetEnvironment (Closed)
Patch Set: sync Created 3 years, 7 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
« no previous file with comments | « components/cronet/ios/Cronet.mm ('k') | components/cronet/ios/test/cronet_http_test.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 241
242 main_context_getter_ = new CronetURLRequestContextGetter( 242 main_context_getter_ = new CronetURLRequestContextGetter(
243 this, network_io_thread_->task_runner()); 243 this, network_io_thread_->task_runner());
244 base::subtle::MemoryBarrier(); 244 base::subtle::MemoryBarrier();
245 PostToNetworkThread(FROM_HERE, 245 PostToNetworkThread(FROM_HERE,
246 base::Bind(&CronetEnvironment::InitializeOnNetworkThread, 246 base::Bind(&CronetEnvironment::InitializeOnNetworkThread,
247 base::Unretained(this))); 247 base::Unretained(this)));
248 } 248 }
249 249
250 CronetEnvironment::~CronetEnvironment() { 250 CronetEnvironment::~CronetEnvironment() {
251 // TODO(lilyhoughton) make unregistering of this work.
251 // net::HTTPProtocolHandlerDelegate::SetInstance(nullptr); 252 // net::HTTPProtocolHandlerDelegate::SetInstance(nullptr);
252 253
253 // TODO(lilyhoughton) right now this is relying on there being 254 // TODO(lilyhoughton) this can only be run once, so right now leaking it.
254 // only one CronetEnvironment (per process). if (when?) that 255 // Should be be called when the _last_ CronetEnvironment is destroyed.
255 // changes, so will this have to. 256 // base::TaskScheduler* ts = base::TaskScheduler::GetInstance();
256 base::TaskScheduler* ts = base::TaskScheduler::GetInstance(); 257 // if (ts)
257 if (ts) 258 // ts->Shutdown();
258 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());
259 } 265 }
260 266
261 void CronetEnvironment::InitializeOnNetworkThread() { 267 void CronetEnvironment::InitializeOnNetworkThread() {
262 DCHECK(network_io_thread_->task_runner()->BelongsToCurrentThread()); 268 DCHECK(network_io_thread_->task_runner()->BelongsToCurrentThread());
263 base::FeatureList::InitializeInstance(std::string(), std::string()); 269 base::FeatureList::InitializeInstance(std::string(), std::string());
264 270
265 static bool ssl_key_log_file_set = false; 271 static bool ssl_key_log_file_set = false;
266 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()) {
267 ssl_key_log_file_set = true; 273 ssl_key_log_file_set = true;
268 base::FilePath ssl_key_log_file(ssl_key_log_file_name_); 274 base::FilePath ssl_key_log_file(ssl_key_log_file_name_);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 event->Signal(); 375 event->Signal();
370 } 376 }
371 377
372 std::string CronetEnvironment::getDefaultQuicUserAgentId() const { 378 std::string CronetEnvironment::getDefaultQuicUserAgentId() const {
373 return base::SysNSStringToUTF8([[NSBundle mainBundle] 379 return base::SysNSStringToUTF8([[NSBundle mainBundle]
374 objectForInfoDictionaryKey:@"CFBundleDisplayName"]) + 380 objectForInfoDictionaryKey:@"CFBundleDisplayName"]) +
375 " Cronet/" + CRONET_VERSION; 381 " Cronet/" + CRONET_VERSION;
376 } 382 }
377 383
378 } // namespace cronet 384 } // namespace cronet
OLDNEW
« no previous file with comments | « components/cronet/ios/Cronet.mm ('k') | components/cronet/ios/test/cronet_http_test.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698