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

Unified Diff: components/ukm/observers/history_delete_observer.h

Issue 2567263003: Basic UkmService implementation (Closed)
Patch Set: Rebase Created 3 years, 11 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: components/ukm/observers/history_delete_observer.h
diff --git a/components/ukm/observers/history_delete_observer.h b/components/ukm/observers/history_delete_observer.h
new file mode 100644
index 0000000000000000000000000000000000000000..eb39e50a7724b1a701cb5ac0d343173d3c8d3349
--- /dev/null
+++ b/components/ukm/observers/history_delete_observer.h
@@ -0,0 +1,47 @@
+// Copyright 2017 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 COMPONENTS_UKM_OBSERVERS_HISTORY_DELETE_OBSERVER_H_
+#define COMPONENTS_UKM_OBSERVERS_HISTORY_DELETE_OBSERVER_H_
+
+#include <set>
+
+#include "base/scoped_observer.h"
+#include "components/history/core/browser/history_service_observer.h"
+
+namespace ukm {
+
+// Observes multiple HistoryService objects for any events that delete history.
+// Handles cleanup and removing observers as objects are destroyed.
+class HistoryDeleteObserver : public history::HistoryServiceObserver {
+ public:
+ HistoryDeleteObserver();
+ ~HistoryDeleteObserver() override;
+
+ // Starts observing a service for history deletions.
+ void ObserveServiceForDeletions(history::HistoryService* history_service);
+
+ // history::HistoryServiceObserver
+ void OnURLsDeleted(history::HistoryService* history_service,
+ bool all_history,
+ bool expired,
+ const history::URLRows& deleted_rows,
+ const std::set<GURL>& favicon_urls) override;
+ void HistoryServiceBeingDeleted(
+ history::HistoryService* history_service) override;
+
+ protected:
+ virtual void OnHistoryDeleted() = 0;
+
+ private:
+ // Tracks observed history services, for cleanup.
+ ScopedObserver<history::HistoryService, history::HistoryServiceObserver>
+ history_observer_;
+
+ DISALLOW_COPY_AND_ASSIGN(HistoryDeleteObserver);
+};
+
+} // namespace ukm
+
+#endif // COMPONENTS_UKM_OBSERVERS_HISTORY_DELETE_OBSERVER_H_

Powered by Google App Engine
This is Rietveld 408576698