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

Side by Side Diff: components/metrics/metrics_service.cc

Issue 396753005: Keep all references to kInstallDate inside components/metrics/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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/chrome_browser_main.cc ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 is 10 // A MetricsService instance is typically created at application startup. It is
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 #include "base/metrics/histogram_samples.h" 172 #include "base/metrics/histogram_samples.h"
173 #include "base/metrics/sparse_histogram.h" 173 #include "base/metrics/sparse_histogram.h"
174 #include "base/metrics/statistics_recorder.h" 174 #include "base/metrics/statistics_recorder.h"
175 #include "base/prefs/pref_registry_simple.h" 175 #include "base/prefs/pref_registry_simple.h"
176 #include "base/prefs/pref_service.h" 176 #include "base/prefs/pref_service.h"
177 #include "base/strings/string_number_conversions.h" 177 #include "base/strings/string_number_conversions.h"
178 #include "base/strings/utf_string_conversions.h" 178 #include "base/strings/utf_string_conversions.h"
179 #include "base/threading/platform_thread.h" 179 #include "base/threading/platform_thread.h"
180 #include "base/threading/thread.h" 180 #include "base/threading/thread.h"
181 #include "base/threading/thread_restrictions.h" 181 #include "base/threading/thread_restrictions.h"
182 #include "base/time/time.h"
182 #include "base/tracked_objects.h" 183 #include "base/tracked_objects.h"
183 #include "base/values.h" 184 #include "base/values.h"
184 #include "components/metrics/metrics_log.h" 185 #include "components/metrics/metrics_log.h"
185 #include "components/metrics/metrics_log_manager.h" 186 #include "components/metrics/metrics_log_manager.h"
186 #include "components/metrics/metrics_log_uploader.h" 187 #include "components/metrics/metrics_log_uploader.h"
187 #include "components/metrics/metrics_pref_names.h" 188 #include "components/metrics/metrics_pref_names.h"
188 #include "components/metrics/metrics_reporting_scheduler.h" 189 #include "components/metrics/metrics_reporting_scheduler.h"
189 #include "components/metrics/metrics_service_client.h" 190 #include "components/metrics/metrics_service_client.h"
190 #include "components/metrics/metrics_state_manager.h" 191 #include "components/metrics/metrics_state_manager.h"
191 #include "components/variations/entropy_provider.h" 192 #include "components/variations/entropy_provider.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 has_initial_stability_log_(false), 325 has_initial_stability_log_(false),
325 log_upload_in_progress_(false), 326 log_upload_in_progress_(false),
326 idle_since_last_transmission_(false), 327 idle_since_last_transmission_(false),
327 session_id_(-1), 328 session_id_(-1),
328 self_ptr_factory_(this), 329 self_ptr_factory_(this),
329 state_saver_factory_(this) { 330 state_saver_factory_(this) {
330 DCHECK(IsSingleThreaded()); 331 DCHECK(IsSingleThreaded());
331 DCHECK(state_manager_); 332 DCHECK(state_manager_);
332 DCHECK(client_); 333 DCHECK(client_);
333 DCHECK(local_state_); 334 DCHECK(local_state_);
335
336 // Set the install date if this is our first run.
337 int64 install_date = local_state_->GetInt64(metrics::prefs::kInstallDate);
338 if (install_date == 0) {
339 local_state_->SetInt64(metrics::prefs::kInstallDate,
340 base::Time::Now().ToTimeT());
341 }
334 } 342 }
335 343
336 MetricsService::~MetricsService() { 344 MetricsService::~MetricsService() {
337 DisableRecording(); 345 DisableRecording();
338 } 346 }
339 347
340 void MetricsService::InitializeMetricsRecordingState() { 348 void MetricsService::InitializeMetricsRecordingState() {
341 InitializeMetricsState(); 349 InitializeMetricsState();
342 350
343 base::Closure callback = base::Bind(&MetricsService::StartScheduledUpload, 351 base::Closure callback = base::Bind(&MetricsService::StartScheduledUpload,
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 RecordCurrentState(local_state_); 1213 RecordCurrentState(local_state_);
1206 } 1214 }
1207 1215
1208 void MetricsService::RecordCurrentState(PrefService* pref) { 1216 void MetricsService::RecordCurrentState(PrefService* pref) {
1209 pref->SetInt64(metrics::prefs::kStabilityLastTimestampSec, 1217 pref->SetInt64(metrics::prefs::kStabilityLastTimestampSec,
1210 Time::Now().ToTimeT()); 1218 Time::Now().ToTimeT());
1211 1219
1212 for (size_t i = 0; i < metrics_providers_.size(); ++i) 1220 for (size_t i = 0; i < metrics_providers_.size(); ++i)
1213 metrics_providers_[i]->RecordCurrentState(); 1221 metrics_providers_[i]->RecordCurrentState();
1214 } 1222 }
OLDNEW
« no previous file with comments | « chrome/browser/chrome_browser_main.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698