summaryrefslogtreecommitdiff
path: root/chromium/components/ukm/observers/history_delete_observer.h
blob: eb39e50a7724b1a701cb5ac0d343173d3c8d3349 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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_