OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 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. | |
4 | |
5 #ifndef CHROME_BROWSER_RAPPOR_RAPPOR_SERVICE_H_ | |
6 #define CHROME_BROWSER_RAPPOR_RAPPOR_SERVICE_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/lazy_instance.h" | |
13 #include "base/memory/weak_ptr.h" | |
14 #include "base/prefs/pref_service.h" | |
15 #include "base/time/time.h" | |
16 #include "base/timer/timer.h" | |
17 #include "components/rappor/log_uploader.h" | |
18 #include "components/rappor/proto/rappor_metric.pb.h" | |
19 | |
20 class PrefRegistrySimple; | |
21 | |
22 namespace rappor { | |
23 | |
24 // This class provides base functionality for logging rappor data. | |
25 class RapporService { | |
26 public: | |
27 RapporService(); | |
28 virtual ~RapporService(); | |
29 | |
30 // Starts the rappord system. Should be called when starting up. | |
31 void Start(PrefService* pref_service, net::URLRequestContextGetter* context); | |
32 | |
33 // At startup, prefs needs to be called with a list of all the pref names and | |
34 // types we'll be using. | |
35 static void RegisterPrefs(PrefRegistrySimple* registry); | |
36 | |
37 private: | |
38 // Client side secret used to generate fake bits. | |
39 std::string rappor_secret_; | |
40 | |
41 RapporMetricsProto rappor_metrics_proto_; | |
42 | |
43 // Timer which schedules calls OnLogInterval() | |
44 base::OneShotTimer<RapporService> log_rotation_timer_; | |
45 | |
46 LogUploader uploader_; | |
47 | |
48 // Generates a rappor_secret and stores it in preferences. If already stored, | |
49 // just retreives the stored value. | |
50 void GenerateRapporSecret(PrefService* pref_service); | |
51 | |
52 // Records a single Rappor value to the rappor_metrics_proto_. | |
53 void RecordRapporMetric(const std::string& metric_name, | |
54 const std::vector<uint8_t> bytes); | |
55 | |
56 // Records all of the collected Rappor metrics to the rappor_metric_proto_. | |
57 void RecordRapporMetrics(); | |
58 | |
59 // Called whenever the logging interval elapses. | |
60 void OnLogInterval(); | |
61 | |
62 DISALLOW_COPY_AND_ASSIGN(RapporService); | |
63 | |
64 friend class RapporServiceTest; | |
Alexei Svitkine (slow)
2013/12/11 15:27:05
Nit: This should be just below the private: sectio
Steven Holte
2013/12/11 20:31:26
Done.
| |
65 }; | |
66 | |
67 extern base::LazyInstance<RapporService>::Leaky g_rappor_service; | |
Alexei Svitkine (slow)
2013/12/11 15:27:05
I don't think we should have this as a global inst
Steven Holte
2013/12/11 20:31:26
Done.
| |
68 | |
69 } // namespace rappor | |
70 | |
71 #endif // CHROME_BROWSER_RAPPOR_RAPPOR_SERVICE_H_ | |
OLD | NEW |