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 "chrome/browser/metrics/chrome_metrics_service_client.h" | 5 #include "chrome/browser/metrics/chrome_metrics_service_client.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 start_time_(base::TimeTicks::Now()), | 206 start_time_(base::TimeTicks::Now()), |
207 has_uploaded_profiler_data_(false), | 207 has_uploaded_profiler_data_(false), |
208 weak_ptr_factory_(this) { | 208 weak_ptr_factory_(this) { |
209 DCHECK(thread_checker_.CalledOnValidThread()); | 209 DCHECK(thread_checker_.CalledOnValidThread()); |
210 RecordCommandLineMetrics(); | 210 RecordCommandLineMetrics(); |
211 RegisterForNotifications(); | 211 RegisterForNotifications(); |
212 } | 212 } |
213 | 213 |
214 ChromeMetricsServiceClient::~ChromeMetricsServiceClient() { | 214 ChromeMetricsServiceClient::~ChromeMetricsServiceClient() { |
215 DCHECK(thread_checker_.CalledOnValidThread()); | 215 DCHECK(thread_checker_.CalledOnValidThread()); |
216 | |
217 // If there is a global metrics file being updated on disk, mark it to be | |
Alexei Svitkine (slow)
2016/06/16 11:36:57
Please make a function in the anon namespace that
bcwhite
2016/06/16 14:21:08
Done.
I checked that the object is deleted on cle
| |
218 // deleted when the process exits. A normal shutdown is almost complete | |
219 // so there is no benefit in keeping a file with no new data to be processed | |
220 // during the next startup sequence. | |
221 base::GlobalHistogramAllocator* allocator = | |
222 base::GlobalHistogramAllocator::Get(); | |
223 if (allocator) { | |
224 base::FilePath path = allocator->GetPersistentLocation(); | |
225 if (!path.empty()) { | |
226 base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_READ | | |
227 base::File::FLAG_DELETE_ON_CLOSE); | |
228 } | |
229 } | |
216 } | 230 } |
217 | 231 |
218 // static | 232 // static |
219 std::unique_ptr<ChromeMetricsServiceClient> ChromeMetricsServiceClient::Create( | 233 std::unique_ptr<ChromeMetricsServiceClient> ChromeMetricsServiceClient::Create( |
220 metrics::MetricsStateManager* state_manager, | 234 metrics::MetricsStateManager* state_manager, |
221 PrefService* local_state) { | 235 PrefService* local_state) { |
222 // Perform two-phase initialization so that |client->metrics_service_| only | 236 // Perform two-phase initialization so that |client->metrics_service_| only |
223 // receives pointers to fully constructed objects. | 237 // receives pointers to fully constructed objects. |
224 std::unique_ptr<ChromeMetricsServiceClient> client( | 238 std::unique_ptr<ChromeMetricsServiceClient> client( |
225 new ChromeMetricsServiceClient(state_manager)); | 239 new ChromeMetricsServiceClient(state_manager)); |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
733 } | 747 } |
734 } | 748 } |
735 | 749 |
736 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { | 750 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { |
737 metrics_service_->OnApplicationNotIdle(); | 751 metrics_service_->OnApplicationNotIdle(); |
738 } | 752 } |
739 | 753 |
740 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() { | 754 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() { |
741 return metrics::IsCellularLogicEnabled(); | 755 return metrics::IsCellularLogicEnabled(); |
742 } | 756 } |
OLD | NEW |