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

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

Issue 10544048: Fix typo: asynchronus -> asynchronous (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 421
422 MetricsService::MetricsService() 422 MetricsService::MetricsService()
423 : recording_active_(false), 423 : recording_active_(false),
424 reporting_active_(false), 424 reporting_active_(false),
425 state_(INITIALIZED), 425 state_(INITIALIZED),
426 low_entropy_source_(0), 426 low_entropy_source_(0),
427 idle_since_last_transmission_(false), 427 idle_since_last_transmission_(false),
428 next_window_id_(0), 428 next_window_id_(0),
429 ALLOW_THIS_IN_INITIALIZER_LIST(self_ptr_factory_(this)), 429 ALLOW_THIS_IN_INITIALIZER_LIST(self_ptr_factory_(this)),
430 ALLOW_THIS_IN_INITIALIZER_LIST(state_saver_factory_(this)), 430 ALLOW_THIS_IN_INITIALIZER_LIST(state_saver_factory_(this)),
431 waiting_for_asynchronus_reporting_step_(false) { 431 waiting_for_asynchronous_reporting_step_(false) {
432 DCHECK(IsSingleThreaded()); 432 DCHECK(IsSingleThreaded());
433 InitializeMetricsState(); 433 InitializeMetricsState();
434 434
435 base::Closure callback = base::Bind(&MetricsService::StartScheduledUpload, 435 base::Closure callback = base::Bind(&MetricsService::StartScheduledUpload,
436 self_ptr_factory_.GetWeakPtr()); 436 self_ptr_factory_.GetWeakPtr());
437 scheduler_.reset(new MetricsReportingScheduler(callback)); 437 scheduler_.reset(new MetricsReportingScheduler(callback));
438 log_manager_.set_log_serializer(new MetricsLogSerializer()); 438 log_manager_.set_log_serializer(new MetricsLogSerializer());
439 log_manager_.set_max_ongoing_log_store_size(kUploadLogAvoidRetransmitSize); 439 log_manager_.set_max_ongoing_log_store_size(kUploadLogAvoidRetransmitSize);
440 } 440 }
441 441
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 1044
1045 StartFinalLogInfoCollection(); 1045 StartFinalLogInfoCollection();
1046 } 1046 }
1047 1047
1048 void MetricsService::StartFinalLogInfoCollection() { 1048 void MetricsService::StartFinalLogInfoCollection() {
1049 // Begin the multi-step process of collecting memory usage histograms: 1049 // Begin the multi-step process of collecting memory usage histograms:
1050 // First spawn a task to collect the memory details; when that task is 1050 // First spawn a task to collect the memory details; when that task is
1051 // finished, it will call OnMemoryDetailCollectionDone. That will in turn 1051 // finished, it will call OnMemoryDetailCollectionDone. That will in turn
1052 // call HistogramSynchronization to collect histograms from all renderers and 1052 // call HistogramSynchronization to collect histograms from all renderers and
1053 // then call OnHistogramSynchronizationDone to continue processing. 1053 // then call OnHistogramSynchronizationDone to continue processing.
1054 DCHECK(!waiting_for_asynchronus_reporting_step_); 1054 DCHECK(!waiting_for_asynchronous_reporting_step_);
1055 waiting_for_asynchronus_reporting_step_ = true; 1055 waiting_for_asynchronous_reporting_step_ = true;
1056 1056
1057 base::Closure callback = 1057 base::Closure callback =
1058 base::Bind(&MetricsService::OnMemoryDetailCollectionDone, 1058 base::Bind(&MetricsService::OnMemoryDetailCollectionDone,
1059 self_ptr_factory_.GetWeakPtr()); 1059 self_ptr_factory_.GetWeakPtr());
1060 1060
1061 scoped_refptr<MetricsMemoryDetails> details( 1061 scoped_refptr<MetricsMemoryDetails> details(
1062 new MetricsMemoryDetails(callback)); 1062 new MetricsMemoryDetails(callback));
1063 details->StartFetch(MemoryDetails::UPDATE_USER_METRICS); 1063 details->StartFetch(MemoryDetails::UPDATE_USER_METRICS);
1064 1064
1065 // Collect WebCore cache information to put into a histogram. 1065 // Collect WebCore cache information to put into a histogram.
1066 for (content::RenderProcessHost::iterator i( 1066 for (content::RenderProcessHost::iterator i(
1067 content::RenderProcessHost::AllHostsIterator()); 1067 content::RenderProcessHost::AllHostsIterator());
1068 !i.IsAtEnd(); i.Advance()) 1068 !i.IsAtEnd(); i.Advance())
1069 i.GetCurrentValue()->Send(new ChromeViewMsg_GetCacheResourceStats()); 1069 i.GetCurrentValue()->Send(new ChromeViewMsg_GetCacheResourceStats());
1070 } 1070 }
1071 1071
1072 void MetricsService::OnMemoryDetailCollectionDone() { 1072 void MetricsService::OnMemoryDetailCollectionDone() {
1073 DCHECK(IsSingleThreaded()); 1073 DCHECK(IsSingleThreaded());
1074 // This function should only be called as the callback from an ansynchronous 1074 // This function should only be called as the callback from an ansynchronous
1075 // step. 1075 // step.
1076 DCHECK(waiting_for_asynchronus_reporting_step_); 1076 DCHECK(waiting_for_asynchronous_reporting_step_);
1077 1077
1078 // Create a callback_task for OnHistogramSynchronizationDone. 1078 // Create a callback_task for OnHistogramSynchronizationDone.
1079 base::Closure callback = base::Bind( 1079 base::Closure callback = base::Bind(
1080 &MetricsService::OnHistogramSynchronizationDone, 1080 &MetricsService::OnHistogramSynchronizationDone,
1081 self_ptr_factory_.GetWeakPtr()); 1081 self_ptr_factory_.GetWeakPtr());
1082 1082
1083 base::StatisticsRecorder::CollectHistogramStats("Browser"); 1083 base::StatisticsRecorder::CollectHistogramStats("Browser");
1084 1084
1085 // Set up the callback to task to call after we receive histograms from all 1085 // Set up the callback to task to call after we receive histograms from all
1086 // renderer processes. Wait time specifies how long to wait before absolutely 1086 // renderer processes. Wait time specifies how long to wait before absolutely
1087 // calling us back on the task. 1087 // calling us back on the task.
1088 HistogramSynchronizer::FetchRendererHistogramsAsynchronously( 1088 HistogramSynchronizer::FetchRendererHistogramsAsynchronously(
1089 MessageLoop::current(), callback, 1089 MessageLoop::current(), callback,
1090 base::TimeDelta::FromMilliseconds(kMaxHistogramGatheringWaitDuration)); 1090 base::TimeDelta::FromMilliseconds(kMaxHistogramGatheringWaitDuration));
1091 } 1091 }
1092 1092
1093 void MetricsService::OnHistogramSynchronizationDone() { 1093 void MetricsService::OnHistogramSynchronizationDone() {
1094 DCHECK(IsSingleThreaded()); 1094 DCHECK(IsSingleThreaded());
1095 // This function should only be called as the callback from an ansynchronous 1095 // This function should only be called as the callback from an ansynchronous
1096 // step. 1096 // step.
1097 DCHECK(waiting_for_asynchronus_reporting_step_); 1097 DCHECK(waiting_for_asynchronous_reporting_step_);
1098 1098
1099 waiting_for_asynchronus_reporting_step_ = false; 1099 waiting_for_asynchronous_reporting_step_ = false;
1100 OnFinalLogInfoCollectionDone(); 1100 OnFinalLogInfoCollectionDone();
1101 } 1101 }
1102 1102
1103 void MetricsService::OnFinalLogInfoCollectionDone() { 1103 void MetricsService::OnFinalLogInfoCollectionDone() {
1104 // If somehow there is a fetch in progress, we return and hope things work 1104 // If somehow there is a fetch in progress, we return and hope things work
1105 // out. The scheduler isn't informed since if this happens, the scheduler 1105 // out. The scheduler isn't informed since if this happens, the scheduler
1106 // will get a response from the upload. 1106 // will get a response from the upload.
1107 DCHECK(!current_fetch_xml_.get()); 1107 DCHECK(!current_fetch_xml_.get());
1108 DCHECK(!current_fetch_proto_.get()); 1108 DCHECK(!current_fetch_proto_.get());
1109 if (current_fetch_xml_.get() || current_fetch_proto_.get()) 1109 if (current_fetch_xml_.get() || current_fetch_proto_.get())
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 // compressed that, so that we can signal that we're losing logs. 1216 // compressed that, so that we can signal that we're losing logs.
1217 return; 1217 return;
1218 } 1218 }
1219 // Currently, the staged log for the protobuf version of the data is discarded 1219 // Currently, the staged log for the protobuf version of the data is discarded
1220 // after we create the URL request, so that there is no chance for 1220 // after we create the URL request, so that there is no chance for
1221 // re-transmission in case the corresponding XML request fails. We will 1221 // re-transmission in case the corresponding XML request fails. We will
1222 // handle protobuf failures more carefully once that becomes the main 1222 // handle protobuf failures more carefully once that becomes the main
1223 // pipeline, i.e. once we switch away from the XML pipeline. 1223 // pipeline, i.e. once we switch away from the XML pipeline.
1224 DCHECK(current_fetch_proto_.get() || !log_manager_.has_staged_log_proto()); 1224 DCHECK(current_fetch_proto_.get() || !log_manager_.has_staged_log_proto());
1225 1225
1226 DCHECK(!waiting_for_asynchronus_reporting_step_); 1226 DCHECK(!waiting_for_asynchronous_reporting_step_);
1227 1227
1228 waiting_for_asynchronus_reporting_step_ = true; 1228 waiting_for_asynchronous_reporting_step_ = true;
1229 current_fetch_xml_->Start(); 1229 current_fetch_xml_->Start();
1230 if (current_fetch_proto_.get()) 1230 if (current_fetch_proto_.get())
1231 current_fetch_proto_->Start(); 1231 current_fetch_proto_->Start();
1232 1232
1233 HandleIdleSinceLastTransmission(true); 1233 HandleIdleSinceLastTransmission(true);
1234 } 1234 }
1235 1235
1236 void MetricsService::PrepareFetchWithStagedLog() { 1236 void MetricsService::PrepareFetchWithStagedLog() {
1237 DCHECK(!log_manager_.staged_log_text().empty()); 1237 DCHECK(!log_manager_.staged_log_text().empty());
1238 1238
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 // arrives. 1305 // arrives.
1306 // 1306 //
1307 // Note that if the XML upload succeeds but the protobuf upload fails, we will 1307 // Note that if the XML upload succeeds but the protobuf upload fails, we will
1308 // not retry the protobuf upload. If the XML upload fails while the protobuf 1308 // not retry the protobuf upload. If the XML upload fails while the protobuf
1309 // upload succeeds, we will still avoid re-uploading the protobuf data because 1309 // upload succeeds, we will still avoid re-uploading the protobuf data because
1310 // we "zap" the data after the first upload attempt. This means that we might 1310 // we "zap" the data after the first upload attempt. This means that we might
1311 // lose protobuf uploads when XML ones succeed; but we will never duplicate any 1311 // lose protobuf uploads when XML ones succeed; but we will never duplicate any
1312 // protobuf uploads. Protobuf failures should be rare enough to where this 1312 // protobuf uploads. Protobuf failures should be rare enough to where this
1313 // should be ok while we have the two pipelines running in parallel. 1313 // should be ok while we have the two pipelines running in parallel.
1314 void MetricsService::OnURLFetchComplete(const net::URLFetcher* source) { 1314 void MetricsService::OnURLFetchComplete(const net::URLFetcher* source) {
1315 DCHECK(waiting_for_asynchronus_reporting_step_); 1315 DCHECK(waiting_for_asynchronous_reporting_step_);
1316 1316
1317 // We're not allowed to re-use the existing |URLFetcher|s, so free them here. 1317 // We're not allowed to re-use the existing |URLFetcher|s, so free them here.
1318 // Note however that |source| is aliased to one of these, so we should be 1318 // Note however that |source| is aliased to one of these, so we should be
1319 // careful not to delete it too early. 1319 // careful not to delete it too early.
1320 scoped_ptr<net::URLFetcher> s; 1320 scoped_ptr<net::URLFetcher> s;
1321 if (source == current_fetch_xml_.get()) { 1321 if (source == current_fetch_xml_.get()) {
1322 s.reset(current_fetch_xml_.release()); 1322 s.reset(current_fetch_xml_.release());
1323 1323
1324 // Cache the XML responses, in case we still need to wait for the protobuf 1324 // Cache the XML responses, in case we still need to wait for the protobuf
1325 // response. 1325 // response.
(...skipping 18 matching lines...) Expand all
1344 } 1344 }
1345 1345
1346 // If we're still waiting for one of the responses, keep waiting... 1346 // If we're still waiting for one of the responses, keep waiting...
1347 if (current_fetch_xml_.get() || current_fetch_proto_.get()) 1347 if (current_fetch_xml_.get() || current_fetch_proto_.get())
1348 return; 1348 return;
1349 1349
1350 // We should only be able to reach here once we've received responses to both 1350 // We should only be able to reach here once we've received responses to both
1351 // the XML and the protobuf requests. We should always have the response code 1351 // the XML and the protobuf requests. We should always have the response code
1352 // available. 1352 // available.
1353 DCHECK_NE(response_code_, kNoResponseCode); 1353 DCHECK_NE(response_code_, kNoResponseCode);
1354 waiting_for_asynchronus_reporting_step_ = false; 1354 waiting_for_asynchronous_reporting_step_ = false;
1355 1355
1356 // If the upload was provisionally stored, drop it now that the upload is 1356 // If the upload was provisionally stored, drop it now that the upload is
1357 // known to have gone through. 1357 // known to have gone through.
1358 log_manager_.DiscardLastProvisionalStore(); 1358 log_manager_.DiscardLastProvisionalStore();
1359 1359
1360 // Confirm send so that we can move on. 1360 // Confirm send so that we can move on.
1361 VLOG(1) << "Metrics response code: " << response_code_ 1361 VLOG(1) << "Metrics response code: " << response_code_
1362 << " status=" << response_status_; 1362 << " status=" << response_status_;
1363 1363
1364 bool upload_succeeded = response_code_ == 200; 1364 bool upload_succeeded = response_code_ == 200;
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1821 if (local_state) { 1821 if (local_state) {
1822 const PrefService::Preference* uma_pref = 1822 const PrefService::Preference* uma_pref =
1823 local_state->FindPreference(prefs::kMetricsReportingEnabled); 1823 local_state->FindPreference(prefs::kMetricsReportingEnabled);
1824 if (uma_pref) { 1824 if (uma_pref) {
1825 bool success = uma_pref->GetValue()->GetAsBoolean(&result); 1825 bool success = uma_pref->GetValue()->GetAsBoolean(&result);
1826 DCHECK(success); 1826 DCHECK(success);
1827 } 1827 }
1828 } 1828 }
1829 return result; 1829 return result;
1830 } 1830 }
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