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

Side by Side Diff: chrome/browser/metrics/metrics_service.cc

Issue 10117034: Don't cache the IO thread in the MetricsService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Linux compile (IWYU) Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/metrics/metrics_service.h ('k') | 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 //------------------------------------------------------------------------------ 5 //------------------------------------------------------------------------------
6 // Description of the life cycle of a instance of MetricsService. 6 // Description of the life cycle of a instance of MetricsService.
7 // 7 //
8 // OVERVIEW 8 // OVERVIEW
9 // 9 //
10 // A MetricsService instance is typically created at application startup. It 10 // A MetricsService instance is typically created at application startup. It
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 #include "base/metrics/histogram.h" 151 #include "base/metrics/histogram.h"
152 #include "base/string_number_conversions.h" 152 #include "base/string_number_conversions.h"
153 #include "base/threading/platform_thread.h" 153 #include "base/threading/platform_thread.h"
154 #include "base/threading/thread.h" 154 #include "base/threading/thread.h"
155 #include "base/utf_string_conversions.h" 155 #include "base/utf_string_conversions.h"
156 #include "base/values.h" 156 #include "base/values.h"
157 #include "chrome/browser/bookmarks/bookmark_model.h" 157 #include "chrome/browser/bookmarks/bookmark_model.h"
158 #include "chrome/browser/browser_process.h" 158 #include "chrome/browser/browser_process.h"
159 #include "chrome/browser/extensions/extension_service.h" 159 #include "chrome/browser/extensions/extension_service.h"
160 #include "chrome/browser/extensions/process_map.h" 160 #include "chrome/browser/extensions/process_map.h"
161 #include "chrome/browser/io_thread.h"
161 #include "chrome/browser/memory_details.h" 162 #include "chrome/browser/memory_details.h"
162 #include "chrome/browser/metrics/histogram_synchronizer.h" 163 #include "chrome/browser/metrics/histogram_synchronizer.h"
163 #include "chrome/browser/metrics/metrics_log.h" 164 #include "chrome/browser/metrics/metrics_log.h"
164 #include "chrome/browser/metrics/metrics_log_serializer.h" 165 #include "chrome/browser/metrics/metrics_log_serializer.h"
165 #include "chrome/browser/metrics/metrics_reporting_scheduler.h" 166 #include "chrome/browser/metrics/metrics_reporting_scheduler.h"
166 #include "chrome/browser/net/http_pipelining_compatibility_client.h" 167 #include "chrome/browser/net/http_pipelining_compatibility_client.h"
167 #include "chrome/browser/net/network_stats.h" 168 #include "chrome/browser/net/network_stats.h"
168 #include "chrome/browser/prefs/pref_service.h" 169 #include "chrome/browser/prefs/pref_service.h"
169 #include "chrome/browser/prefs/scoped_user_pref_update.h" 170 #include "chrome/browser/prefs/scoped_user_pref_update.h"
170 #include "chrome/browser/profiles/profile.h" 171 #include "chrome/browser/profiles/profile.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 local_state->ClearPref(prefs::kMetricsInitialLogsXml); 386 local_state->ClearPref(prefs::kMetricsInitialLogsXml);
386 local_state->ClearPref(prefs::kMetricsOngoingLogsXml); 387 local_state->ClearPref(prefs::kMetricsOngoingLogsXml);
387 local_state->ClearPref(prefs::kMetricsInitialLogsProto); 388 local_state->ClearPref(prefs::kMetricsInitialLogsProto);
388 local_state->ClearPref(prefs::kMetricsOngoingLogsProto); 389 local_state->ClearPref(prefs::kMetricsOngoingLogsProto);
389 } 390 }
390 391
391 MetricsService::MetricsService() 392 MetricsService::MetricsService()
392 : recording_active_(false), 393 : recording_active_(false),
393 reporting_active_(false), 394 reporting_active_(false),
394 state_(INITIALIZED), 395 state_(INITIALIZED),
395 io_thread_(NULL),
396 idle_since_last_transmission_(false), 396 idle_since_last_transmission_(false),
397 next_window_id_(0), 397 next_window_id_(0),
398 ALLOW_THIS_IN_INITIALIZER_LIST(self_ptr_factory_(this)), 398 ALLOW_THIS_IN_INITIALIZER_LIST(self_ptr_factory_(this)),
399 ALLOW_THIS_IN_INITIALIZER_LIST(state_saver_factory_(this)), 399 ALLOW_THIS_IN_INITIALIZER_LIST(state_saver_factory_(this)),
400 waiting_for_asynchronus_reporting_step_(false) { 400 waiting_for_asynchronus_reporting_step_(false) {
401 DCHECK(IsSingleThreaded()); 401 DCHECK(IsSingleThreaded());
402 InitializeMetricsState(); 402 InitializeMetricsState();
403 403
404 base::Closure callback = base::Bind(&MetricsService::StartScheduledUpload, 404 base::Closure callback = base::Bind(&MetricsService::StartScheduledUpload,
405 self_ptr_factory_.GetWeakPtr()); 405 self_ptr_factory_.GetWeakPtr());
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 PluginService::GetInstance()->GetPlugins( 780 PluginService::GetInstance()->GetPlugins(
781 base::Bind(&MetricsService::OnInitTaskGotPluginInfo, 781 base::Bind(&MetricsService::OnInitTaskGotPluginInfo,
782 self_ptr_factory_.GetWeakPtr())); 782 self_ptr_factory_.GetWeakPtr()));
783 } 783 }
784 784
785 void MetricsService::OnInitTaskGotPluginInfo( 785 void MetricsService::OnInitTaskGotPluginInfo(
786 const std::vector<webkit::WebPluginInfo>& plugins) { 786 const std::vector<webkit::WebPluginInfo>& plugins) {
787 DCHECK_EQ(state_, INIT_TASK_SCHEDULED); 787 DCHECK_EQ(state_, INIT_TASK_SCHEDULED);
788 plugins_ = plugins; 788 plugins_ = plugins;
789 789
790 io_thread_ = g_browser_process->io_thread();
791 if (state_ == INIT_TASK_SCHEDULED) 790 if (state_ == INIT_TASK_SCHEDULED)
792 state_ = INIT_TASK_DONE; 791 state_ = INIT_TASK_DONE;
793 } 792 }
794 793
795 std::string MetricsService::GenerateClientID() { 794 std::string MetricsService::GenerateClientID() {
796 return guid::GenerateGUID(); 795 return guid::GenerateGUID();
797 } 796 }
798 797
799 //------------------------------------------------------------------------------ 798 //------------------------------------------------------------------------------
800 // State save methods 799 // State save methods
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 } 1260 }
1262 1261
1263 // Error 400 indicates a problem with the log, not with the server, so 1262 // Error 400 indicates a problem with the log, not with the server, so
1264 // don't consider that a sign that the server is in trouble. 1263 // don't consider that a sign that the server is in trouble.
1265 bool server_is_healthy = upload_succeeded || response_code_ == 400; 1264 bool server_is_healthy = upload_succeeded || response_code_ == 400;
1266 1265
1267 scheduler_->UploadFinished(server_is_healthy, 1266 scheduler_->UploadFinished(server_is_healthy,
1268 log_manager_.has_unsent_logs()); 1267 log_manager_.has_unsent_logs());
1269 1268
1270 // Collect network stats if UMA upload succeeded. 1269 // Collect network stats if UMA upload succeeded.
1271 if (server_is_healthy && io_thread_) { 1270 IOThread* io_thread = g_browser_process->io_thread();
1272 chrome_browser_net::CollectNetworkStats(network_stats_server_, io_thread_); 1271 if (server_is_healthy && io_thread) {
1272 chrome_browser_net::CollectNetworkStats(network_stats_server_, io_thread);
1273 chrome_browser_net::CollectPipeliningCapabilityStatsOnUIThread( 1273 chrome_browser_net::CollectPipeliningCapabilityStatsOnUIThread(
1274 http_pipelining_test_server_, io_thread_); 1274 http_pipelining_test_server_, io_thread);
1275 } 1275 }
1276 1276
1277 // Reset the cached response data. 1277 // Reset the cached response data.
1278 response_code_ = kNoResponseCode; 1278 response_code_ = kNoResponseCode;
1279 response_data_ = std::string(); 1279 response_data_ = std::string();
1280 response_status_ = std::string(); 1280 response_status_ = std::string();
1281 } 1281 }
1282 1282
1283 void MetricsService::LogBadResponseCode() { 1283 void MetricsService::LogBadResponseCode() {
1284 VLOG(1) << "Verify your metrics logs are formatted correctly. Verify server " 1284 VLOG(1) << "Verify your metrics logs are formatted correctly. Verify server "
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 if (local_state) { 1670 if (local_state) {
1671 const PrefService::Preference* uma_pref = 1671 const PrefService::Preference* uma_pref =
1672 local_state->FindPreference(prefs::kMetricsReportingEnabled); 1672 local_state->FindPreference(prefs::kMetricsReportingEnabled);
1673 if (uma_pref) { 1673 if (uma_pref) {
1674 bool success = uma_pref->GetValue()->GetAsBoolean(&result); 1674 bool success = uma_pref->GetValue()->GetAsBoolean(&result);
1675 DCHECK(success); 1675 DCHECK(success);
1676 } 1676 }
1677 } 1677 }
1678 return result; 1678 return result;
1679 } 1679 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698