 Chromium Code Reviews
 Chromium Code Reviews Issue 49753002:
  RAPPOR implementation  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 49753002:
  RAPPOR implementation  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| Index: components/rappor/rappor_service.h | 
| diff --git a/components/rappor/rappor_service.h b/components/rappor/rappor_service.h | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..b1204799b49d051987e305337a6774e8e6cd3d5e | 
| --- /dev/null | 
| +++ b/components/rappor/rappor_service.h | 
| @@ -0,0 +1,71 @@ | 
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +#ifndef CHROME_BROWSER_RAPPOR_RAPPOR_SERVICE_H_ | 
| +#define CHROME_BROWSER_RAPPOR_RAPPOR_SERVICE_H_ | 
| + | 
| +#include <string> | 
| +#include <vector> | 
| + | 
| +#include "base/basictypes.h" | 
| +#include "base/lazy_instance.h" | 
| +#include "base/memory/weak_ptr.h" | 
| +#include "base/prefs/pref_service.h" | 
| +#include "base/time/time.h" | 
| +#include "base/timer/timer.h" | 
| +#include "components/rappor/log_uploader.h" | 
| +#include "components/rappor/proto/rappor_metric.pb.h" | 
| + | 
| +class PrefRegistrySimple; | 
| + | 
| +namespace rappor { | 
| + | 
| +// This class provides base functionality for logging rappor data. | 
| +class RapporService { | 
| + public: | 
| + RapporService(); | 
| + virtual ~RapporService(); | 
| + | 
| + // Starts the rappord system. Should be called when starting up. | 
| + void Start(PrefService* pref_service, net::URLRequestContextGetter* context); | 
| + | 
| + // At startup, prefs needs to be called with a list of all the pref names and | 
| + // types we'll be using. | 
| + static void RegisterPrefs(PrefRegistrySimple* registry); | 
| + | 
| + private: | 
| + // Client side secret used to generate fake bits. | 
| + std::string rappor_secret_; | 
| + | 
| + RapporMetricsProto rappor_metrics_proto_; | 
| + | 
| + // Timer which schedules calls OnLogInterval() | 
| + base::OneShotTimer<RapporService> log_rotation_timer_; | 
| + | 
| + LogUploader uploader_; | 
| + | 
| + // Generates a rappor_secret and stores it in preferences. If already stored, | 
| + // just retreives the stored value. | 
| + void GenerateRapporSecret(PrefService* pref_service); | 
| + | 
| + // Records a single Rappor value to the rappor_metrics_proto_. | 
| + void RecordRapporMetric(const std::string& metric_name, | 
| + const std::vector<uint8_t> bytes); | 
| + | 
| + // Records all of the collected Rappor metrics to the rappor_metric_proto_. | 
| + void RecordRapporMetrics(); | 
| + | 
| + // Called whenever the logging interval elapses. | 
| + void OnLogInterval(); | 
| + | 
| + DISALLOW_COPY_AND_ASSIGN(RapporService); | 
| + | 
| + 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.
 | 
| +}; | 
| + | 
| +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.
 | 
| + | 
| +} // namespace rappor | 
| + | 
| +#endif // CHROME_BROWSER_RAPPOR_RAPPOR_SERVICE_H_ |