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

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

Issue 2836063005: [cronet] Add mechanism for restarting CronetEnvironment (Closed)
Patch Set: per #5 Created 3 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 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
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();
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
mef 2017/04/26 22:19:41 I think there is also a problem with having object
lilyhoughton 2017/04/27 13:53:39 Not really sure what to do about this, since afaic
mef 2017/04/27 14:58:20 Yeah, this needs more thought and test coverage, s
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698