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

Unified Diff: chrome/browser/safe_browsing/incident_reporting_service.h

Issue 441453002: Support for process-wide incidents in the safe browsing incident reporting service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: impl Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/incident_reporting_service.h
diff --git a/chrome/browser/safe_browsing/incident_reporting_service.h b/chrome/browser/safe_browsing/incident_reporting_service.h
index bd024728cc21f67c66c27fa115f6478106a61f81..5a4c7e566ef939c7d7b7a3bc1fbc5713dcf15184 100644
--- a/chrome/browser/safe_browsing/incident_reporting_service.h
+++ b/chrome/browser/safe_browsing/incident_reporting_service.h
@@ -19,6 +19,8 @@
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "chrome/browser/safe_browsing/add_incident_callback.h"
+#include "chrome/browser/safe_browsing/delayed_analysis_callback.h"
+#include "chrome/browser/safe_browsing/delayed_callback_runner.h"
#include "chrome/browser/safe_browsing/incident_report_uploader.h"
#include "chrome/browser/safe_browsing/last_download_finder.h"
#include "content/public/browser/notification_observer.h"
@@ -54,11 +56,13 @@ class ClientIncidentReport_IncidentData;
// begins operation when an incident is reported via the AddIncident method.
// Incidents reported from a profile that is loading are held until the profile
// is fully created. Incidents originating from profiles that do not participate
-// in safe browsing are dropped. Following the addition of an incident that is
-// not dropped, the service collects environmental data, finds the most recent
-// binary download, and waits a bit. Additional incidents that arrive during
-// this time are collated with the initial incident. Finally, already-reported
-// incidents are pruned and any remaining are uploaded in an incident report.
+// in safe browsing are dropped. Process-wide incidents are affiliated with a
+// profile that participates in safe browsing when one becomes available.
robertshield 2014/08/05 21:26:28 s/one/such a profile/ to resolve mild pronoun ambi
+// Following the addition of an incident that is not dropped, the service
+// collects environmental data, finds the most recent binary download, and waits
+// a bit. Additional incidents that arrive during this time are collated with
+// the initial incident. Finally, already-reported incidents are pruned and any
+// remaining are uploaded in an incident report.
class IncidentReportingService : public content::NotificationObserver {
public:
IncidentReportingService(SafeBrowsingService* safe_browsing_service,
@@ -83,6 +87,9 @@ class IncidentReportingService : public content::NotificationObserver {
scoped_ptr<TrackedPreferenceValidationDelegate>
CreatePreferenceValidationDelegate(Profile* profile);
+ // Registers |callback| to be run after some delay following process launch.
+ void RegisterDelayedAnalysisCallback(const DelayedAnalysisCallback& callback);
+
protected:
// A pointer to a function that populates a protobuf with environment data.
typedef void (*CollectEnvironmentDataFn)(
@@ -131,11 +138,23 @@ class IncidentReportingService : public content::NotificationObserver {
// but not yet uploaded are dropped.
void OnProfileDestroyed(Profile* profile);
+ // Returns an initialized profile that participates in safe browsing. Profiles
+ // participating in extended safe browsing are preferred.
+ Profile* FindEligibleProfile() const;
+
// Adds |incident_data| to the service. The incident_time_msec field is
// populated with the current time if the caller has not already done so.
void AddIncident(Profile* profile,
scoped_ptr<ClientIncidentReport_IncidentData> incident_data);
+ // Begins processing a report. If processing is already underway, ensures that
+ // collection tasks have completed or are running.
+ void BeginReportProcessing();
+
+ // Begins the process of collating incidents by waiting for incidents to
+ // arrive. This function is idempotent.
+ void BeginIncidentCollation();
+
// Starts a task to collect environment data in the blocking pool.
void BeginEnvironmentCollection();
@@ -159,10 +178,11 @@ class IncidentReportingService : public content::NotificationObserver {
// Cancels the collection timeout.
void CancelIncidentCollection();
- // A callback invoked on the UI thread after which incident collection has
+ // A callback invoked on the UI thread after which incident collation has
// completed. Incident report processing continues, either by waiting for
- // environment data to arrive or by sending an incident report.
- void OnCollectionTimeout();
+ // environment data or the most recent download to arrive or by sending an
+ // incident report.
+ void OnCollationTimeout();
// Starts the asynchronous process of finding the most recent executable
// download if one is not currently being search for and/or has not already
@@ -234,12 +254,12 @@ class IncidentReportingService : public content::NotificationObserver {
bool environment_collection_pending_;
// True when an incident has been received and the service is waiting for the
- // upload_timer_ to fire.
- bool collection_timeout_pending_;
+ // collation_timer_ to fire.
+ bool collation_timeout_pending_;
// A timer upon the firing of which the service will report received
// incidents.
- base::DelayTimer<IncidentReportingService> upload_timer_;
+ base::DelayTimer<IncidentReportingService> collation_timer_;
// The report currently being assembled. This becomes non-NULL when an initial
// incident is reported, and returns to NULL when the report is sent for
@@ -258,9 +278,13 @@ class IncidentReportingService : public content::NotificationObserver {
// The time at which download collection was initiated.
base::TimeTicks last_download_begin_;
- // Context data for all on-the-record profiles.
+ // Context data for all on-the-record profiles plus the process-wide (NULL)
+ // context.
ProfileContextCollection profiles_;
+ // Callbacks registered for performing delayed analysis.
+ DelayedCallbackRunner delayed_analysis_callbacks_;
+
// The collection of uploads in progress.
ScopedVector<UploadContext> uploads_;

Powered by Google App Engine
This is Rietveld 408576698