OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/ukm/observers/history_delete_observer.h" |
| 6 |
| 7 #include "components/history/core/browser/history_service.h" |
| 8 |
| 9 namespace ukm { |
| 10 |
| 11 HistoryDeleteObserver::HistoryDeleteObserver() = default; |
| 12 |
| 13 HistoryDeleteObserver::~HistoryDeleteObserver() { |
| 14 for (history::HistoryService* history_service : observed_history_services_) { |
| 15 history_service->RemoveObserver(this); |
| 16 } |
| 17 } |
| 18 |
| 19 void HistoryDeleteObserver::ObserveServiceForDeletions( |
| 20 history::HistoryService* history_service) { |
| 21 if (history_service) { |
| 22 history_service->AddObserver(this); |
| 23 observed_history_services_.insert(history_service); |
| 24 } |
| 25 } |
| 26 |
| 27 void HistoryDeleteObserver::OnURLsDeleted( |
| 28 history::HistoryService* history_service, |
| 29 bool all_history, |
| 30 bool expired, |
| 31 const history::URLRows& deleted_rows, |
| 32 const std::set<GURL>& favicon_urls) { |
| 33 if (!expired) |
| 34 OnHistoryDeleted(); |
| 35 } |
| 36 |
| 37 void HistoryDeleteObserver::HistoryServiceBeingDeleted( |
| 38 history::HistoryService* history_service) { |
| 39 history_service->RemoveObserver(this); |
| 40 observed_history_services_.erase(history_service); |
| 41 } |
| 42 |
| 43 } // namespace ukm |
OLD | NEW |