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

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

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 #ifndef CHROMECAST_BROWSER_METRICS_EXTERNAL_METRICS_H_ 5 #ifndef CHROMECAST_BROWSER_METRICS_EXTERNAL_METRICS_H_
6 #define CHROMECAST_BROWSER_METRICS_EXTERNAL_METRICS_H_ 6 #define CHROMECAST_BROWSER_METRICS_EXTERNAL_METRICS_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 12
13 namespace metrics { 13 namespace metrics {
14 class MetricSample; 14 class MetricSample;
15 } // namespace metrics 15 } // namespace metrics
16 16
17 namespace chromecast { 17 namespace chromecast {
18 namespace metrics { 18 namespace metrics {
19 19
20 class CastStabilityMetricsProvider; 20 class CastStabilityMetricsProvider;
21 21
22 // ExternalMetrics service allows processes outside of the Chromecast browser 22 // ExternalMetrics service allows processes outside of the Chromecast browser
23 // process to upload metrics via reading/writing to a known shared file. 23 // process to upload metrics via reading/writing to a known shared file.
24 class ExternalMetrics { 24 class ExternalMetrics {
25 public: 25 public:
26 explicit ExternalMetrics(CastStabilityMetricsProvider* stability_provider); 26 explicit ExternalMetrics(CastStabilityMetricsProvider* stability_provider);
27 ~ExternalMetrics();
28 27
29 // Begins external data collection. Calls to RecordAction originate in the 28 // Begins external data collection. Calls to RecordAction originate in the
30 // File thread but are executed in the UI thread. 29 // File thread but are executed in the UI thread.
31 void Start(); 30 void Start();
32 31
32 // Destroys itself in appropriate thread.
33 void StopAndDestroy();
34
33 private: 35 private:
36 friend class base::DeleteHelper<ExternalMetrics>;
37
38 ~ExternalMetrics();
39
34 // The max length of a message (name-value pair, plus header) 40 // The max length of a message (name-value pair, plus header)
35 static const int kMetricsMessageMaxLength = 1024; // be generous 41 static const int kMetricsMessageMaxLength = 1024; // be generous
36 42
37 // Records an external crash of the given string description. 43 // Records an external crash of the given string description.
38 void RecordCrash(const std::string& crash_kind); 44 void RecordCrash(const std::string& crash_kind);
39 45
40 // Records a sparse histogram. |sample| is expected to be a sparse histogram. 46 // Records a sparse histogram. |sample| is expected to be a sparse histogram.
41 void RecordSparseHistogram(const ::metrics::MetricSample& sample); 47 void RecordSparseHistogram(const ::metrics::MetricSample& sample);
42 48
43 // Collects external events from metrics log file. This is run at periodic 49 // Collects external events from metrics log file. This is run at periodic
(...skipping 16 matching lines...) Expand all
60 66
61 base::WeakPtrFactory<ExternalMetrics> weak_factory_; 67 base::WeakPtrFactory<ExternalMetrics> weak_factory_;
62 68
63 DISALLOW_COPY_AND_ASSIGN(ExternalMetrics); 69 DISALLOW_COPY_AND_ASSIGN(ExternalMetrics);
64 }; 70 };
65 71
66 } // namespace metrics 72 } // namespace metrics
67 } // namespace chromecast 73 } // namespace chromecast
68 74
69 #endif // CHROMECAST_BROWSER_METRICS_EXTERNAL_METRICS_H_ 75 #endif // CHROMECAST_BROWSER_METRICS_EXTERNAL_METRICS_H_
OLDNEW
« no previous file with comments | « chromecast/browser/metrics/cast_metrics_service_client.cc ('k') | chromecast/browser/metrics/external_metrics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698