Chromium Code Reviews| 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..54942c67adf3199d0c6c001444fd9af7bcd101cb |
| --- /dev/null |
| +++ b/components/ukm/observers/history_delete_observer.h |
| @@ -0,0 +1,45 @@ |
| +// 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 "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. |
| + std::set<history::HistoryService*> observed_history_services_; |
|
sdefresne
2017/01/23 09:53:04
I would recommend using ScopedObserver here. It al
Steven Holte
2017/01/23 20:37:29
Done, thanks for the tip.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(HistoryDeleteObserver); |
| +}; |
| + |
| +} // namespace ukm |
| + |
| +#endif // COMPONENTS_UKM_OBSERVERS_HISTORY_DELETE_OBSERVER_H_ |