cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / chromecast / browser / metrics / external_metrics.h
blob5c451611b55effe791cf1e1f432c1c94b8958149
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
3 // found in the LICENSE file.
5 #ifndef CHROMECAST_BROWSER_METRICS_EXTERNAL_METRICS_H_
6 #define CHROMECAST_BROWSER_METRICS_EXTERNAL_METRICS_H_
8 #include <string>
10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h"
13 namespace metrics {
14 class MetricSample;
15 } // namespace metrics
17 namespace chromecast {
18 namespace metrics {
20 class CastStabilityMetricsProvider;
22 // ExternalMetrics service allows processes outside of the Chromecast browser
23 // process to upload metrics via reading/writing to a known shared file.
24 class ExternalMetrics {
25 public:
26 explicit ExternalMetrics(CastStabilityMetricsProvider* stability_provider,
27 const std::string& uma_events_file);
28 // Begins external data collection. Calls to RecordAction originate in the
29 // File thread but are executed in the UI thread.
30 void Start();
32 // Destroys itself in appropriate thread.
33 void StopAndDestroy();
35 private:
36 friend class base::DeleteHelper<ExternalMetrics>;
38 ~ExternalMetrics();
40 // The max length of a message (name-value pair, plus header)
41 static const int kMetricsMessageMaxLength = 1024; // be generous
43 // Records an external crash of the given string description.
44 void RecordCrash(const std::string& crash_kind);
46 // Records a sparse histogram. |sample| is expected to be a sparse histogram.
47 void RecordSparseHistogram(const ::metrics::MetricSample& sample);
49 // Collects external events from metrics log file. This is run at periodic
50 // intervals.
52 // Returns the number of events collected.
53 int CollectEvents();
55 // Calls CollectEvents and reschedules a future collection.
56 void CollectEventsAndReschedule();
58 // Reference to stability metrics provider, for reporting external crashes.
59 CastStabilityMetricsProvider* const stability_provider_;
61 // File used by libmetrics to send metrics to the browser process.
62 const std::string uma_events_file_;
64 base::WeakPtrFactory<ExternalMetrics> weak_factory_;
66 DISALLOW_COPY_AND_ASSIGN(ExternalMetrics);
69 } // namespace metrics
70 } // namespace chromecast
72 #endif // CHROMECAST_BROWSER_METRICS_EXTERNAL_METRICS_H_