Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/metrics_log.h" | 5 #include "components/metrics/metrics_log.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/base64.h" | 11 #include "base/base64.h" |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/build_time.h" | |
| 13 #include "base/cpu.h" | 14 #include "base/cpu.h" |
| 14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 16 #include "base/metrics/histogram_samples.h" | 17 #include "base/metrics/histogram_samples.h" |
| 17 #include "base/prefs/pref_registry_simple.h" | 18 #include "base/prefs/pref_registry_simple.h" |
| 18 #include "base/prefs/pref_service.h" | 19 #include "base/prefs/pref_service.h" |
| 19 #include "base/sha1.h" | 20 #include "base/sha1.h" |
| 20 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
| 21 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 // being hashed to a given MD5 value by just running the version of Chromium | 150 // being hashed to a given MD5 value by just running the version of Chromium |
| 150 // in question with --enable-logging. | 151 // in question with --enable-logging. |
| 151 DVLOG(1) << "Metrics: Hash numeric [" << value << "]=[" << hash << "]"; | 152 DVLOG(1) << "Metrics: Hash numeric [" << value << "]=[" << hash << "]"; |
| 152 | 153 |
| 153 return hash; | 154 return hash; |
| 154 } | 155 } |
| 155 | 156 |
| 156 // static | 157 // static |
| 157 int64 MetricsLog::GetBuildTime() { | 158 int64 MetricsLog::GetBuildTime() { |
| 158 static int64 integral_build_time = 0; | 159 static int64 integral_build_time = 0; |
| 159 if (!integral_build_time) { | 160 if (!integral_build_time) |
| 160 base::Time time; | 161 integral_build_time = static_cast<int64>(base::GetBuildTime().ToTimeT()); |
| 161 static const char kDateTime[] = __DATE__ " " __TIME__ " GMT"; | |
|
M-A Ruel
2014/10/31 14:09:14
Note that the PST / GMT difference was pure hack;
| |
| 162 bool result = base::Time::FromString(kDateTime, &time); | |
| 163 DCHECK(result); | |
| 164 integral_build_time = static_cast<int64>(time.ToTimeT()); | |
| 165 } | |
| 166 return integral_build_time; | 162 return integral_build_time; |
| 167 } | 163 } |
| 168 | 164 |
| 169 // static | 165 // static |
| 170 int64 MetricsLog::GetCurrentTime() { | 166 int64 MetricsLog::GetCurrentTime() { |
| 171 return (base::TimeTicks::Now() - base::TimeTicks()).InSeconds(); | 167 return (base::TimeTicks::Now() - base::TimeTicks()).InSeconds(); |
| 172 } | 168 } |
| 173 | 169 |
| 174 void MetricsLog::RecordUserAction(const std::string& key) { | 170 void MetricsLog::RecordUserAction(const std::string& key) { |
| 175 DCHECK(!closed_); | 171 DCHECK(!closed_); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 430 DCHECK(!closed_); | 426 DCHECK(!closed_); |
| 431 closed_ = true; | 427 closed_ = true; |
| 432 } | 428 } |
| 433 | 429 |
| 434 void MetricsLog::GetEncodedLog(std::string* encoded_log) { | 430 void MetricsLog::GetEncodedLog(std::string* encoded_log) { |
| 435 DCHECK(closed_); | 431 DCHECK(closed_); |
| 436 uma_proto_.SerializeToString(encoded_log); | 432 uma_proto_.SerializeToString(encoded_log); |
| 437 } | 433 } |
| 438 | 434 |
| 439 } // namespace metrics | 435 } // namespace metrics |
| OLD | NEW |