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

Side by Side Diff: components/cronet/histogram_manager.h

Issue 1882563004: [Cronet] Make HistogramManager public APIs thread-safe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make lock specific to GetDeltas() Created 4 years, 8 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
« no previous file with comments | « no previous file | components/cronet/histogram_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 COMPONENTS_CRONET_HISTOGRAM_MANAGER_H_ 5 #ifndef COMPONENTS_CRONET_HISTOGRAM_MANAGER_H_
6 #define COMPONENTS_CRONET_HISTOGRAM_MANAGER_H_ 6 #define COMPONENTS_CRONET_HISTOGRAM_MANAGER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/metrics/histogram_flattener.h" 16 #include "base/metrics/histogram_flattener.h"
17 #include "base/metrics/histogram_snapshot_manager.h" 17 #include "base/metrics/histogram_snapshot_manager.h"
18 #include "base/synchronization/lock.h"
18 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h" 19 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h"
19 20
20 namespace cronet { 21 namespace cronet {
21 22
22 // A HistogramManager instance is created by the app. It is the central 23 // A HistogramManager instance is created by the app. It is the central
23 // controller for the acquisition of log data, and recording deltas for 24 // controller for the acquisition of log data, and recording deltas for
24 // transmission to an external server. 25 // transmission to an external server. Public APIs are all thread-safe.
25 class HistogramManager : public base::HistogramFlattener { 26 class HistogramManager : public base::HistogramFlattener {
26 public: 27 public:
27 HistogramManager(); 28 HistogramManager();
28 ~HistogramManager() override; 29 ~HistogramManager() override;
29 30
30 // Snapshot all histograms to record the delta into |uma_proto_| and then 31 // Snapshot all histograms to record the delta into |uma_proto_| and then
31 // returns the serialized protobuf representation of the record in |data|. 32 // returns the serialized protobuf representation of the record in |data|.
32 // Returns true if it was successfully serialized. 33 // Returns true if it was successfully serialized.
33 bool GetDeltas(std::vector<uint8_t>* data); 34 bool GetDeltas(std::vector<uint8_t>* data);
34 35
(...skipping 10 matching lines...) Expand all
45 base::HistogramBase::Inconsistency problem) override; 46 base::HistogramBase::Inconsistency problem) override;
46 void UniqueInconsistencyDetected( 47 void UniqueInconsistencyDetected(
47 base::HistogramBase::Inconsistency problem) override; 48 base::HistogramBase::Inconsistency problem) override;
48 void InconsistencyDetectedInLoggedCount(int amount) override; 49 void InconsistencyDetectedInLoggedCount(int amount) override;
49 50
50 base::HistogramSnapshotManager histogram_snapshot_manager_; 51 base::HistogramSnapshotManager histogram_snapshot_manager_;
51 52
52 // Stores the protocol buffer representation for this log. 53 // Stores the protocol buffer representation for this log.
53 metrics::ChromeUserMetricsExtension uma_proto_; 54 metrics::ChromeUserMetricsExtension uma_proto_;
54 55
56 // Should be acquired whenever GetDeltas() is executing to maintain
57 // thread-safety.
58 base::Lock get_deltas_lock_;
59
55 DISALLOW_COPY_AND_ASSIGN(HistogramManager); 60 DISALLOW_COPY_AND_ASSIGN(HistogramManager);
56 }; 61 };
57 62
58 } // namespace cronet 63 } // namespace cronet
59 64
60 #endif // COMPONENTS_CRONET_HISTOGRAM_MANAGER_H_ 65 #endif // COMPONENTS_CRONET_HISTOGRAM_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | components/cronet/histogram_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698