diff options
-rw-r--r-- | chrome/browser/extensions/user_script_master.cc | 4 | ||||
-rw-r--r-- | chrome/browser/extensions/user_script_master_unittest.cc | 12 | ||||
-rw-r--r-- | chrome/browser/renderer_host/browser_render_process_host.cc | 6 | ||||
-rw-r--r-- | chrome/common/notification_type.h | 2 | ||||
-rw-r--r-- | chrome/common/render_messages_internal.h | 3 | ||||
-rw-r--r-- | chrome/renderer/render_thread.cc | 2 |
6 files changed, 12 insertions, 17 deletions
diff --git a/chrome/browser/extensions/user_script_master.cc b/chrome/browser/extensions/user_script_master.cc index e1ed5db..5051cd6 100644 --- a/chrome/browser/extensions/user_script_master.cc +++ b/chrome/browser/extensions/user_script_master.cc @@ -188,8 +188,6 @@ static void LoadLoneScripts(UserScriptList* lone_scripts) { // Pickle user scripts and return pointer to the shared memory. static base::SharedMemory* Serialize(UserScriptList& scripts) { - if (scripts.empty()) - return NULL; // Nothing to serialize Pickle pickle; pickle.WriteSize(scripts.size()); for (size_t i = 0; i < scripts.size(); i++) { @@ -303,7 +301,7 @@ void UserScriptMaster::NewScriptsAvailable(base::SharedMemory* handle) { shared_memory_.swap(handle_deleter); NotificationService::current()->Notify( - NotificationType::USER_SCRIPTS_LOADED, + NotificationType::USER_SCRIPTS_UPDATED, NotificationService::AllSources(), Details<base::SharedMemory>(handle)); } diff --git a/chrome/browser/extensions/user_script_master_unittest.cc b/chrome/browser/extensions/user_script_master_unittest.cc index 3b92d24..e7c4206 100644 --- a/chrome/browser/extensions/user_script_master_unittest.cc +++ b/chrome/browser/extensions/user_script_master_unittest.cc @@ -37,7 +37,7 @@ class UserScriptMasterTest : public testing::Test, file_util::CreateDirectory(script_dir_); // Register for all user script notifications. - registrar_.Add(this, NotificationType::USER_SCRIPTS_LOADED, + registrar_.Add(this, NotificationType::USER_SCRIPTS_UPDATED, NotificationService::AllSources()); } @@ -50,7 +50,7 @@ class UserScriptMasterTest : public testing::Test, virtual void Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { - DCHECK(type == NotificationType::USER_SCRIPTS_LOADED); + DCHECK(type == NotificationType::USER_SCRIPTS_UPDATED); shared_memory_ = Details<base::SharedMemory>(details).ptr(); if (MessageLoop::current() == &message_loop_) @@ -69,10 +69,8 @@ class UserScriptMasterTest : public testing::Test, base::SharedMemory* shared_memory_; }; -// Test that we *don't* get spurious notifications. +// Test that we get notified even when there are no scripts. TEST_F(UserScriptMasterTest, NoScripts) { - // Set shared_memory_ to something non-NULL, so we can check it became NULL. - shared_memory_ = reinterpret_cast<base::SharedMemory*>(1); scoped_refptr<UserScriptMaster> master( new UserScriptMaster(MessageLoop::current(), script_dir_)); @@ -80,9 +78,7 @@ TEST_F(UserScriptMasterTest, NoScripts) { message_loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask); message_loop_.Run(); - // There were no scripts in the script dir, so we shouldn't have gotten - // a notification. - ASSERT_EQ(NULL, shared_memory_); + ASSERT_TRUE(shared_memory_ != NULL); } // TODO(shess): Disabled on Linux because of missing DirectoryWatcher. diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index 4624ff6..8cee7ae 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -136,7 +136,7 @@ BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile) this, &BrowserRenderProcessHost::ClearTransportDIBCache)) { widget_helper_ = new RenderWidgetHelper(); - registrar_.Add(this, NotificationType::USER_SCRIPTS_LOADED, + registrar_.Add(this, NotificationType::USER_SCRIPTS_UPDATED, NotificationService::AllSources()); if (run_renderer_in_process()) { @@ -483,7 +483,7 @@ void BrowserRenderProcessHost::SendUserScriptsUpdate( &handle_for_process); DCHECK(r); if (base::SharedMemory::IsHandleValid(handle_for_process)) { - channel_->Send(new ViewMsg_UserScripts_NewScripts(handle_for_process)); + channel_->Send(new ViewMsg_UserScripts_UpdatedScripts(handle_for_process)); } } @@ -793,7 +793,7 @@ void BrowserRenderProcessHost::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { switch (type.value) { - case NotificationType::USER_SCRIPTS_LOADED: { + case NotificationType::USER_SCRIPTS_UPDATED: { base::SharedMemory* shared_memory = Details<base::SharedMemory>(details).ptr(); if (shared_memory) { diff --git a/chrome/common/notification_type.h b/chrome/common/notification_type.h index d26d47e..1bd3bff 100644 --- a/chrome/common/notification_type.h +++ b/chrome/common/notification_type.h @@ -545,7 +545,7 @@ class NotificationType { // Sent when there are new user scripts available. The details are a // pointer to SharedMemory containing the new scripts. - USER_SCRIPTS_LOADED, + USER_SCRIPTS_UPDATED, // Extensions -------------------------------------------------------------- diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 187f59e..6b5a5d7 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -157,7 +157,8 @@ IPC_BEGIN_MESSAGES(View) // Notification that the user scripts have been updated. It has one // SharedMemoryHandle argument consisting of the pickled script data. This // handle is valid in the context of the renderer. - IPC_MESSAGE_CONTROL1(ViewMsg_UserScripts_NewScripts, base::SharedMemoryHandle) + IPC_MESSAGE_CONTROL1(ViewMsg_UserScripts_UpdatedScripts, + base::SharedMemoryHandle) // Sent when the user wants to search for a word on the page (find in page). IPC_MESSAGE_ROUTED3(ViewMsg_Find, diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index c69cb1b..af81a02 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -215,7 +215,7 @@ void RenderThread::OnControlMessageReceived(const IPC::Message& msg) { OnGetRendererHistograms) IPC_MESSAGE_HANDLER(ViewMsg_GetCacheResourceStats, OnGetCacheResourceStats) - IPC_MESSAGE_HANDLER(ViewMsg_UserScripts_NewScripts, + IPC_MESSAGE_HANDLER(ViewMsg_UserScripts_UpdatedScripts, OnUpdateUserScripts) // TODO(rafaelw): create an ExtensionDispatcher that handles extension // messages seperates their handling from the RenderThread. |