summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsammc <sammc@chromium.org>2016-09-21 07:30:42 (GMT)
committerCommit bot <commit-bot@chromium.org>2016-09-21 07:34:08 (GMT)
commitaa22276dd0feae03cfc4eaa11f1ddf432dc87b11 (patch)
treef18d6dd548c47996b8851e9174dc01ba7d13b52a
parent3191d5fe4e3c5778b72c7e3ff5a9ae37783d849d (diff)
downloadchromium-lkcr.tar.gz
chromium-lkcr.tar.xz
Convert visitedlink to use mojo.lkcr
BUG=577685 Review-Url: https://codereview.chromium.org/2048503002 Cr-Commit-Position: refs/heads/master@{#419998}
-rw-r--r--android_webview/browser/aw_browser_context.cc1
-rw-r--r--android_webview/renderer/aw_content_renderer_client.cc4
-rw-r--r--chrome/renderer/chrome_content_renderer_client.cc7
-rw-r--r--chrome/renderer/chrome_content_renderer_client.h5
-rw-r--r--chrome/renderer/chrome_render_thread_observer.cc12
-rw-r--r--chrome/renderer/chrome_render_thread_observer.h11
-rw-r--r--components/BUILD.gn2
-rw-r--r--components/visitedlink/DEPS4
-rw-r--r--components/visitedlink/browser/visitedlink_event_listener.cc70
-rw-r--r--components/visitedlink/browser/visitedlink_event_listener.h27
-rw-r--r--components/visitedlink/browser/visitedlink_master.cc159
-rw-r--r--components/visitedlink/browser/visitedlink_master.h29
-rw-r--r--components/visitedlink/common/BUILD.gn15
-rw-r--r--components/visitedlink/common/OWNERS4
-rw-r--r--components/visitedlink/common/visitedlink.mojom22
-rw-r--r--components/visitedlink/common/visitedlink_message_generator.cc40
-rw-r--r--components/visitedlink/common/visitedlink_message_generator.h7
-rw-r--r--components/visitedlink/common/visitedlink_messages.h32
-rw-r--r--components/visitedlink/renderer/visitedlink_slave.cc95
-rw-r--r--components/visitedlink/renderer/visitedlink_slave.h30
-rw-r--r--components/visitedlink/test/visitedlink_perftest.cc3
-rw-r--r--components/visitedlink/test/visitedlink_unittest.cc206
-rw-r--r--tools/ipc_fuzzer/message_lib/all_messages.h1
23 files changed, 390 insertions, 396 deletions
diff --git a/android_webview/browser/aw_browser_context.cc b/android_webview/browser/aw_browser_context.cc
index 26c4a12..d9af58b 100644
--- a/android_webview/browser/aw_browser_context.cc
+++ b/android_webview/browser/aw_browser_context.cc
@@ -17,6 +17,7 @@
#include "android_webview/common/aw_content_client.h"
#include "base/base_paths_android.h"
#include "base/bind.h"
+#include "base/files/file_util.h"
#include "base/path_service.h"
#include "components/autofill/core/common/autofill_pref_names.h"
#include "components/metrics/metrics_service.h"
diff --git a/android_webview/renderer/aw_content_renderer_client.cc b/android_webview/renderer/aw_content_renderer_client.cc
index 5a7b385..7d87db2 100644
--- a/android_webview/renderer/aw_content_renderer_client.cc
+++ b/android_webview/renderer/aw_content_renderer_client.cc
@@ -40,6 +40,7 @@
#include "net/base/escape.h"
#include "net/base/net_errors.h"
#include "services/shell/public/cpp/interface_provider.h"
+#include "services/shell/public/cpp/interface_registry.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebURL.h"
#include "third_party/WebKit/public/platform/WebURLError.h"
@@ -71,7 +72,8 @@ void AwContentRendererClient::RenderThreadStarted() {
thread->AddObserver(aw_render_thread_observer_.get());
visited_link_slave_.reset(new visitedlink::VisitedLinkSlave);
- thread->AddObserver(visited_link_slave_.get());
+ thread->GetInterfaceRegistry()->AddInterface(
+ visited_link_slave_->GetBindCallback());
blink::WebString content_scheme(base::ASCIIToUTF16(url::kContentScheme));
blink::WebSecurityPolicy::registerURLSchemeAsLocal(content_scheme);
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
index 1b05df6..e697090 100644
--- a/chrome/renderer/chrome_content_renderer_client.cc
+++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -362,7 +362,6 @@ void ChromeContentRendererClient::RenderThreadStarted() {
thread->AddObserver(spellcheck_.get());
}
#endif
- visited_link_slave_.reset(new visitedlink::VisitedLinkSlave());
#if defined(FULL_SAFE_BROWSING)
phishing_classifier_.reset(safe_browsing::PhishingClassifierFilter::Create());
#endif
@@ -378,7 +377,6 @@ void ChromeContentRendererClient::RenderThreadStarted() {
#if defined(FULL_SAFE_BROWSING)
thread->AddObserver(phishing_classifier_.get());
#endif
- thread->AddObserver(visited_link_slave_.get());
thread->AddObserver(prerender_dispatcher_.get());
thread->AddObserver(subresource_filter_ruleset_dealer_.get());
thread->AddObserver(SearchBouncer::GetInstance());
@@ -1163,11 +1161,12 @@ bool ChromeContentRendererClient::IsPrefetchOnly(
unsigned long long ChromeContentRendererClient::VisitedLinkHash(
const char* canonical_url, size_t length) {
- return visited_link_slave_->ComputeURLFingerprint(canonical_url, length);
+ return chrome_observer_->visited_link_slave()->ComputeURLFingerprint(
+ canonical_url, length);
}
bool ChromeContentRendererClient::IsLinkVisited(unsigned long long link_hash) {
- return visited_link_slave_->IsVisited(link_hash);
+ return chrome_observer_->visited_link_slave()->IsVisited(link_hash);
}
blink::WebPrescientNetworking*
diff --git a/chrome/renderer/chrome_content_renderer_client.h b/chrome/renderer/chrome_content_renderer_client.h
index 0061770..2a834f1 100644
--- a/chrome/renderer/chrome_content_renderer_client.h
+++ b/chrome/renderer/chrome_content_renderer_client.h
@@ -62,10 +62,6 @@ namespace subresource_filter {
class RulesetDealer;
}
-namespace visitedlink {
-class VisitedLinkSlave;
-}
-
namespace web_cache {
class WebCacheImpl;
}
@@ -240,7 +236,6 @@ class ChromeContentRendererClient : public content::ContentRendererClient {
#if defined(ENABLE_SPELLCHECK)
std::unique_ptr<SpellCheck> spellcheck_;
#endif
- std::unique_ptr<visitedlink::VisitedLinkSlave> visited_link_slave_;
std::unique_ptr<safe_browsing::PhishingClassifierFilter> phishing_classifier_;
std::unique_ptr<subresource_filter::RulesetDealer>
subresource_filter_ruleset_dealer_;
diff --git a/chrome/renderer/chrome_render_thread_observer.cc b/chrome/renderer/chrome_render_thread_observer.cc
index 486f019..817a4f6 100644
--- a/chrome/renderer/chrome_render_thread_observer.cc
+++ b/chrome/renderer/chrome_render_thread_observer.cc
@@ -37,6 +37,7 @@
#include "chrome/common/url_constants.h"
#include "chrome/renderer/content_settings_observer.h"
#include "chrome/renderer/security_filter_peer.h"
+#include "components/visitedlink/renderer/visitedlink_slave.h"
#include "content/public/child/resource_dispatcher_delegate.h"
#include "content/public/renderer/render_thread.h"
#include "content/public/renderer/render_view.h"
@@ -231,7 +232,9 @@ void CreateResourceUsageReporter(
bool ChromeRenderThreadObserver::is_incognito_process_ = false;
ChromeRenderThreadObserver::ChromeRenderThreadObserver()
- : field_trial_syncer_(this), weak_factory_(this) {
+ : field_trial_syncer_(this),
+ visited_link_slave_(new visitedlink::VisitedLinkSlave),
+ weak_factory_(this) {
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
@@ -261,6 +264,9 @@ ChromeRenderThreadObserver::ChromeRenderThreadObserver()
WebSecurityPolicy::registerURLSchemeAsNoAccess(native_scheme);
WebSecurityPolicy::registerURLSchemeAsNotAllowingJavascriptURLs(
native_scheme);
+
+ thread->GetInterfaceRegistry()->AddInterface(
+ visited_link_slave_->GetBindCallback());
}
ChromeRenderThreadObserver::~ChromeRenderThreadObserver() {}
@@ -279,6 +285,10 @@ bool ChromeRenderThreadObserver::OnControlMessageReceived(
return handled;
}
+void ChromeRenderThreadObserver::OnRenderProcessShutdown() {
+ visited_link_slave_.reset();
+}
+
void ChromeRenderThreadObserver::OnFieldTrialGroupFinalized(
const std::string& trial_name,
const std::string& group_name) {
diff --git a/chrome/renderer/chrome_render_thread_observer.h b/chrome/renderer/chrome_render_thread_observer.h
index d93aec0..3e377bb 100644
--- a/chrome/renderer/chrome_render_thread_observer.h
+++ b/chrome/renderer/chrome_render_thread_observer.h
@@ -27,6 +27,10 @@ namespace content {
class ResourceDispatcherDelegate;
}
+namespace visitedlink {
+class VisitedLinkSlave;
+}
+
// This class filters the incoming control messages (i.e. ones not destined for
// a RenderView) for Chrome specific messages that the content layer doesn't
// happen. If a few messages are related, they should probably have their own
@@ -43,6 +47,10 @@ class ChromeRenderThreadObserver : public content::RenderThreadObserver,
// |ChromeRenderThreadObserver|.
const RendererContentSettingRules* content_setting_rules() const;
+ visitedlink::VisitedLinkSlave* visited_link_slave() {
+ return visited_link_slave_.get();
+ }
+
private:
// Initializes field trial state change observation and notifies the browser
// of any field trials that might have already been activated.
@@ -50,6 +58,7 @@ class ChromeRenderThreadObserver : public content::RenderThreadObserver,
// content::RenderThreadObserver:
bool OnControlMessageReceived(const IPC::Message& message) override;
+ void OnRenderProcessShutdown() override;
// base::FieldTrialList::Observer:
void OnFieldTrialGroupFinalized(const std::string& trial_name,
@@ -68,6 +77,8 @@ class ChromeRenderThreadObserver : public content::RenderThreadObserver,
RendererContentSettingRules content_setting_rules_;
chrome_variations::ChildProcessFieldTrialSyncer field_trial_syncer_;
+ std::unique_ptr<visitedlink::VisitedLinkSlave> visited_link_slave_;
+
base::WeakPtrFactory<ChromeRenderThreadObserver> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(ChromeRenderThreadObserver);
diff --git a/components/BUILD.gn b/components/BUILD.gn
index fb25d30..698aa3d 100644
--- a/components/BUILD.gn
+++ b/components/BUILD.gn
@@ -482,9 +482,9 @@ if (!is_ios) {
deps = [
"//base",
"//base/test:test_support",
- "//base/test:test_support_perf",
"//components/visitedlink/browser",
"//content/test:test_support",
+ "//mojo/edk/test:run_all_perftests",
"//testing/gtest",
"//testing/perf",
"//url",
diff --git a/components/visitedlink/DEPS b/components/visitedlink/DEPS
index 1c40d98..e7d54f9 100644
--- a/components/visitedlink/DEPS
+++ b/components/visitedlink/DEPS
@@ -1,3 +1,5 @@
include_rules = [
- "+ipc",
+ "+mojo/public",
+ "+content/public/common",
+ "+services/shell/public",
]
diff --git a/components/visitedlink/browser/visitedlink_event_listener.cc b/components/visitedlink/browser/visitedlink_event_listener.cc
index dd9c9f7..37cdcd5 100644
--- a/components/visitedlink/browser/visitedlink_event_listener.cc
+++ b/components/visitedlink/browser/visitedlink_event_listener.cc
@@ -4,13 +4,14 @@
#include "components/visitedlink/browser/visitedlink_event_listener.h"
-#include "base/memory/shared_memory.h"
+#include "base/bind.h"
#include "components/visitedlink/browser/visitedlink_delegate.h"
-#include "components/visitedlink/common/visitedlink_messages.h"
+#include "components/visitedlink/common/visitedlink.mojom.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_widget_host.h"
+#include "services/shell/public/cpp/interface_provider.h"
using base::Time;
using base::TimeDelta;
@@ -19,7 +20,7 @@ using content::RenderWidgetHost;
namespace {
// The amount of time we wait to accumulate visited link additions.
-const int kCommitIntervalMs = 100;
+constexpr int kCommitIntervalMs = 100;
// Size of the buffer after which individual link updates deemed not warranted
// and the overall update should be used instead.
@@ -42,20 +43,18 @@ class VisitedLinkUpdater {
explicit VisitedLinkUpdater(int render_process_id)
: reset_needed_(false),
invalidate_hashes_(false),
- render_process_id_(render_process_id) {}
+ render_process_id_(render_process_id) {
+ content::RenderProcessHost::FromID(render_process_id)
+ ->GetRemoteInterfaces()
+ ->GetInterface(&sink_);
+ }
// Informs the renderer about a new visited link table.
- void SendVisitedLinkTable(base::SharedMemory* table_memory) {
- content::RenderProcessHost* process =
- content::RenderProcessHost::FromID(render_process_id_);
- if (!process)
- return; // Happens in tests
- base::SharedMemoryHandle handle_for_process;
- table_memory->ShareReadOnlyToProcess(process->GetHandle(),
- &handle_for_process);
- if (base::SharedMemory::IsHandleValid(handle_for_process))
- process->Send(new ChromeViewMsg_VisitedLink_NewTable(
- handle_for_process));
+ void SendVisitedLinkTable(mojo::SharedBufferHandle table) {
+ mojo::ScopedSharedBufferHandle client_table =
+ table.Clone(mojo::SharedBufferHandle::AccessMode::READ_ONLY);
+ if (client_table.is_valid())
+ sink_->UpdateVisitedLinks(std::move(client_table));
}
// Buffers |links| to update, but doesn't actually relay them.
@@ -98,7 +97,7 @@ class VisitedLinkUpdater {
return;
if (reset_needed_) {
- process->Send(new ChromeViewMsg_VisitedLink_Reset(invalidate_hashes_));
+ sink_->ResetVisitedLinks(invalidate_hashes_);
reset_needed_ = false;
invalidate_hashes_ = false;
return;
@@ -107,7 +106,7 @@ class VisitedLinkUpdater {
if (pending_.empty())
return;
- process->Send(new ChromeViewMsg_VisitedLink_Add(pending_));
+ sink_->AddVisitedLinks(pending_);
pending_.clear();
}
@@ -116,13 +115,13 @@ class VisitedLinkUpdater {
bool reset_needed_;
bool invalidate_hashes_;
int render_process_id_;
+ mojom::VisitedLinkNotificationSinkPtr sink_;
VisitedLinkCommon::Fingerprints pending_;
};
VisitedLinkEventListener::VisitedLinkEventListener(
- VisitedLinkMaster* master,
content::BrowserContext* browser_context)
- : master_(master),
+ : coalesce_timer_(&default_coalesce_timer_),
browser_context_(browser_context) {
registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED,
content::NotificationService::AllBrowserContextsAndSources());
@@ -137,8 +136,10 @@ VisitedLinkEventListener::~VisitedLinkEventListener() {
pending_visited_links_.clear();
}
-void VisitedLinkEventListener::NewTable(base::SharedMemory* table_memory) {
- if (!table_memory)
+void VisitedLinkEventListener::NewTable(mojo::SharedBufferHandle table) {
+ DCHECK(table.is_valid());
+ shared_memory_ = table.Clone(mojo::SharedBufferHandle::AccessMode::READ_ONLY);
+ if (!shared_memory_.is_valid())
return;
// Send to all RenderProcessHosts.
@@ -149,23 +150,24 @@ void VisitedLinkEventListener::NewTable(base::SharedMemory* table_memory) {
if (!process)
continue;
- i->second->SendVisitedLinkTable(table_memory);
+ i->second->SendVisitedLinkTable(shared_memory_.get());
}
}
void VisitedLinkEventListener::Add(VisitedLinkMaster::Fingerprint fingerprint) {
pending_visited_links_.push_back(fingerprint);
- if (!coalesce_timer_.IsRunning()) {
- coalesce_timer_.Start(FROM_HERE,
- TimeDelta::FromMilliseconds(kCommitIntervalMs), this,
- &VisitedLinkEventListener::CommitVisitedLinks);
+ if (!coalesce_timer_->IsRunning()) {
+ coalesce_timer_->Start(
+ FROM_HERE, TimeDelta::FromMilliseconds(kCommitIntervalMs),
+ base::Bind(&VisitedLinkEventListener::CommitVisitedLinks,
+ base::Unretained(this)));
}
}
void VisitedLinkEventListener::Reset(bool invalidate_hashes) {
pending_visited_links_.clear();
- coalesce_timer_.Stop();
+ coalesce_timer_->Stop();
for (Updaters::iterator i = updaters_.begin(); i != updaters_.end(); ++i) {
i->second->AddReset(invalidate_hashes);
@@ -173,6 +175,11 @@ void VisitedLinkEventListener::Reset(bool invalidate_hashes) {
}
}
+void VisitedLinkEventListener::SetCoalesceTimerForTest(
+ base::Timer* coalesce_timer_override) {
+ coalesce_timer_ = coalesce_timer_override;
+}
+
void VisitedLinkEventListener::CommitVisitedLinks() {
// Send to all RenderProcessHosts.
for (Updaters::iterator i = updaters_.begin(); i != updaters_.end(); ++i) {
@@ -195,13 +202,12 @@ void VisitedLinkEventListener::Observe(
return;
// Happens on browser start up.
- if (!master_->shared_memory())
+ if (!shared_memory_.is_valid())
return;
- updaters_[process->GetID()] =
- make_linked_ptr(new VisitedLinkUpdater(process->GetID()));
- updaters_[process->GetID()]->SendVisitedLinkTable(
- master_->shared_memory());
+ updaters_[process->GetID()].reset(
+ new VisitedLinkUpdater(process->GetID()));
+ updaters_[process->GetID()]->SendVisitedLinkTable(shared_memory_.get());
break;
}
case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: {
diff --git a/components/visitedlink/browser/visitedlink_event_listener.h b/components/visitedlink/browser/visitedlink_event_listener.h
index 7439471..15b4dd8 100644
--- a/components/visitedlink/browser/visitedlink_event_listener.h
+++ b/components/visitedlink/browser/visitedlink_event_listener.h
@@ -6,18 +6,14 @@
#define COMPONENTS_VISITEDLINK_BROWSER_VISITEDLINK_EVENT_LISTENER_H_
#include <map>
+#include <memory>
#include "base/macros.h"
-#include "base/memory/linked_ptr.h"
#include "base/timer/timer.h"
#include "components/visitedlink/browser/visitedlink_master.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
-namespace base {
-class SharedMemory;
-}
-
namespace content {
class BrowserContext;
}
@@ -32,14 +28,17 @@ class VisitedLinkUpdater;
class VisitedLinkEventListener : public VisitedLinkMaster::Listener,
public content::NotificationObserver {
public:
- VisitedLinkEventListener(VisitedLinkMaster* master,
- content::BrowserContext* browser_context);
+ explicit VisitedLinkEventListener(content::BrowserContext* browser_context);
~VisitedLinkEventListener() override;
- void NewTable(base::SharedMemory* table_memory) override;
+ void NewTable(mojo::SharedBufferHandle table) override;
void Add(VisitedLinkMaster::Fingerprint fingerprint) override;
void Reset(bool invalidate_hashes) override;
+ // Sets a custom timer to use for coalescing events for testing.
+ // |coalesce_timer_override| must outlive this.
+ void SetCoalesceTimerForTest(base::Timer* coalesce_timer_override);
+
private:
void CommitVisitedLinks();
@@ -48,16 +47,22 @@ class VisitedLinkEventListener : public VisitedLinkMaster::Listener,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
- base::OneShotTimer coalesce_timer_;
+ // The default Timer to use for coalescing events. This should not be used
+ // directly to allow overriding it in tests. Instead, |coalesce_timer_|
+ // should be used.
+ base::OneShotTimer default_coalesce_timer_;
+ // A pointer to either |default_coalesce_timer_| or to an override set using
+ // SetCoalesceTimerForTest(). This does not own the timer.
+ base::Timer* coalesce_timer_;
VisitedLinkCommon::Fingerprints pending_visited_links_;
content::NotificationRegistrar registrar_;
// Map between renderer child ids and their VisitedLinkUpdater.
- typedef std::map<int, linked_ptr<VisitedLinkUpdater> > Updaters;
+ typedef std::map<int, std::unique_ptr<VisitedLinkUpdater>> Updaters;
Updaters updaters_;
- VisitedLinkMaster* master_;
+ mojo::ScopedSharedBufferHandle shared_memory_;
// Used to filter RENDERER_PROCESS_CREATED notifications to renderers that
// belong to this BrowserContext.
diff --git a/components/visitedlink/browser/visitedlink_master.cc b/components/visitedlink/browser/visitedlink_master.cc
index 792c750..0447c15 100644
--- a/components/visitedlink/browser/visitedlink_master.cc
+++ b/components/visitedlink/browser/visitedlink_master.cc
@@ -16,6 +16,7 @@
#include "base/files/scoped_file.h"
#include "base/logging.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/rand_util.h"
#include "base/strings/string_util.h"
@@ -62,7 +63,8 @@ namespace {
// It is not necessary to generate a cryptographically strong random string,
// only that it be reasonably different for different users.
void GenerateSalt(uint8_t salt[LINK_SALT_LENGTH]) {
- DCHECK_EQ(LINK_SALT_LENGTH, 8) << "This code assumes the length of the salt";
+ static_assert(LINK_SALT_LENGTH == 8,
+ "This code assumes the length of the salt");
uint64_t randval = base::RandUint64();
memcpy(salt, &randval, 8);
}
@@ -123,15 +125,15 @@ void AsyncClose(FILE** file) {
struct VisitedLinkMaster::LoadFromFileResult
: public base::RefCountedThreadSafe<LoadFromFileResult> {
LoadFromFileResult(base::ScopedFILE file,
- std::unique_ptr<base::SharedMemory> shared_memory,
- Fingerprint* hash_table,
+ mojo::ScopedSharedBufferHandle shared_memory,
+ mojo::ScopedSharedBufferMapping hash_table,
int32_t num_entries,
int32_t used_count,
uint8_t salt[LINK_SALT_LENGTH]);
base::ScopedFILE file;
- std::unique_ptr<base::SharedMemory> shared_memory;
- Fingerprint* hash_table;
+ mojo::ScopedSharedBufferHandle shared_memory;
+ mojo::ScopedSharedBufferMapping hash_table;
int32_t num_entries;
int32_t used_count;
uint8_t salt[LINK_SALT_LENGTH];
@@ -145,14 +147,14 @@ struct VisitedLinkMaster::LoadFromFileResult
VisitedLinkMaster::LoadFromFileResult::LoadFromFileResult(
base::ScopedFILE file,
- std::unique_ptr<base::SharedMemory> shared_memory,
- Fingerprint* hash_table,
+ mojo::ScopedSharedBufferHandle shared_memory,
+ mojo::ScopedSharedBufferMapping hash_table,
int32_t num_entries,
int32_t used_count,
uint8_t salt[LINK_SALT_LENGTH])
: file(std::move(file)),
shared_memory(std::move(shared_memory)),
- hash_table(hash_table),
+ hash_table(std::move(hash_table)),
num_entries(num_entries),
used_count(used_count) {
memcpy(this->salt, salt, LINK_SALT_LENGTH);
@@ -224,7 +226,7 @@ VisitedLinkMaster::VisitedLinkMaster(content::BrowserContext* browser_context,
bool persist_to_disk)
: browser_context_(browser_context),
delegate_(delegate),
- listener_(new VisitedLinkEventListener(this, browser_context)),
+ listener_(base::MakeUnique<VisitedLinkEventListener>(browser_context)),
persist_to_disk_(persist_to_disk),
table_is_loading_from_file_(false),
weak_ptr_factory_(this) {
@@ -277,7 +279,6 @@ VisitedLinkMaster::~VisitedLinkMaster() {
void VisitedLinkMaster::InitMembers() {
file_ = NULL;
- shared_memory_ = NULL;
shared_memory_serial_ = 0;
used_items_ = 0;
table_size_override_ = 0;
@@ -294,6 +295,9 @@ bool VisitedLinkMaster::Init() {
if (!CreateURLTable(DefaultTableSize()))
return false;
+ if (shared_memory_.is_valid())
+ listener_->NewTable(shared_memory_.get());
+
#ifndef NDEBUG
DebugValidate();
#endif
@@ -662,19 +666,20 @@ bool VisitedLinkMaster::LoadApartFromFile(
return false; // Header isn't valid.
// Allocate and read the table.
- std::unique_ptr<base::SharedMemory> shared_memory;
- VisitedLinkCommon::Fingerprint* hash_table;
+ mojo::ScopedSharedBufferHandle shared_memory;
+ mojo::ScopedSharedBufferMapping hash_table;
if (!CreateApartURLTable(num_entries, salt, &shared_memory, &hash_table))
return false;
- if (!ReadFromFile(file_closer.get(), kFileHeaderSize, hash_table,
+ if (!ReadFromFile(file_closer.get(), kFileHeaderSize,
+ GetHashTableFromMapping(hash_table),
num_entries * sizeof(Fingerprint))) {
return false;
}
- *load_from_file_result =
- new LoadFromFileResult(std::move(file_closer), std::move(shared_memory),
- hash_table, num_entries, used_count, salt);
+ *load_from_file_result = new LoadFromFileResult(
+ std::move(file_closer), std::move(shared_memory), std::move(hash_table),
+ num_entries, used_count, salt);
return true;
}
@@ -715,9 +720,9 @@ void VisitedLinkMaster::OnTableLoadComplete(
DCHECK(load_from_file_result.get());
// Delete the previous table.
- DCHECK(shared_memory_);
- delete shared_memory_;
- shared_memory_ = nullptr;
+ DCHECK(shared_memory_.is_valid());
+ shared_memory_.reset();
+ hash_table_mapping_.reset();
// Assign the open file.
DCHECK(!file_);
@@ -726,11 +731,12 @@ void VisitedLinkMaster::OnTableLoadComplete(
*file_ = load_from_file_result->file.release();
// Assign the loaded table.
- DCHECK(load_from_file_result->shared_memory.get());
+ DCHECK(load_from_file_result->shared_memory.is_valid());
DCHECK(load_from_file_result->hash_table);
memcpy(salt_, load_from_file_result->salt, LINK_SALT_LENGTH);
- shared_memory_ = load_from_file_result->shared_memory.release();
- hash_table_ = load_from_file_result->hash_table;
+ shared_memory_ = std::move(load_from_file_result->shared_memory);
+ hash_table_mapping_ = std::move(load_from_file_result->hash_table);
+ hash_table_ = GetHashTableFromMapping(hash_table_mapping_);
table_length_ = load_from_file_result->num_entries;
used_items_ = load_from_file_result->used_count;
@@ -739,7 +745,7 @@ void VisitedLinkMaster::OnTableLoadComplete(
#endif
// Send an update notification to all child processes.
- listener_->NewTable(shared_memory_);
+ listener_->NewTable(shared_memory_.get());
if (!added_since_load_.empty() || !deleted_since_load_.empty()) {
// Resize the table if the table doesn't have enough capacity.
@@ -859,11 +865,12 @@ bool VisitedLinkMaster::GetDatabaseFileName(base::FilePath* filename) {
// Initializes the shared memory structure. The salt should already be filled
// in so that it can be written to the shared memory
bool VisitedLinkMaster::CreateURLTable(int32_t num_entries) {
- std::unique_ptr<base::SharedMemory> shared_memory;
- VisitedLinkCommon::Fingerprint* hash_table;
+ mojo::ScopedSharedBufferHandle shared_memory;
+ mojo::ScopedSharedBufferMapping hash_table;
if (CreateApartURLTable(num_entries, salt_, &shared_memory, &hash_table)) {
- shared_memory_ = shared_memory.release();
- hash_table_ = hash_table;
+ shared_memory_ = std::move(shared_memory);
+ hash_table_mapping_ = std::move(hash_table);
+ hash_table_ = GetHashTableFromMapping(hash_table_mapping_);
table_length_ = num_entries;
used_items_ = 0;
return true;
@@ -876,8 +883,8 @@ bool VisitedLinkMaster::CreateURLTable(int32_t num_entries) {
bool VisitedLinkMaster::CreateApartURLTable(
int32_t num_entries,
const uint8_t salt[LINK_SALT_LENGTH],
- std::unique_ptr<base::SharedMemory>* shared_memory,
- VisitedLinkCommon::Fingerprint** hash_table) {
+ mojo::ScopedSharedBufferHandle* shared_memory,
+ mojo::ScopedSharedBufferMapping* hash_table) {
DCHECK(salt);
DCHECK(shared_memory);
DCHECK(hash_table);
@@ -887,41 +894,38 @@ bool VisitedLinkMaster::CreateApartURLTable(
num_entries * sizeof(Fingerprint) + sizeof(SharedHeader);
// Create the shared memory object.
- std::unique_ptr<base::SharedMemory> sh_mem(new base::SharedMemory());
- if (!sh_mem)
+ mojo::ScopedSharedBufferHandle shared_buffer =
+ mojo::SharedBufferHandle::Create(alloc_size);
+ if (!shared_buffer.is_valid())
return false;
-
- base::SharedMemoryCreateOptions options;
- options.size = alloc_size;
- options.share_read_only = true;
-
- if (!sh_mem->Create(options) || !sh_mem->Map(alloc_size))
+ mojo::ScopedSharedBufferMapping hash_table_mapping =
+ shared_buffer->Map(alloc_size);
+ if (!hash_table_mapping)
return false;
- memset(sh_mem->memory(), 0, alloc_size);
+ memset(hash_table_mapping.get(), 0, alloc_size);
// Save the header for other processes to read.
- SharedHeader* header = static_cast<SharedHeader*>(sh_mem->memory());
+ SharedHeader* header = static_cast<SharedHeader*>(hash_table_mapping.get());
header->length = num_entries;
memcpy(header->salt, salt, LINK_SALT_LENGTH);
- // Our table pointer is just the data immediately following the size.
- *hash_table = reinterpret_cast<Fingerprint*>(
- static_cast<char*>(sh_mem->memory()) + sizeof(SharedHeader));
-
- *shared_memory = std::move(sh_mem);
+ *shared_memory = std::move(shared_buffer);
+ *hash_table = std::move(hash_table_mapping);
return true;
}
bool VisitedLinkMaster::BeginReplaceURLTable(int32_t num_entries) {
- base::SharedMemory *old_shared_memory = shared_memory_;
- Fingerprint* old_hash_table = hash_table_;
+ mojo::ScopedSharedBufferHandle old_shared_memory = std::move(shared_memory_);
+ mojo::ScopedSharedBufferMapping old_hash_table_mapping =
+ std::move(hash_table_mapping_);
int32_t old_table_length = table_length_;
if (!CreateURLTable(num_entries)) {
// Try to put back the old state.
- shared_memory_ = old_shared_memory;
- hash_table_ = old_hash_table;
+ shared_memory_ = std::move(old_shared_memory);
+ hash_table_mapping_ = std::move(old_hash_table_mapping);
+ hash_table_ = GetHashTableFromMapping(hash_table_mapping_);
table_length_ = old_table_length;
return false;
}
@@ -934,10 +938,8 @@ bool VisitedLinkMaster::BeginReplaceURLTable(int32_t num_entries) {
}
void VisitedLinkMaster::FreeURLTable() {
- if (shared_memory_) {
- delete shared_memory_;
- shared_memory_ = NULL;
- }
+ shared_memory_.reset();
+ hash_table_mapping_.reset();
if (!persist_to_disk_ || !file_)
return;
PostIOTask(FROM_HERE, base::Bind(&AsyncClose, file_));
@@ -970,34 +972,37 @@ bool VisitedLinkMaster::ResizeTableIfNecessary() {
}
void VisitedLinkMaster::ResizeTable(int32_t new_size) {
- DCHECK(shared_memory_ && shared_memory_->memory() && hash_table_);
+ DCHECK(shared_memory_.is_valid() && hash_table_mapping_);
shared_memory_serial_++;
#ifndef NDEBUG
DebugValidate();
#endif
- base::SharedMemory* old_shared_memory = shared_memory_;
- Fingerprint* old_hash_table = hash_table_;
+ mojo::ScopedSharedBufferMapping old_hash_table_mapping =
+ std::move(hash_table_mapping_);
int32_t old_table_length = table_length_;
- if (!BeginReplaceURLTable(new_size))
+ if (!BeginReplaceURLTable(new_size)) {
+ hash_table_mapping_ = std::move(old_hash_table_mapping);
+ hash_table_ = GetHashTableFromMapping(hash_table_mapping_);
return;
-
- // Now we have two tables, our local copy which is the old one, and the new
- // one loaded into this object where we need to copy the data.
- for (int32_t i = 0; i < old_table_length; i++) {
- Fingerprint cur = old_hash_table[i];
- if (cur)
- AddFingerprint(cur, false);
}
-
- // On error unmapping, just forget about it since we can't do anything
- // else to release it.
- delete old_shared_memory;
+ {
+ Fingerprint* old_hash_table =
+ GetHashTableFromMapping(old_hash_table_mapping);
+ // Now we have two tables, our local copy which is the old one, and the new
+ // one loaded into this object where we need to copy the data.
+ for (int32_t i = 0; i < old_table_length; i++) {
+ Fingerprint cur = old_hash_table[i];
+ if (cur)
+ AddFingerprint(cur, false);
+ }
+ }
+ old_hash_table_mapping.reset();
// Send an update notification to all child processes so they read the new
// table.
- listener_->NewTable(shared_memory_);
+ listener_->NewTable(shared_memory_.get());
#ifndef NDEBUG
DebugValidate();
@@ -1065,16 +1070,9 @@ void VisitedLinkMaster::OnTableRebuildComplete(
// Replace the old table with a new blank one.
shared_memory_serial_++;
- // We are responsible for freeing it AFTER it has been replaced if
- // replacement succeeds.
- base::SharedMemory* old_shared_memory = shared_memory_;
-
int new_table_size = NewTableSizeForCount(
static_cast<int>(fingerprints.size() + added_since_rebuild_.size()));
if (BeginReplaceURLTable(new_table_size)) {
- // Free the old table.
- delete old_shared_memory;
-
// Add the stored fingerprints to the hash table.
for (const auto& fingerprint : fingerprints)
AddFingerprint(fingerprint, false);
@@ -1092,7 +1090,7 @@ void VisitedLinkMaster::OnTableRebuildComplete(
deleted_since_rebuild_.clear();
// Send an update notification to all child processes.
- listener_->NewTable(shared_memory_);
+ listener_->NewTable(shared_memory_.get());
// All tabs which was loaded when table was being rebuilt
// invalidate their links again.
listener_->Reset(false);
@@ -1201,4 +1199,13 @@ void VisitedLinkMaster::TableBuilder::OnCompleteMainThread() {
master_->OnTableRebuildComplete(success_, fingerprints_);
}
+// static
+VisitedLinkCommon::Fingerprint* VisitedLinkMaster::GetHashTableFromMapping(
+ const mojo::ScopedSharedBufferMapping& hash_table_mapping) {
+ DCHECK(hash_table_mapping);
+ // Our table pointer is just the data immediately following the header.
+ return reinterpret_cast<Fingerprint*>(
+ static_cast<char*>(hash_table_mapping.get()) + sizeof(SharedHeader));
+}
+
} // namespace visitedlink
diff --git a/components/visitedlink/browser/visitedlink_master.h b/components/visitedlink/browser/visitedlink_master.h
index f7f4ca5..6eb5097 100644
--- a/components/visitedlink/browser/visitedlink_master.h
+++ b/components/visitedlink/browser/visitedlink_master.h
@@ -18,11 +18,11 @@
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/shared_memory.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/sequenced_worker_pool.h"
#include "build/build_config.h"
#include "components/visitedlink/common/visitedlink_common.h"
+#include "mojo/public/cpp/system/buffer.h"
#if defined(OS_WIN)
#include <windows.h>
@@ -58,7 +58,7 @@ class VisitedLinkMaster : public VisitedLinkCommon {
// Called when link coloring database has been created or replaced. The
// argument is the new table handle.
- virtual void NewTable(base::SharedMemory*) = 0;
+ virtual void NewTable(mojo::SharedBufferHandle table) = 0;
// Called when new link has been added. The argument is the fingerprint
// (hash) of the link.
@@ -105,7 +105,9 @@ class VisitedLinkMaster : public VisitedLinkCommon {
// object won't work.
bool Init();
- base::SharedMemory* shared_memory() { return shared_memory_; }
+ const mojo::SharedBufferHandle& shared_memory() {
+ return shared_memory_.get();
+ }
// Adds a URL to the table.
void AddURL(const GURL& url);
@@ -320,11 +322,10 @@ class VisitedLinkMaster : public VisitedLinkCommon {
// Structure is filled with 0s and shared header with salt. The result of
// allocation is saved into |shared_memory| and |hash_table| points to the
// beginning of Fingerprint table in |shared_memory|.
- static bool CreateApartURLTable(
- int32_t num_entries,
- const uint8_t salt[LINK_SALT_LENGTH],
- std::unique_ptr<base::SharedMemory>* shared_memory,
- VisitedLinkCommon::Fingerprint** hash_table);
+ static bool CreateApartURLTable(int32_t num_entries,
+ const uint8_t salt[LINK_SALT_LENGTH],
+ mojo::ScopedSharedBufferHandle* shared_memory,
+ mojo::ScopedSharedBufferMapping* hash_table);
// A wrapper for CreateURLTable, this will allocate a new table, initialized
// to empty. The caller is responsible for saving the shared memory pointer
@@ -390,6 +391,11 @@ class VisitedLinkMaster : public VisitedLinkCommon {
return hash - 1;
}
+ // Returns a pointer to the start of the hash table, given the mapping
+ // containing the hash table.
+ static Fingerprint* GetHashTableFromMapping(
+ const mojo::ScopedSharedBufferMapping& hash_table_mapping);
+
// Reference to the browser context that this object belongs to
// (it knows the path to where the data is stored)
content::BrowserContext* browser_context_;
@@ -435,7 +441,12 @@ class VisitedLinkMaster : public VisitedLinkCommon {
bool persist_to_disk_;
// Shared memory consists of a SharedHeader followed by the table.
- base::SharedMemory *shared_memory_;
+ mojo::ScopedSharedBufferHandle shared_memory_;
+
+ // A mapping of the table including the SharedHeader.
+ // GetHashTableFromMapping() can be used to obtain a pointer to the hash table
+ // contained in this mapping.
+ mojo::ScopedSharedBufferMapping hash_table_mapping_;
// When we generate new tables, we increment the serial number of the
// shared memory object.
diff --git a/components/visitedlink/common/BUILD.gn b/components/visitedlink/common/BUILD.gn
index ae0f12d..b131dd1 100644
--- a/components/visitedlink/common/BUILD.gn
+++ b/components/visitedlink/common/BUILD.gn
@@ -2,19 +2,28 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("//mojo/public/tools/bindings/mojom.gni")
+
static_library("common") {
sources = [
"visitedlink_common.cc",
"visitedlink_common.h",
- "visitedlink_message_generator.cc",
- "visitedlink_message_generator.h",
- "visitedlink_messages.h",
+ ]
+ public_deps = [
+ ":interfaces",
]
deps = [
+ ":interfaces",
"//base",
"//content/public/common",
"//ipc",
"//url",
]
}
+
+mojom("interfaces") {
+ sources = [
+ "visitedlink.mojom",
+ ]
+}
diff --git a/components/visitedlink/common/OWNERS b/components/visitedlink/common/OWNERS
index 42444bc..08850f4 100644
--- a/components/visitedlink/common/OWNERS
+++ b/components/visitedlink/common/OWNERS
@@ -1,2 +1,2 @@
-per-file *_messages*.h=set noparent
-per-file *_messages*.h=file://ipc/SECURITY_OWNERS
+per-file *.mojom=set noparent
+per-file *.mojom=file://ipc/SECURITY_OWNERS
diff --git a/components/visitedlink/common/visitedlink.mojom b/components/visitedlink/common/visitedlink.mojom
new file mode 100644
index 0000000..9a8ce86
--- /dev/null
+++ b/components/visitedlink/common/visitedlink.mojom
@@ -0,0 +1,22 @@
+// Copyright 2016 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.
+
+module visitedlink.mojom;
+
+interface VisitedLinkNotificationSink {
+ // Notification that the visited link database has been replaced. It has one
+ // SharedMemoryHandle argument consisting of the table handle.
+ UpdateVisitedLinks(handle<shared_buffer> table_handle);
+
+ // Notification that one or more links have been added and the link coloring
+ // state for the given hashes must be re-calculated.
+ AddVisitedLinks(array<uint64> link_hashes);
+
+ // Notification that one or more history items have been deleted, which at
+ // this point means that all link coloring state must be re-calculated.
+ // |invalidate_cached_hashes| is used to inform renderer process to invalidate
+ // cached visited links hashes. The flag is needed because the salt will
+ // change after loading the visitedlink table from the database file.
+ ResetVisitedLinks(bool invalidate_cached_hashes);
+};
diff --git a/components/visitedlink/common/visitedlink_message_generator.cc b/components/visitedlink/common/visitedlink_message_generator.cc
deleted file mode 100644
index 9ab374e..0000000
--- a/components/visitedlink/common/visitedlink_message_generator.cc
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) 2013 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.
-
-// Get basic type definitions.
-#define IPC_MESSAGE_IMPL
-#include "components/visitedlink/common/visitedlink_message_generator.h"
-
-// Generate constructors.
-#include "ipc/struct_constructor_macros.h"
-#include "components/visitedlink/common/visitedlink_message_generator.h"
-
-// Generate destructors.
-#include "ipc/struct_destructor_macros.h"
-#include "components/visitedlink/common/visitedlink_message_generator.h"
-
-// Generate param traits size methods.
-#include "ipc/param_traits_size_macros.h"
-namespace IPC {
-#include "components/visitedlink/common/visitedlink_message_generator.h"
-} // namespace IPC
-
-// Generate param traits write methods.
-#include "ipc/param_traits_write_macros.h"
-namespace IPC {
-#include "components/visitedlink/common/visitedlink_message_generator.h"
-} // namespace IPC
-
-// Generate param traits read methods.
-#include "ipc/param_traits_read_macros.h"
-namespace IPC {
-#include "components/visitedlink/common/visitedlink_message_generator.h"
-} // namespace IPC
-
-// Generate param traits log methods.
-#include "ipc/param_traits_log_macros.h"
-namespace IPC {
-#include "components/visitedlink/common/visitedlink_message_generator.h"
-} // namespace IPC
-
diff --git a/components/visitedlink/common/visitedlink_message_generator.h b/components/visitedlink/common/visitedlink_message_generator.h
deleted file mode 100644
index e4a496b..0000000
--- a/components/visitedlink/common/visitedlink_message_generator.h
+++ /dev/null
@@ -1,7 +0,0 @@
-// Copyright (c) 2013 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.
-
-// Multiply-included file, no traditional include guard.
-
-#include "components/visitedlink/common/visitedlink_messages.h"
diff --git a/components/visitedlink/common/visitedlink_messages.h b/components/visitedlink/common/visitedlink_messages.h
deleted file mode 100644
index f2c1d88..0000000
--- a/components/visitedlink/common/visitedlink_messages.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) 2013 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.
-
-// Multiply-included file, no traditional include guard.
-
-#include <stdint.h>
-
-#include <vector>
-
-#include "base/memory/shared_memory.h"
-#include "content/public/common/common_param_traits_macros.h"
-#include "ipc/ipc_message_macros.h"
-
-#define IPC_MESSAGE_START VisitedLinkMsgStart
-
-// History system notification that the visited link database has been
-// replaced. It has one SharedMemoryHandle argument consisting of the table
-// handle. This handle is valid in the context of the renderer
-IPC_MESSAGE_CONTROL1(ChromeViewMsg_VisitedLink_NewTable,
- base::SharedMemoryHandle)
-
-// History system notification that a link has been added and the link
-// coloring state for the given hash must be re-calculated.
-IPC_MESSAGE_CONTROL1(ChromeViewMsg_VisitedLink_Add, std::vector<uint64_t>)
-
-// History system notification that one or more history items have been
-// deleted, which at this point means that all link coloring state must be
-// re-calculated. Boolean flag is used to inform renderer process to invalidate
-// cached visited links hashes. The flag is needed because the salt will change
-// after loading the visitedlink table from the database file.
-IPC_MESSAGE_CONTROL1(ChromeViewMsg_VisitedLink_Reset, bool)
diff --git a/components/visitedlink/renderer/visitedlink_slave.cc b/components/visitedlink/renderer/visitedlink_slave.cc
index c159aba..bbc9b5d 100644
--- a/components/visitedlink/renderer/visitedlink_slave.cc
+++ b/components/visitedlink/renderer/visitedlink_slave.cc
@@ -8,88 +8,79 @@
#include <stdint.h>
#include "base/logging.h"
-#include "base/memory/shared_memory.h"
-#include "components/visitedlink/common/visitedlink_messages.h"
#include "third_party/WebKit/public/web/WebView.h"
using blink::WebView;
namespace visitedlink {
-VisitedLinkSlave::VisitedLinkSlave() : shared_memory_(NULL) {}
+VisitedLinkSlave::VisitedLinkSlave() : binding_(this), weak_factory_(this) {}
VisitedLinkSlave::~VisitedLinkSlave() {
FreeTable();
}
-bool VisitedLinkSlave::OnControlMessageReceived(const IPC::Message& message) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(VisitedLinkSlave, message)
- IPC_MESSAGE_HANDLER(ChromeViewMsg_VisitedLink_NewTable,
- OnUpdateVisitedLinks)
- IPC_MESSAGE_HANDLER(ChromeViewMsg_VisitedLink_Add, OnAddVisitedLinks)
- IPC_MESSAGE_HANDLER(ChromeViewMsg_VisitedLink_Reset, OnResetVisitedLinks)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
+base::Callback<void(mojom::VisitedLinkNotificationSinkRequest)>
+VisitedLinkSlave::GetBindCallback() {
+ return base::Bind(&VisitedLinkSlave::Bind, weak_factory_.GetWeakPtr());
}
-// This function's job is to initialize the table with the given
-// shared memory handle. This memory is mapped into the process.
-void VisitedLinkSlave::OnUpdateVisitedLinks(base::SharedMemoryHandle table) {
- DCHECK(base::SharedMemory::IsHandleValid(table)) << "Bad table handle";
- // since this function may be called again to change the table, we may need
- // to free old objects
+// Initializes the table with the given shared memory handle. This memory is
+// mapped into the process.
+void VisitedLinkSlave::UpdateVisitedLinks(
+ mojo::ScopedSharedBufferHandle table) {
+ DCHECK(table.is_valid()) << "Bad table handle";
+ // Since this function may be called again to change the table, we may need
+ // to free old objects.
FreeTable();
- DCHECK(shared_memory_ == NULL && hash_table_ == NULL);
-
- // create the shared memory object
- shared_memory_ = new base::SharedMemory(table, true);
- if (!shared_memory_)
- return;
+ DCHECK(hash_table_ == NULL);
+
+ int32_t table_len = 0;
+ {
+ // Map the header into our process so we can see how long the rest is,
+ // and set the salt.
+ mojo::ScopedSharedBufferMapping header_memory =
+ table->Map(sizeof(SharedHeader));
+ if (!header_memory)
+ return;
+
+ SharedHeader* header = static_cast<SharedHeader*>(header_memory.get());
+ table_len = header->length;
+ memcpy(salt_, header->salt, sizeof(salt_));
+ }
- // map the header into our process so we can see how long the rest is,
- // and set the salt
- if (!shared_memory_->Map(sizeof(SharedHeader)))
+ // Now we know the length, so map the table contents.
+ table_mapping_ =
+ table->MapAtOffset(table_len * sizeof(Fingerprint), sizeof(SharedHeader));
+ if (!table_mapping_)
return;
- SharedHeader* header =
- static_cast<SharedHeader*>(shared_memory_->memory());
- DCHECK(header);
- int32_t table_len = header->length;
- memcpy(salt_, header->salt, sizeof(salt_));
- shared_memory_->Unmap();
-
- // now do the whole table because we know the length
- if (!shared_memory_->Map(sizeof(SharedHeader) +
- table_len * sizeof(Fingerprint))) {
- shared_memory_->Close();
- return;
- }
- // commit the data
- DCHECK(shared_memory_->memory());
- hash_table_ = reinterpret_cast<Fingerprint*>(
- static_cast<char*>(shared_memory_->memory()) + sizeof(SharedHeader));
+ // Commit the data.
+ hash_table_ = reinterpret_cast<Fingerprint*>(table_mapping_.get());
table_length_ = table_len;
}
-void VisitedLinkSlave::OnAddVisitedLinks(
- const VisitedLinkSlave::Fingerprints& fingerprints) {
+void VisitedLinkSlave::AddVisitedLinks(
+ const std::vector<VisitedLinkSlave::Fingerprint>& fingerprints) {
for (size_t i = 0; i < fingerprints.size(); ++i)
WebView::updateVisitedLinkState(fingerprints[i]);
}
-void VisitedLinkSlave::OnResetVisitedLinks(bool invalidate_hashes) {
+void VisitedLinkSlave::ResetVisitedLinks(bool invalidate_hashes) {
WebView::resetVisitedLinkState(invalidate_hashes);
}
void VisitedLinkSlave::FreeTable() {
- if (shared_memory_) {
- delete shared_memory_;
- shared_memory_ = NULL;
- }
+ if (!hash_table_)
+ return;
+
+ table_mapping_.reset();
hash_table_ = NULL;
table_length_ = 0;
}
+void VisitedLinkSlave::Bind(mojom::VisitedLinkNotificationSinkRequest request) {
+ binding_.Bind(std::move(request));
+}
+
} // namespace visitedlink
diff --git a/components/visitedlink/renderer/visitedlink_slave.h b/components/visitedlink/renderer/visitedlink_slave.h
index 31cae89..bbf0cfd 100644
--- a/components/visitedlink/renderer/visitedlink_slave.h
+++ b/components/visitedlink/renderer/visitedlink_slave.h
@@ -7,33 +7,41 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/shared_memory.h"
+#include "base/memory/weak_ptr.h"
+#include "components/visitedlink/common/visitedlink.mojom.h"
#include "components/visitedlink/common/visitedlink_common.h"
-#include "content/public/renderer/render_thread_observer.h"
+#include "mojo/public/cpp/bindings/binding.h"
+#include "mojo/public/cpp/system/buffer.h"
namespace visitedlink {
// Reads the link coloring database provided by the master. There can be any
// number of slaves reading the same database.
class VisitedLinkSlave : public VisitedLinkCommon,
- public content::RenderThreadObserver {
+ public mojom::VisitedLinkNotificationSink {
public:
VisitedLinkSlave();
~VisitedLinkSlave() override;
- // RenderThreadObserver implementation.
- bool OnControlMessageReceived(const IPC::Message& message) override;
+ base::Callback<void(mojom::VisitedLinkNotificationSinkRequest)>
+ GetBindCallback();
- // Message handlers.
- void OnUpdateVisitedLinks(base::SharedMemoryHandle table);
- void OnAddVisitedLinks(const VisitedLinkSlave::Fingerprints& fingerprints);
- void OnResetVisitedLinks(bool invalidate_hashes);
+ // mojom::VisitedLinkNotificationSink overrides.
+ void UpdateVisitedLinks(mojo::ScopedSharedBufferHandle table) override;
+ void AddVisitedLinks(
+ const std::vector<VisitedLinkSlave::Fingerprint>& fingerprints) override;
+ void ResetVisitedLinks(bool invalidate_hashes) override;
private:
void FreeTable();
- // shared memory consists of a SharedHeader followed by the table
- base::SharedMemory* shared_memory_;
+ void Bind(mojom::VisitedLinkNotificationSinkRequest request);
+
+ mojo::ScopedSharedBufferMapping table_mapping_;
+
+ mojo::Binding<mojom::VisitedLinkNotificationSink> binding_;
+
+ base::WeakPtrFactory<VisitedLinkSlave> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(VisitedLinkSlave);
};
diff --git a/components/visitedlink/test/visitedlink_perftest.cc b/components/visitedlink/test/visitedlink_perftest.cc
index 4c805e5..5bf7b60 100644
--- a/components/visitedlink/test/visitedlink_perftest.cc
+++ b/components/visitedlink/test/visitedlink_perftest.cc
@@ -8,7 +8,6 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
-#include "base/memory/shared_memory.h"
#include "base/strings/stringprintf.h"
#include "base/test/perf_log.h"
#include "base/test/perf_time_logger.h"
@@ -41,7 +40,7 @@ GURL TestURL(const char* prefix, int i) {
class DummyVisitedLinkEventListener : public VisitedLinkMaster::Listener {
public:
DummyVisitedLinkEventListener() {}
- void NewTable(base::SharedMemory* table) override {}
+ void NewTable(mojo::SharedBufferHandle) override {}
void Add(VisitedLinkCommon::Fingerprint) override {}
void Reset(bool invalidate_hashes) override {}
};
diff --git a/components/visitedlink/test/visitedlink_unittest.cc b/components/visitedlink/test/visitedlink_unittest.cc
index 32e9c04..ce7aa1f 100644
--- a/components/visitedlink/test/visitedlink_unittest.cc
+++ b/components/visitedlink/test/visitedlink_unittest.cc
@@ -10,20 +10,22 @@
#include <string>
#include <vector>
+#include "base/callback_helpers.h"
#include "base/files/file_util.h"
#include "base/location.h"
#include "base/macros.h"
-#include "base/memory/shared_memory.h"
+#include "base/memory/ptr_util.h"
#include "base/process/process_handle.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
+#include "base/timer/mock_timer.h"
#include "components/visitedlink/browser/visitedlink_delegate.h"
#include "components/visitedlink/browser/visitedlink_event_listener.h"
#include "components/visitedlink/browser/visitedlink_master.h"
-#include "components/visitedlink/common/visitedlink_messages.h"
+#include "components/visitedlink/common/visitedlink.mojom.h"
#include "components/visitedlink/renderer/visitedlink_slave.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
@@ -33,6 +35,7 @@
#include "content/public/test/test_browser_thread_bundle.h"
#include "content/public/test/test_renderer_host.h"
#include "content/public/test/test_utils.h"
+#include "services/shell/public/cpp/interface_provider.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
@@ -115,13 +118,11 @@ class TrackingVisitedLinkEventListener : public VisitedLinkMaster::Listener {
completely_reset_count_(0),
add_count_(0) {}
- void NewTable(base::SharedMemory* table) override {
- if (table) {
+ void NewTable(mojo::SharedBufferHandle table) override {
+ if (table.is_valid()) {
for (std::vector<VisitedLinkSlave>::size_type i = 0;
i < g_slaves.size(); i++) {
- base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle();
- table->ShareToProcess(base::GetCurrentProcessHandle(), &new_handle);
- g_slaves[i]->OnUpdateVisitedLinks(new_handle);
+ g_slaves[i]->UpdateVisitedLinks(table.Clone());
}
}
}
@@ -201,10 +202,7 @@ class VisitedLinkTest : public testing::Test {
// Create a slave database.
VisitedLinkSlave slave;
- base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle();
- master_->shared_memory()->ShareToProcess(
- base::GetCurrentProcessHandle(), &new_handle);
- slave.OnUpdateVisitedLinks(new_handle);
+ slave.UpdateVisitedLinks(master_->shared_memory().Clone());
g_slaves.push_back(&slave);
bool found;
@@ -332,10 +330,7 @@ TEST_F(VisitedLinkTest, DeleteAll) {
{
VisitedLinkSlave slave;
- base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle();
- master_->shared_memory()->ShareToProcess(
- base::GetCurrentProcessHandle(), &new_handle);
- slave.OnUpdateVisitedLinks(new_handle);
+ slave.UpdateVisitedLinks(master_->shared_memory().Clone());
g_slaves.push_back(&slave);
// Add the test URLs.
@@ -379,10 +374,7 @@ TEST_F(VisitedLinkTest, Resizing) {
// ...and a slave
VisitedLinkSlave slave;
- base::SharedMemoryHandle new_handle = base::SharedMemory::NULLHandle();
- master_->shared_memory()->ShareToProcess(
- base::GetCurrentProcessHandle(), &new_handle);
- slave.OnUpdateVisitedLinks(new_handle);
+ slave.UpdateVisitedLinks(master_->shared_memory().Clone());
g_slaves.push_back(&slave);
int32_t used_count = master_->GetUsedCount();
@@ -527,30 +519,56 @@ TEST_F(VisitedLinkTest, Listener) {
EXPECT_EQ(1, listener->completely_reset_count());
}
-class VisitCountingContext : public content::TestBrowserContext {
+class VisitCountingContext : public mojom::VisitedLinkNotificationSink {
public:
VisitCountingContext()
: add_count_(0),
add_event_count_(0),
reset_event_count_(0),
completely_reset_event_count_(0),
- new_table_count_(0) {}
+ new_table_count_(0),
+ binding_(this) {}
- void CountAddEvent(int by) {
- add_count_ += by;
- add_event_count_++;
+ void Bind(mojo::ScopedMessagePipeHandle handle) {
+ binding_.Bind(mojo::MakeRequest<mojom::VisitedLinkNotificationSink>(
+ std::move(handle)));
}
- void CountResetEvent() {
- reset_event_count_++;
+ void WaitForUpdate() {
+ base::RunLoop run_loop;
+ quit_closure_ = run_loop.QuitClosure();
+ run_loop.Run();
}
- void CountCompletelyResetEvent() {
- completely_reset_event_count_++;
+ void WaitForNoUpdate() { binding_.FlushForTesting(); }
+
+ mojo::Binding<mojom::VisitedLinkNotificationSink>& binding() {
+ return binding_;
}
- void CountNewTable() {
+ void NotifyUpdate() {
+ if (!quit_closure_.is_null())
+ base::ResetAndReturn(&quit_closure_).Run();
+ }
+
+ void UpdateVisitedLinks(
+ mojo::ScopedSharedBufferHandle table_handle) override {
new_table_count_++;
+ NotifyUpdate();
+ }
+
+ void AddVisitedLinks(const std::vector<uint64_t>& link_hashes) override {
+ add_count_ += link_hashes.size();
+ add_event_count_++;
+ NotifyUpdate();
+ }
+
+ void ResetVisitedLinks(bool invalidate_cached_hashes) override {
+ if (invalidate_cached_hashes)
+ completely_reset_event_count_++;
+ else
+ reset_event_count_++;
+ NotifyUpdate();
}
int add_count() const { return add_count_; }
@@ -567,14 +585,23 @@ class VisitCountingContext : public content::TestBrowserContext {
int reset_event_count_;
int completely_reset_event_count_;
int new_table_count_;
+
+ base::Closure quit_closure_;
+ mojo::Binding<mojom::VisitedLinkNotificationSink> binding_;
};
// Stub out as little as possible, borrowing from RenderProcessHost.
class VisitRelayingRenderProcessHost : public MockRenderProcessHost {
public:
explicit VisitRelayingRenderProcessHost(
- content::BrowserContext* browser_context)
- : MockRenderProcessHost(browser_context), widgets_(0) {
+ content::BrowserContext* browser_context,
+ VisitCountingContext* context)
+ : MockRenderProcessHost(browser_context), widgets_(0) {
+ SetRemoteInterfaces(base::MakeUnique<shell::InterfaceProvider>());
+ shell::InterfaceProvider::TestApi test_api(GetRemoteInterfaces());
+ test_api.SetBinderForName(
+ mojom::VisitedLinkNotificationSink::Name_,
+ base::Bind(&VisitCountingContext::Bind, base::Unretained(context)));
content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDERER_PROCESS_CREATED,
content::Source<RenderProcessHost>(this),
@@ -591,32 +618,6 @@ class VisitRelayingRenderProcessHost : public MockRenderProcessHost {
void WidgetHidden() override { widgets_--; }
int VisibleWidgetCount() const override { return widgets_; }
- bool Send(IPC::Message* msg) override {
- VisitCountingContext* counting_context =
- static_cast<VisitCountingContext*>(
- GetBrowserContext());
-
- if (msg->type() == ChromeViewMsg_VisitedLink_Add::ID) {
- base::PickleIterator iter(*msg);
- std::vector<uint64_t> fingerprints;
- CHECK(IPC::ReadParam(msg, &iter, &fingerprints));
- counting_context->CountAddEvent(fingerprints.size());
- } else if (msg->type() == ChromeViewMsg_VisitedLink_Reset::ID) {
- base::PickleIterator iter(*msg);
- bool invalidate_hashes;
- CHECK(IPC::ReadParam(msg, &iter, &invalidate_hashes));
- if (invalidate_hashes)
- counting_context->CountCompletelyResetEvent();
- else
- counting_context->CountResetEvent();
- } else if (msg->type() == ChromeViewMsg_VisitedLink_NewTable::ID) {
- counting_context->CountNewTable();
- }
-
- delete msg;
- return true;
- }
-
private:
int widgets_;
@@ -626,15 +627,17 @@ class VisitRelayingRenderProcessHost : public MockRenderProcessHost {
class VisitedLinkRenderProcessHostFactory
: public content::RenderProcessHostFactory {
public:
- VisitedLinkRenderProcessHostFactory()
- : content::RenderProcessHostFactory() {}
+ VisitedLinkRenderProcessHostFactory() : context_(new VisitCountingContext) {}
content::RenderProcessHost* CreateRenderProcessHost(
content::BrowserContext* browser_context,
content::SiteInstance* site_instance) const override {
- return new VisitRelayingRenderProcessHost(browser_context);
+ return new VisitRelayingRenderProcessHost(browser_context, context_.get());
}
+ VisitCountingContext* context() { return context_.get(); }
+
private:
+ std::unique_ptr<VisitCountingContext> context_;
DISALLOW_COPY_AND_ASSIGN(VisitedLinkRenderProcessHostFactory);
};
@@ -656,39 +659,30 @@ class VisitedLinkEventsTest : public content::RenderViewHostTestHarness {
}
content::BrowserContext* CreateBrowserContext() override {
- VisitCountingContext* context = new VisitCountingContext();
+ content::BrowserContext* context = new content::TestBrowserContext();
CreateVisitedLinkMaster(context);
return context;
}
- VisitCountingContext* context() {
- return static_cast<VisitCountingContext*>(browser_context());
- }
+ VisitCountingContext* context() { return vc_rph_factory_.context(); }
VisitedLinkMaster* master() const {
return master_.get();
}
- void WaitForCoalescence() {
- // Let the timer fire.
- //
- // TODO(ajwong): This is horrid! What is the right synchronization method?
- base::RunLoop run_loop;
- base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE, run_loop.QuitClosure(),
- base::TimeDelta::FromMilliseconds(110));
- run_loop.Run();
- }
-
protected:
void CreateVisitedLinkMaster(content::BrowserContext* browser_context) {
+ timer_.reset(new base::MockTimer(false, false));
master_.reset(new VisitedLinkMaster(browser_context, &delegate_, true));
+ static_cast<VisitedLinkEventListener*>(master_->GetListener())
+ ->SetCoalesceTimerForTest(timer_.get());
master_->Init();
}
VisitedLinkRenderProcessHostFactory vc_rph_factory_;
TestVisitedLinkDelegate delegate_;
+ std::unique_ptr<base::MockTimer> timer_;
std::unique_ptr<VisitedLinkMaster> master_;
};
@@ -696,8 +690,6 @@ TEST_F(VisitedLinkEventsTest, Coalescence) {
// Waiting complete rebuild the table.
content::RunAllBlockingPoolTasksUntilIdle();
- WaitForCoalescence();
-
// After rebuild table expect reset event.
EXPECT_EQ(1, context()->reset_event_count());
@@ -708,13 +700,10 @@ TEST_F(VisitedLinkEventsTest, Coalescence) {
master()->AddURL(GURL("http://chromium.org/"));
// Just for kicks, add a duplicate URL. This shouldn't increase the resulting
master()->AddURL(GURL("http://acidtests.org/"));
+ ASSERT_TRUE(timer_->IsRunning());
+ timer_->Fire();
- // Make sure that coalescing actually occurs. There should be no links or
- // events received by the renderer.
- EXPECT_EQ(0, context()->add_count());
- EXPECT_EQ(0, context()->add_event_count());
-
- WaitForCoalescence();
+ context()->WaitForUpdate();
// We now should have 3 entries added in 1 event.
EXPECT_EQ(3, context()->add_count());
@@ -725,7 +714,9 @@ TEST_F(VisitedLinkEventsTest, Coalescence) {
master()->AddURL(GURL("http://webkit.org/"));
master()->AddURL(GURL("http://acid3.acidtests.org/"));
- WaitForCoalescence();
+ ASSERT_TRUE(timer_->IsRunning());
+ timer_->Fire();
+ context()->WaitForUpdate();
// We should have 6 entries added in 2 events.
EXPECT_EQ(6, context()->add_count());
@@ -733,8 +724,8 @@ TEST_F(VisitedLinkEventsTest, Coalescence) {
// Test whether duplicate entries produce add events.
master()->AddURL(GURL("http://acidtests.org/"));
-
- WaitForCoalescence();
+ EXPECT_FALSE(timer_->IsRunning());
+ context()->WaitForNoUpdate();
// We should have no change in results.
EXPECT_EQ(6, context()->add_count());
@@ -742,9 +733,10 @@ TEST_F(VisitedLinkEventsTest, Coalescence) {
// Ensure that the coalescing does not resume after resetting.
master()->AddURL(GURL("http://build.chromium.org/"));
+ EXPECT_TRUE(timer_->IsRunning());
master()->DeleteAllURLs();
-
- WaitForCoalescence();
+ EXPECT_FALSE(timer_->IsRunning());
+ context()->WaitForNoUpdate();
// We should have no change in results except for one new reset event.
EXPECT_EQ(6, context()->add_count());
@@ -759,8 +751,6 @@ TEST_F(VisitedLinkEventsTest, Basics) {
// Waiting complete rebuild the table.
content::RunAllBlockingPoolTasksUntilIdle();
- WaitForCoalescence();
-
// After rebuild table expect reset event.
EXPECT_EQ(1, context()->reset_event_count());
@@ -768,8 +758,9 @@ TEST_F(VisitedLinkEventsTest, Basics) {
master()->AddURL(GURL("http://acidtests.org/"));
master()->AddURL(GURL("http://google.com/"));
master()->AddURL(GURL("http://chromium.org/"));
-
- WaitForCoalescence();
+ ASSERT_TRUE(timer_->IsRunning());
+ timer_->Fire();
+ context()->WaitForUpdate();
// We now should have 1 add event.
EXPECT_EQ(1, context()->add_event_count());
@@ -777,7 +768,8 @@ TEST_F(VisitedLinkEventsTest, Basics) {
master()->DeleteAllURLs();
- WaitForCoalescence();
+ EXPECT_FALSE(timer_->IsRunning());
+ context()->WaitForNoUpdate();
// We should have no change in add results, plus one new reset event.
EXPECT_EQ(1, context()->add_event_count());
@@ -791,8 +783,6 @@ TEST_F(VisitedLinkEventsTest, TabVisibility) {
// Waiting complete rebuild the table.
content::RunAllBlockingPoolTasksUntilIdle();
- WaitForCoalescence();
-
// After rebuild table expect reset event.
EXPECT_EQ(1, context()->reset_event_count());
@@ -803,8 +793,9 @@ TEST_F(VisitedLinkEventsTest, TabVisibility) {
master()->AddURL(GURL("http://acidtests.org/"));
master()->AddURL(GURL("http://google.com/"));
master()->AddURL(GURL("http://chromium.org/"));
-
- WaitForCoalescence();
+ ASSERT_TRUE(timer_->IsRunning());
+ timer_->Fire();
+ context()->WaitForNoUpdate();
// We shouldn't have any events.
EXPECT_EQ(0, context()->add_event_count());
@@ -812,6 +803,7 @@ TEST_F(VisitedLinkEventsTest, TabVisibility) {
// Simulate the tab becoming active.
RenderViewHostTester::For(rvh())->SimulateWasShown();
+ context()->WaitForUpdate();
// We should now have 3 add events, still no reset events.
EXPECT_EQ(1, context()->add_event_count());
@@ -824,7 +816,9 @@ TEST_F(VisitedLinkEventsTest, TabVisibility) {
for (int i = 0; i < 100; i++)
master()->AddURL(TestURL(i));
- WaitForCoalescence();
+ ASSERT_TRUE(timer_->IsRunning());
+ timer_->Fire();
+ context()->WaitForNoUpdate();
// Again, no change in events until tab is active.
EXPECT_EQ(1, context()->add_event_count());
@@ -832,6 +826,8 @@ TEST_F(VisitedLinkEventsTest, TabVisibility) {
// Activate the tab.
RenderViewHostTester::For(rvh())->SimulateWasShown();
+ EXPECT_FALSE(timer_->IsRunning());
+ context()->WaitForUpdate();
// We should have only one more reset event.
EXPECT_EQ(1, context()->add_event_count());
@@ -841,22 +837,22 @@ TEST_F(VisitedLinkEventsTest, TabVisibility) {
// Tests that VisitedLink ignores renderer process creation notification for a
// different context.
TEST_F(VisitedLinkEventsTest, IgnoreRendererCreationFromDifferentContext) {
- VisitCountingContext different_context;
- VisitRelayingRenderProcessHost different_process_host(&different_context);
+ content::TestBrowserContext different_context;
+ VisitCountingContext counting_context;
+ VisitRelayingRenderProcessHost different_process_host(&different_context,
+ &counting_context);
content::NotificationService::current()->Notify(
content::NOTIFICATION_RENDERER_PROCESS_CREATED,
content::Source<content::RenderProcessHost>(&different_process_host),
content::NotificationService::NoDetails());
- WaitForCoalescence();
-
- EXPECT_EQ(0, different_context.new_table_count());
+ EXPECT_FALSE(counting_context.binding().is_bound());
}
class VisitedLinkCompletelyResetEventTest : public VisitedLinkEventsTest {
public:
content::BrowserContext* CreateBrowserContext() override {
- VisitCountingContext* context = new VisitCountingContext();
+ content::BrowserContext* context = new content::TestBrowserContext();
CreateVisitedLinkFile(context);
CreateVisitedLinkMaster(context);
return context;
@@ -882,7 +878,7 @@ TEST_F(VisitedLinkCompletelyResetEventTest, LoadTable) {
// Waiting complete loading the table.
content::RunAllBlockingPoolTasksUntilIdle();
- WaitForCoalescence();
+ context()->binding().FlushForTesting();
// After load table expect completely reset event.
EXPECT_EQ(1, context()->completely_reset_event_count());
diff --git a/tools/ipc_fuzzer/message_lib/all_messages.h b/tools/ipc_fuzzer/message_lib/all_messages.h
index 13e93d1a..a6424f1 100644
--- a/tools/ipc_fuzzer/message_lib/all_messages.h
+++ b/tools/ipc_fuzzer/message_lib/all_messages.h
@@ -24,6 +24,5 @@
#include "components/pdf/common/pdf_message_generator.h"
#include "components/spellcheck/common/spellcheck_message_generator.h"
#include "components/tracing/common/tracing_messages.h"
-#include "components/visitedlink/common/visitedlink_message_generator.h"
#include "content/common/all_messages.h"
#include "extensions/common/extension_message_generator.h"