Make SafeBrowsing Rappor metrics controlled by Safebrowsing bit.
This moves control over whether SafeBrowsing related Rappor metrics
(formerly COARSE Rappor metrics) are reported to be determined by the
SafeBrowsing bit. The user-metrics bit will have no effect on these metrics.
BUG=485310,418242
Review URL: https://codereview.chromium.org/1127903002
Cr-Commit-Position: refs/heads/master@{#335095}
diff --git a/components/rappor/rappor_service.h b/components/rappor/rappor_service.h
index 2a3daa8..286d7ce 100644
--- a/components/rappor/rappor_service.h
+++ b/components/rappor/rappor_service.h
@@ -12,6 +12,7 @@
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
+#include "base/threading/thread_checker.h"
#include "base/timer/timer.h"
#include "components/metrics/daily_event.h"
#include "components/rappor/rappor_parameters.h"
@@ -36,10 +37,11 @@
// Generic metrics from UMA opt-in users.
UMA_RAPPOR_TYPE = 0,
// Generic metrics for SafeBrowsing users.
- COARSE_RAPPOR_TYPE,
+ SAFEBROWSING_RAPPOR_TYPE,
// Deprecated: Use UMA_RAPPOR_TYPE for new metrics
ETLD_PLUS_ONE_RAPPOR_TYPE,
NUM_RAPPOR_TYPES,
+ COARSE_RAPPOR_TYPE = SAFEBROWSING_RAPPOR_TYPE,
};
// This class provides an interface for recording samples for rappor metrics,
@@ -63,10 +65,12 @@
// Updates the settings for metric recording and uploading.
// The RapporService must be initialized before this method is called.
- // If |recording_level| > REPORTING_DISABLED, periodic reports will be
+ // |recording_groups| should be set of flags, e.g.
+ // UMA_RECORDING_GROUP | SAFEBROWSING_RECORDING_GROUP
+ // If it contains any enabled groups, periodic reports will be
// generated and queued for upload.
// If |may_upload| is true, reports will be uploaded from the queue.
- void Update(RecordingLevel recording_level, bool may_upload);
+ void Update(int recording_groups, bool may_upload);
// Constructs a Sample object for the caller to record fields in.
scoped_ptr<Sample> CreateSample(RapporType);
@@ -104,9 +108,6 @@
int32_t cohort,
const std::string& secret);
- // Sets the recording level.
- void SetRecordingLevel(RecordingLevel parameters);
-
// Cancels the next call to OnLogInterval.
virtual void CancelNextLogRotation();
@@ -133,6 +134,11 @@
// reports and pass it to the uploader.
void OnLogInterval();
+ // Check if recording of the metric is allowed, given it's parameters.
+ // This will check that we are not in incognito mode, and that the
+ // appropriate recording group is enabled.
+ bool RecordingAllowed(const RapporParameters& parameters);
+
// Finds a metric in the metrics_map_, creating it if it doesn't already
// exist.
RapporMetric* LookUpMetric(const std::string& metric_name,
@@ -159,8 +165,9 @@
// A private LogUploader instance for sending reports to the server.
scoped_ptr<LogUploaderInterface> uploader_;
- // What reporting level of metrics are being reported.
- RecordingLevel recording_level_;
+ // The set of recording groups that metrics are being recorded, e.g.
+ // UMA_RECORDING_GROUP | SAFEBROWSING_RECORDING_GROUP
+ int recording_groups_;
// We keep all registered metrics in a map, from name to metric.
// The map owns the metrics it contains.
@@ -168,6 +175,8 @@
internal::Sampler sampler_;
+ base::ThreadChecker thread_checker_;
+
DISALLOW_COPY_AND_ASSIGN(RapporService);
};