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

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

Issue 7383012: Start and stop the safe browsing service depending on whether any profile is using it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 9 years, 5 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
« no previous file with comments | « chrome/browser/profiles/profile_manager.cc ('k') | chrome/browser/safe_browsing/safe_browsing_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/safe_browsing/safe_browsing_service.h
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.h b/chrome/browser/safe_browsing/safe_browsing_service.h
index 90199377d5423df4e5b981c8e12fecb9fbbe34f2..f9b2c6cbfaf34b1a7284470fbcb3e1b68758b571 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service.h
+++ b/chrome/browser/safe_browsing/safe_browsing_service.h
@@ -10,6 +10,7 @@
#pragma once
#include <deque>
+#include <map>
#include <set>
#include <string>
#include <vector>
@@ -26,6 +27,7 @@
#include "googleurl/src/gurl.h"
class MalwareDetails;
+class PrefChangeRegistrar;
class PrefService;
class SafeBrowsingDatabase;
class SafeBrowsingProtocolManager;
@@ -227,9 +229,6 @@ class SafeBrowsingService
void OnNewMacKeys(const std::string& client_key,
const std::string& wrapped_key);
- // Notification on the UI thread from the advanced options UI.
- void OnEnable(bool enabled);
-
bool enabled() const { return enabled_; }
bool download_protection_enabled() const {
@@ -418,6 +417,16 @@ class SafeBrowsingService
const NotificationSource& source,
const NotificationDetails& details) OVERRIDE;
+ // Starts following the safe browsing preference on |pref_service|.
+ void AddPrefService(PrefService* pref_service);
+
+ // Stop following the safe browsing preference on |pref_service|.
+ void RemovePrefService(PrefService* pref_service);
+
+ // Checks if any profile is currently using the safe browsing service, and
+ // starts or stops the service accordingly.
+ void RefreshState();
+
// The factory used to instanciate a SafeBrowsingService object.
// Useful for tests, so they can provide their own implementation of
// SafeBrowsingService.
@@ -480,8 +489,17 @@ class SafeBrowsingService
// Similar to |download_urlcheck_timeout_ms_|, but for download hash checks.
int64 download_hashcheck_timeout_ms_;
+ // Used to track purge memory notifications. Lives on the IO thread.
NotificationRegistrar registrar_;
+ // Tracks existing PrefServices, and the safe browsing preference on each.
+ // This is used to determine if any profile is currently using the safe
+ // browsing service, and to start it up or shut it down accordingly.
+ std::map<PrefService*, PrefChangeRegistrar*> prefs_map_;
+
+ // Used to track creation and destruction of profiles on the UI thread.
+ NotificationRegistrar prefs_registrar_;
+
DISALLOW_COPY_AND_ASSIGN(SafeBrowsingService);
};
« no previous file with comments | « chrome/browser/profiles/profile_manager.cc ('k') | chrome/browser/safe_browsing/safe_browsing_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698