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 "chromecast/browser/metrics/external_metrics.h" | 5 #include "chromecast/browser/metrics/external_metrics.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 const char kEventsFilePath[] = "/data/share/chrome/metrics/uma-events"; | 51 const char kEventsFilePath[] = "/data/share/chrome/metrics/uma-events"; |
52 | 52 |
53 ExternalMetrics::ExternalMetrics( | 53 ExternalMetrics::ExternalMetrics( |
54 CastStabilityMetricsProvider* stability_provider) | 54 CastStabilityMetricsProvider* stability_provider) |
55 : stability_provider_(stability_provider), | 55 : stability_provider_(stability_provider), |
56 uma_events_file_(kEventsFilePath), | 56 uma_events_file_(kEventsFilePath), |
57 weak_factory_(this) { | 57 weak_factory_(this) { |
58 DCHECK(stability_provider); | 58 DCHECK(stability_provider); |
59 } | 59 } |
60 | 60 |
61 ExternalMetrics::~ExternalMetrics() {} | 61 ExternalMetrics::~ExternalMetrics() { |
62 } | |
63 | |
64 void ExternalMetrics::DestroySelf() { | |
65 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)) { | |
gunsch
2015/01/09 18:56:19
Why does it need to be destroyed on the file threa
gfhuang
2015/01/09 19:10:45
Yes
| |
66 content::BrowserThread::PostTask( | |
67 content::BrowserThread::FILE, | |
68 FROM_HERE, | |
69 base::Bind(&ExternalMetrics::DestroySelf, base::Unretained(this))); | |
70 return; | |
71 } | |
72 delete this; | |
73 } | |
62 | 74 |
63 void ExternalMetrics::Start() { | 75 void ExternalMetrics::Start() { |
64 ScheduleCollector(); | 76 ScheduleCollector(); |
65 } | 77 } |
66 | 78 |
67 void ExternalMetrics::RecordCrash(const std::string& crash_kind) { | 79 void ExternalMetrics::RecordCrash(const std::string& crash_kind) { |
68 content::BrowserThread::PostTask( | 80 content::BrowserThread::PostTask( |
69 content::BrowserThread::UI, FROM_HERE, | 81 content::BrowserThread::UI, FROM_HERE, |
70 base::Bind(&CastStabilityMetricsProvider::LogExternalCrash, | 82 base::Bind(&CastStabilityMetricsProvider::LogExternalCrash, |
71 base::Unretained(stability_provider_), | 83 base::Unretained(stability_provider_), |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 content::BrowserThread::FILE, | 148 content::BrowserThread::FILE, |
137 FROM_HERE, | 149 FROM_HERE, |
138 base::Bind(&ExternalMetrics::CollectEventsAndReschedule, | 150 base::Bind(&ExternalMetrics::CollectEventsAndReschedule, |
139 weak_factory_.GetWeakPtr()), | 151 weak_factory_.GetWeakPtr()), |
140 base::TimeDelta::FromSeconds(kExternalMetricsCollectionIntervalSeconds)); | 152 base::TimeDelta::FromSeconds(kExternalMetricsCollectionIntervalSeconds)); |
141 DCHECK(result); | 153 DCHECK(result); |
142 } | 154 } |
143 | 155 |
144 } // namespace metrics | 156 } // namespace metrics |
145 } // namespace chromecast | 157 } // namespace chromecast |
OLD | NEW |