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

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

Issue 113591: Fix Acid3 Test 48: LINKTEST, Chromium side.... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: Made waiting more bearable. Created 11 years, 5 months 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
« 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')
Property Changes:
Added: svn:eol-style
+ LF
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 #include "chrome/common/render_messages.h"
10
11 using base::Time;
12 using base::TimeDelta;
13
14 // The amount of time we wait to accumulate visited link additions.
15 static const int kCommitIntervalMs = 100;
16
17 void VisitedLinkEventListener::NewTable(base::SharedMemory* table_memory) {
18 if (!table_memory)
19 return;
20
21 // Send to all RenderProcessHosts.
22 for (RenderProcessHost::iterator i = RenderProcessHost::begin();
23 i != RenderProcessHost::end(); ++i) {
24 if (!i->second->HasConnection())
25 continue;
26
27 base::SharedMemoryHandle new_table;
28 base::ProcessHandle process = i->second->process().handle();
29 if (!process) {
30 // process can be null if it's started with the --single-process flag.
31 process = base::Process::Current().handle();
32 }
33
34 table_memory->ShareToProcess(process, &new_table);
35 i->second->Send(new ViewMsg_VisitedLink_NewTable(new_table));
36 }
37 }
38
39 void VisitedLinkEventListener::Add(VisitedLinkMaster::Fingerprint fingerprint) {
40 pending_visited_links_.push_back(fingerprint);
41
42 if (!coalesce_timer_.IsRunning()) {
43 coalesce_timer_.Start(
44 TimeDelta::FromMilliseconds(kCommitIntervalMs), this,
45 &VisitedLinkEventListener::CommitVisitedLinks);
46 }
47 }
48
49 void VisitedLinkEventListener::Reset() {
50 pending_visited_links_.clear();
51 coalesce_timer_.Stop();
52
53 // Send to all RenderProcessHosts.
54 for (RenderProcessHost::iterator i = RenderProcessHost::begin();
55 i != RenderProcessHost::end(); ++i) {
56 i->second->ResetVisitedLinks();
57 }
58 }
59
60 void VisitedLinkEventListener::CommitVisitedLinks() {
61 // Send to all RenderProcessHosts.
62 for (RenderProcessHost::iterator i = RenderProcessHost::begin();
63 i != RenderProcessHost::end(); ++i) {
64 i->second->AddVisitedLinks(pending_visited_links_);
65 }
66
67 pending_visited_links_.clear();
68 }
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