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

Side by Side Diff: chromecast/browser/metrics/external_metrics.cc

Issue 845003002: [chromecast] ExternalMetrics has to destroy itself in file thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
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 "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
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)) {
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;
byungchul 2015/01/09 21:23:24 why not just: content::BrowserThread::DeleteSoon(
gfhuang 2015/01/09 22:30:18 Done.
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698