Remove migrateNetworkPredictionPreferences().
[chromium-blink-merge.git] / components / visitedlink / browser / visitedlink_event_listener.h
blob2b6aa726d0f1c3a2368a8461af63aeb7e96aecda
1 // Copyright (c) 2011 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.
5 #ifndef COMPONENTS_VISITEDLINK_BROWSER_VISITEDLINK_EVENT_LISTENER_H_
6 #define COMPONENTS_VISITEDLINK_BROWSER_VISITEDLINK_EVENT_LISTENER_H_
8 #include <map>
10 #include "base/memory/linked_ptr.h"
11 #include "base/timer/timer.h"
12 #include "components/visitedlink/browser/visitedlink_master.h"
13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h"
16 namespace base {
17 class SharedMemory;
20 namespace content {
21 class BrowserContext;
24 namespace visitedlink {
26 class VisitedLinkUpdater;
28 // VisitedLinkEventListener broadcasts link coloring database updates to all
29 // processes. It also coalesces the updates to avoid excessive broadcasting of
30 // messages to the renderers.
31 class VisitedLinkEventListener : public VisitedLinkMaster::Listener,
32 public content::NotificationObserver {
33 public:
34 VisitedLinkEventListener(VisitedLinkMaster* master,
35 content::BrowserContext* browser_context);
36 ~VisitedLinkEventListener() override;
38 void NewTable(base::SharedMemory* table_memory) override;
39 void Add(VisitedLinkMaster::Fingerprint fingerprint) override;
40 void Reset() override;
42 private:
43 void CommitVisitedLinks();
45 // content::NotificationObserver implementation.
46 void Observe(int type,
47 const content::NotificationSource& source,
48 const content::NotificationDetails& details) override;
50 base::OneShotTimer<VisitedLinkEventListener> coalesce_timer_;
51 VisitedLinkCommon::Fingerprints pending_visited_links_;
53 content::NotificationRegistrar registrar_;
55 // Map between renderer child ids and their VisitedLinkUpdater.
56 typedef std::map<int, linked_ptr<VisitedLinkUpdater> > Updaters;
57 Updaters updaters_;
59 VisitedLinkMaster* master_;
61 // Used to filter RENDERER_PROCESS_CREATED notifications to renderers that
62 // belong to this BrowserContext.
63 content::BrowserContext* browser_context_;
65 DISALLOW_COPY_AND_ASSIGN(VisitedLinkEventListener);
68 } // namespace visitedlink
70 #endif // COMPONENTS_VISITEDLINK_BROWSER_VISITEDLINK_EVENT_LISTENER_H_