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

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

Issue 2801603008: [Cronet iOS] Add base::StatisticsRecorder::IsActive() check (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 if (!g_at_exit_) 118 if (!g_at_exit_)
119 g_at_exit_ = new base::AtExitManager; 119 g_at_exit_ = new base::AtExitManager;
120 120
121 base::TaskScheduler::CreateAndSetSimpleTaskScheduler("CronetIos"); 121 base::TaskScheduler::CreateAndSetSimpleTaskScheduler("CronetIos");
122 122
123 url::Initialize(); 123 url::Initialize();
124 base::CommandLine::Init(0, nullptr); 124 base::CommandLine::Init(0, nullptr);
125 125
126 // Without doing this, StatisticsRecorder::FactoryGet() leaks one histogram 126 // Without doing this, StatisticsRecorder::FactoryGet() leaks one histogram
127 // per call after the first for a given name. 127 // per call after the first for a given name.
128 base::StatisticsRecorder::Initialize(); 128 base::StatisticsRecorder::Initialize();
xunjieli 2017/04/06 21:37:29 We are calling base::StatisticsRecorder::Initializ
mef 2017/04/06 22:08:11 I wonder whether it should happen after message lo
129 129
130 // Create a message loop on the UI thread. 130 // Create a message loop on the UI thread.
131 DCHECK(!base::MessageLoop::current()); 131 DCHECK(!base::MessageLoop::current());
132 DCHECK(!g_main_message_loop); 132 DCHECK(!g_main_message_loop);
133 g_main_message_loop = new base::MessageLoopForUI(); 133 g_main_message_loop = new base::MessageLoopForUI();
134 base::MessageLoopForUI::current()->Attach(); 134 base::MessageLoopForUI::current()->Attach();
135 // The network change notifier must be initialized so that registered 135 // The network change notifier must be initialized so that registered
136 // delegates will receive callbacks. 136 // delegates will receive callbacks.
137 DCHECK(!g_network_change_notifier); 137 DCHECK(!g_network_change_notifier);
138 g_network_change_notifier = net::NetworkChangeNotifier::Create(); 138 g_network_change_notifier = net::NetworkChangeNotifier::Create();
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 const net::HttpUserAgentSettings* user_agent_settings = 342 const net::HttpUserAgentSettings* user_agent_settings =
343 main_context_->http_user_agent_settings(); 343 main_context_->http_user_agent_settings();
344 if (!user_agent_settings) { 344 if (!user_agent_settings) {
345 return nullptr; 345 return nullptr;
346 } 346 }
347 347
348 return user_agent_settings->GetUserAgent(); 348 return user_agent_settings->GetUserAgent();
349 } 349 }
350 350
351 std::vector<uint8_t> CronetEnvironment::GetHistogramDeltas() { 351 std::vector<uint8_t> CronetEnvironment::GetHistogramDeltas() {
352 base::StatisticsRecorder::Initialize(); 352 DCHECK(base::StatisticsRecorder::IsActive());
mef 2017/04/06 22:08:11 What would happen if they call this on background
xunjieli 2017/04/06 23:58:01 Is there an entry point (if not CronetEnvironment
353 std::vector<uint8_t> data; 353 std::vector<uint8_t> data;
354 if (!HistogramManager::GetInstance()->GetDeltas(&data)) 354 if (!HistogramManager::GetInstance()->GetDeltas(&data))
355 return std::vector<uint8_t>(); 355 return std::vector<uint8_t>();
356 return data; 356 return data;
357 } 357 }
358 358
359 void CronetEnvironment::SetHostResolverRules(const std::string& rules) { 359 void CronetEnvironment::SetHostResolverRules(const std::string& rules) {
360 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, 360 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
361 base::WaitableEvent::InitialState::NOT_SIGNALED); 361 base::WaitableEvent::InitialState::NOT_SIGNALED);
362 PostToNetworkThread( 362 PostToNetworkThread(
(...skipping 11 matching lines...) Expand all
374 event->Signal(); 374 event->Signal();
375 } 375 }
376 376
377 std::string CronetEnvironment::getDefaultQuicUserAgentId() const { 377 std::string CronetEnvironment::getDefaultQuicUserAgentId() const {
378 return base::SysNSStringToUTF8([[NSBundle mainBundle] 378 return base::SysNSStringToUTF8([[NSBundle mainBundle]
379 objectForInfoDictionaryKey:@"CFBundleDisplayName"]) + 379 objectForInfoDictionaryKey:@"CFBundleDisplayName"]) +
380 " Cronet/" + CRONET_VERSION; 380 " Cronet/" + CRONET_VERSION;
381 } 381 }
382 382
383 } // namespace cronet 383 } // namespace cronet
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698