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

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

Issue 1819093002: Remove base_i18n dependency from //components/metrics:metrics target (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | « components/metrics/BUILD.gn ('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 #include "components/metrics/daily_event.h" 5 #include "components/metrics/daily_event.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/i18n/time_formatting.h"
10 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
11 #include "components/prefs/pref_registry_simple.h" 10 #include "components/prefs/pref_registry_simple.h"
12 #include "components/prefs/pref_service.h" 11 #include "components/prefs/pref_service.h"
13 12
14 namespace metrics { 13 namespace metrics {
15 14
16 namespace { 15 namespace {
17 16
18 enum IntervalType { 17 enum IntervalType {
19 FIRST_RUN, 18 FIRST_RUN,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 DCHECK(last_fired_.is_null()); 61 DCHECK(last_fired_.is_null());
63 observers_.push_back(std::move(observer)); 62 observers_.push_back(std::move(observer));
64 } 63 }
65 64
66 void DailyEvent::CheckInterval() { 65 void DailyEvent::CheckInterval() {
67 base::Time now = base::Time::Now(); 66 base::Time now = base::Time::Now();
68 if (last_fired_.is_null()) { 67 if (last_fired_.is_null()) {
69 // The first time we call CheckInterval, we read the time stored in prefs. 68 // The first time we call CheckInterval, we read the time stored in prefs.
70 last_fired_ = base::Time::FromInternalValue( 69 last_fired_ = base::Time::FromInternalValue(
71 pref_service_->GetInt64(pref_name_)); 70 pref_service_->GetInt64(pref_name_));
72 DVLOG(1) << "DailyEvent time loaded: " 71 DVLOG(1) << "DailyEvent time loaded: " << last_fired_;
xunjieli 2016/03/21 21:02:13 base::Time converts to a UTC timestamp automatical
73 << base::TimeFormatShortDateAndTime(last_fired_);
74 if (last_fired_.is_null()) { 72 if (last_fired_.is_null()) {
75 DVLOG(1) << "DailyEvent first run."; 73 DVLOG(1) << "DailyEvent first run.";
76 RecordIntervalTypeHistogram(histogram_name_, FIRST_RUN); 74 RecordIntervalTypeHistogram(histogram_name_, FIRST_RUN);
77 OnInterval(now); 75 OnInterval(now);
78 return; 76 return;
79 } 77 }
80 } 78 }
81 int days_elapsed = (now - last_fired_).InDays(); 79 int days_elapsed = (now - last_fired_).InDays();
82 if (days_elapsed >= 1) { 80 if (days_elapsed >= 1) {
83 DVLOG(1) << "DailyEvent day elapsed."; 81 DVLOG(1) << "DailyEvent day elapsed.";
(...skipping 15 matching lines...) Expand all
99 97
100 // Notify all observers 98 // Notify all observers
101 for (ScopedVector<DailyEvent::Observer>::iterator it = observers_.begin(); 99 for (ScopedVector<DailyEvent::Observer>::iterator it = observers_.begin();
102 it != observers_.end(); 100 it != observers_.end();
103 ++it) { 101 ++it) {
104 (*it)->OnDailyEvent(); 102 (*it)->OnDailyEvent();
105 } 103 }
106 } 104 }
107 105
108 } // namespace metrics 106 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698