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

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

Issue 2796123003: Componentize safe_browsing: factor out chrome/ deps in ThreatDetailsRedirectsCollector. (Closed)
Patch Set: fix crashes Created 3 years, 8 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/threat_details_history.h
diff --git a/chrome/browser/safe_browsing/threat_details_history.h b/chrome/browser/safe_browsing/threat_details_history.h
index 67c9a087eee01a5e54499187557aef5c1320297f..70c1236031c002ff2f34cbe5187db559c9b9ff00 100644
--- a/chrome/browser/safe_browsing/threat_details_history.h
+++ b/chrome/browser/safe_browsing/threat_details_history.h
@@ -14,16 +14,13 @@
#include "base/containers/hash_tables.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
+#include "base/scoped_observer.h"
#include "base/sequenced_task_runner_helpers.h"
#include "base/task/cancelable_task_tracker.h"
-#include "components/history/core/browser/history_service.h"
+#include "components/history/core/browser/history_service_observer.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_registrar.h"
#include "net/base/completion_callback.h"
-class Profile;
-
namespace safe_browsing {
typedef std::vector<GURL> RedirectChain;
@@ -32,9 +29,10 @@ class ThreatDetailsRedirectsCollector
: public base::RefCountedThreadSafe<
ThreatDetailsRedirectsCollector,
content::BrowserThread::DeleteOnUIThread>,
- public content::NotificationObserver {
+ public history::HistoryServiceObserver {
public:
- explicit ThreatDetailsRedirectsCollector(Profile* profile);
+ explicit ThreatDetailsRedirectsCollector(
+ const base::WeakPtr<history::HistoryService>& history_service);
// Collects urls' redirects chain information from the history service.
// We get access to history service via web_contents in UI thread.
@@ -48,10 +46,9 @@ class ThreatDetailsRedirectsCollector
// Returns the redirect urls we get from history service
const std::vector<RedirectChain>& GetCollectedUrls() const;
- // content::NotificationObserver
- void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) override;
+ // history::HistoryServiceObserver
+ void HistoryServiceBeingDeleted(
+ history::HistoryService* history_service) override;
private:
friend struct content::BrowserThread::DeleteOnThread<
@@ -69,7 +66,6 @@ class ThreatDetailsRedirectsCollector
// is all done.
void AllDone();
- Profile* profile_;
base::CancelableTaskTracker request_tracker_;
// Method we call when we are done. The caller must be alive for the
@@ -86,7 +82,9 @@ class ThreatDetailsRedirectsCollector
// The collected directs from history service
std::vector<RedirectChain> redirects_urls_;
- content::NotificationRegistrar registrar_;
+ base::WeakPtr<history::HistoryService> history_service_;
+ ScopedObserver<history::HistoryService, history::HistoryServiceObserver>
+ history_service_observer_;
DISALLOW_COPY_AND_ASSIGN(ThreatDetailsRedirectsCollector);
};

Powered by Google App Engine
This is Rietveld 408576698