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

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

Issue 2567263003: Basic UkmService implementation (Closed)
Patch Set: Check OFFICIAL_BUILD 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.cc
diff --git a/components/ukm/observers/history_delete_observer.cc b/components/ukm/observers/history_delete_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6a82e127f35c605fa3bf5c18d095eb445965b762
--- /dev/null
+++ b/components/ukm/observers/history_delete_observer.cc
@@ -0,0 +1,43 @@
+// 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.
+
+#include "components/ukm/observers/history_delete_observer.h"
+
+#include "components/history/core/browser/history_service.h"
+
+namespace ukm {
+
+HistoryDeleteObserver::HistoryDeleteObserver() = default;
+
+HistoryDeleteObserver::~HistoryDeleteObserver() {
+ for (history::HistoryService* history_service : observed_history_services_) {
+ history_service->RemoveObserver(this);
+ }
+}
+
+void HistoryDeleteObserver::ObserveServiceForDeletions(
+ history::HistoryService* history_service) {
+ if (history_service) {
+ history_service->AddObserver(this);
+ observed_history_services_.insert(history_service);
+ }
+}
+
+void HistoryDeleteObserver::OnURLsDeleted(
+ history::HistoryService* history_service,
+ bool all_history,
+ bool expired,
+ const history::URLRows& deleted_rows,
+ const std::set<GURL>& favicon_urls) {
+ if (!expired)
+ OnHistoryDeleted();
+}
+
+void HistoryDeleteObserver::HistoryServiceBeingDeleted(
+ history::HistoryService* history_service) {
+ history_service->RemoveObserver(this);
+ observed_history_services_.erase(history_service);
+}
+
+} // namespace ukm

Powered by Google App Engine
This is Rietveld 408576698