summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-25 23:49:14 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-25 23:49:14 +0000
commit8243c186a0fc264d187a41981402711b672ec54b (patch)
treea7df28594621125b3ec7a9a3b1d0d9fcdc7a4c0c /chrome
parent4fc7baba80b0df795c3438bd351029645a33d609 (diff)
downloadchromium_src-8243c186a0fc264d187a41981402711b672ec54b.zip
chromium_src-8243c186a0fc264d187a41981402711b672ec54b.tar.gz
chromium_src-8243c186a0fc264d187a41981402711b672ec54b.tar.bz2
Add DCHECK to make sure that RenderProcessHost::FromID (which is also called by RenderViewHost::FromID) is called on the UI thread. Also fix NotificationObjectProxy using RenderProcessHost on the IO thread.
Review URL: http://codereview.chromium.org/6599008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76119 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/notifications/notification_object_proxy.cc56
-rw-r--r--chrome/browser/notifications/notification_object_proxy.h5
-rw-r--r--chrome/browser/renderer_host/web_cache_manager_unittest.cc6
-rw-r--r--chrome/browser/translate/translate_manager_browsertest.cc6
-rw-r--r--chrome/browser/visitedlink/visitedlink_unittest.cc4
5 files changed, 30 insertions, 47 deletions
diff --git a/chrome/browser/notifications/notification_object_proxy.cc b/chrome/browser/notifications/notification_object_proxy.cc
index a973473..b81dc95 100644
--- a/chrome/browser/notifications/notification_object_proxy.cc
+++ b/chrome/browser/notifications/notification_object_proxy.cc
@@ -19,42 +19,22 @@ NotificationObjectProxy::NotificationObjectProxy(int process_id, int route_id,
}
void NotificationObjectProxy::Display() {
- if (worker_) {
- // TODO(johnnyg): http://crbug.com/23065 Worker support coming soon.
- NOTREACHED();
- } else {
- DeliverMessage(new ViewMsg_PostDisplayToNotificationObject(
- route_id_, notification_id_));
- }
+ Send(new ViewMsg_PostDisplayToNotificationObject(
+ route_id_, notification_id_));
}
void NotificationObjectProxy::Error() {
- if (worker_) {
- // TODO(johnnyg): http://crbug.com/23065 Worker support coming soon.
- NOTREACHED();
- } else {
- DeliverMessage(new ViewMsg_PostErrorToNotificationObject(
- route_id_, notification_id_, string16()));
- }
+ Send(new ViewMsg_PostErrorToNotificationObject(
+ route_id_, notification_id_, string16()));
}
void NotificationObjectProxy::Close(bool by_user) {
- if (worker_) {
- // TODO(johnnyg): http://crbug.com/23065 Worker support coming soon.
- NOTREACHED();
- } else {
- DeliverMessage(new ViewMsg_PostCloseToNotificationObject(
- route_id_, notification_id_, by_user));
- }
+ Send(new ViewMsg_PostCloseToNotificationObject(
+ route_id_, notification_id_, by_user));
}
void NotificationObjectProxy::Click() {
- if (worker_) {
- NOTREACHED();
- } else {
- DeliverMessage(new ViewMsg_PostClickToNotificationObject(
- route_id_, notification_id_));
- }
+ Send(new ViewMsg_PostClickToNotificationObject(route_id_, notification_id_));
}
std::string NotificationObjectProxy::id() const {
@@ -63,23 +43,17 @@ std::string NotificationObjectProxy::id() const {
}
-void NotificationObjectProxy::DeliverMessage(IPC::Message* message) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(this, &NotificationObjectProxy::Send, message));
-}
-
-// Deferred method which runs on the IO thread and sends a message to the
-// proxied notification, routing it through the correct host in the browser.
void NotificationObjectProxy::Send(IPC::Message* message) {
- // Take ownership of the message; ownership will pass to a host if possible.
- scoped_ptr<IPC::Message> owned_message(message);
+ if (worker_) {
+ // TODO(johnnyg): http://crbug.com/23065 Worker support coming soon.
+ NOTREACHED();
+ return;
+ }
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
RenderViewHost* host = RenderViewHost::FromID(process_id_, route_id_);
if (host) {
- // Pass ownership to the host.
- host->Send(owned_message.release());
+ host->Send(message);
+ } else {
+ delete message;
}
}
diff --git a/chrome/browser/notifications/notification_object_proxy.h b/chrome/browser/notifications/notification_object_proxy.h
index c3cb777..13c4054 100644
--- a/chrome/browser/notifications/notification_object_proxy.h
+++ b/chrome/browser/notifications/notification_object_proxy.h
@@ -39,10 +39,7 @@ class NotificationObjectProxy
virtual ~NotificationObjectProxy() {}
private:
- // Called on UI thread to schedule a message for sending.
- void DeliverMessage(IPC::Message* message);
-
- // Called via Task on IO thread to actually send a message to a notification.
+ // Called on UI thread to send a message.
void Send(IPC::Message* message);
// Callback information to find the JS Notification object where it lives.
diff --git a/chrome/browser/renderer_host/web_cache_manager_unittest.cc b/chrome/browser/renderer_host/web_cache_manager_unittest.cc
index 3f33f1a..11b5b13 100644
--- a/chrome/browser/renderer_host/web_cache_manager_unittest.cc
+++ b/chrome/browser/renderer_host/web_cache_manager_unittest.cc
@@ -6,6 +6,7 @@
#include "base/message_loop.h"
#include "chrome/browser/renderer_host/web_cache_manager.h"
+#include "content/browser/browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
using base::Time;
@@ -23,6 +24,10 @@ class WebCacheManagerTest : public testing::Test {
static const WebCache::UsageStats kStats;
static const WebCache::UsageStats kStats2;
+ WebCacheManagerTest()
+ : ui_thread_(BrowserThread::UI, &message_loop_) {
+ }
+
// Thunks to access protected members of WebCacheManager
static std::map<int, WebCacheManager::RendererInfo>& stats(
WebCacheManager* h) {
@@ -88,6 +93,7 @@ class WebCacheManagerTest : public testing::Test {
private:
WebCacheManager manager_;
MessageLoop message_loop_;
+ BrowserThread ui_thread_;
};
// static
diff --git a/chrome/browser/translate/translate_manager_browsertest.cc b/chrome/browser/translate/translate_manager_browsertest.cc
index d8031ce..20213fc 100644
--- a/chrome/browser/translate/translate_manager_browsertest.cc
+++ b/chrome/browser/translate/translate_manager_browsertest.cc
@@ -22,6 +22,7 @@
#include "chrome/common/net/test_url_fetcher_factory.h"
#include "chrome/test/testing_browser_process.h"
#include "chrome/test/testing_profile.h"
+#include "content/browser/browser_thread.h"
#include "content/browser/renderer_host/mock_render_process_host.h"
#include "content/browser/renderer_host/test_render_view_host.h"
#include "content/browser/tab_contents/navigation_controller.h"
@@ -40,7 +41,9 @@ using WebKit::WebContextMenuData;
class TranslateManagerTest : public RenderViewHostTestHarness,
public NotificationObserver {
public:
- TranslateManagerTest() {}
+ TranslateManagerTest()
+ : ui_thread_(BrowserThread::UI, &message_loop_) {
+ }
// Simluates navigating to a page and getting the page contents and language
// for that navigation.
@@ -202,6 +205,7 @@ class TranslateManagerTest : public RenderViewHostTestHarness,
private:
NotificationRegistrar notification_registrar_;
TestURLFetcherFactory url_fetcher_factory_;
+ BrowserThread ui_thread_;
// The infobars that have been removed.
// WARNING: the pointers point to deleted objects, use only for comparison.
diff --git a/chrome/browser/visitedlink/visitedlink_unittest.cc b/chrome/browser/visitedlink/visitedlink_unittest.cc
index af957ce..dd7aa83 100644
--- a/chrome/browser/visitedlink/visitedlink_unittest.cc
+++ b/chrome/browser/visitedlink/visitedlink_unittest.cc
@@ -12,13 +12,13 @@
#include "base/process_util.h"
#include "base/shared_memory.h"
#include "base/string_util.h"
-#include "chrome/browser/browser_thread.h"
#include "chrome/browser/renderer_host/browser_render_process_host.h"
#include "chrome/browser/visitedlink/visitedlink_master.h"
#include "chrome/browser/visitedlink/visitedlink_event_listener.h"
#include "chrome/common/render_messages.h"
#include "chrome/renderer/visitedlink_slave.h"
#include "chrome/test/testing_profile.h"
+#include "content/browser/browser_thread.h"
#include "content/browser/renderer_host/test_render_view_host.h"
#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -583,6 +583,7 @@ class VisitedLinkEventsTest : public RenderViewHostTestHarness {
public:
VisitedLinkEventsTest()
: RenderViewHostTestHarness(),
+ ui_thread_(BrowserThread::UI, &message_loop_),
file_thread_(BrowserThread::FILE, &message_loop_) {}
~VisitedLinkEventsTest() {
// This ends up using the file thread to schedule the delete.
@@ -614,6 +615,7 @@ class VisitedLinkEventsTest : public RenderViewHostTestHarness {
private:
scoped_ptr<VisitedLinkEventListener> event_listener_;
+ BrowserThread ui_thread_;
BrowserThread file_thread_;
DISALLOW_COPY_AND_ASSIGN(VisitedLinkEventsTest);