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

Side by Side Diff: chrome/browser/visitedlink_event_listener.cc

Issue 5606002: Move:... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/visitedlink_event_listener.h ('k') | chrome/browser/visitedlink_master.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 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 "chrome/browser/visitedlink_event_listener.h"
6
7 #include "base/shared_memory.h"
8 #include "chrome/browser/renderer_host/render_process_host.h"
9
10 using base::Time;
11 using base::TimeDelta;
12
13 // The amount of time we wait to accumulate visited link additions.
14 static const int kCommitIntervalMs = 100;
15
16 VisitedLinkEventListener::VisitedLinkEventListener() {
17 }
18
19 VisitedLinkEventListener::~VisitedLinkEventListener() {
20 }
21
22 void VisitedLinkEventListener::NewTable(base::SharedMemory* table_memory) {
23 if (!table_memory)
24 return;
25
26 // Send to all RenderProcessHosts.
27 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator());
28 !i.IsAtEnd(); i.Advance()) {
29 if (!i.GetCurrentValue()->HasConnection())
30 continue;
31
32 i.GetCurrentValue()->SendVisitedLinkTable(table_memory);
33 }
34 }
35
36 void VisitedLinkEventListener::Add(VisitedLinkMaster::Fingerprint fingerprint) {
37 pending_visited_links_.push_back(fingerprint);
38
39 if (!coalesce_timer_.IsRunning()) {
40 coalesce_timer_.Start(
41 TimeDelta::FromMilliseconds(kCommitIntervalMs), this,
42 &VisitedLinkEventListener::CommitVisitedLinks);
43 }
44 }
45
46 void VisitedLinkEventListener::Reset() {
47 pending_visited_links_.clear();
48 coalesce_timer_.Stop();
49
50 // Send to all RenderProcessHosts.
51 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator());
52 !i.IsAtEnd(); i.Advance()) {
53 i.GetCurrentValue()->ResetVisitedLinks();
54 }
55 }
56
57 void VisitedLinkEventListener::CommitVisitedLinks() {
58 // Send to all RenderProcessHosts.
59 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator());
60 !i.IsAtEnd(); i.Advance()) {
61 i.GetCurrentValue()->AddVisitedLinks(pending_visited_links_);
62 }
63
64 pending_visited_links_.clear();
65 }
OLDNEW
« no previous file with comments | « chrome/browser/visitedlink_event_listener.h ('k') | chrome/browser/visitedlink_master.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698