diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-25 23:49:14 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-25 23:49:14 +0000 |
commit | 8243c186a0fc264d187a41981402711b672ec54b (patch) | |
tree | a7df28594621125b3ec7a9a3b1d0d9fcdc7a4c0c /chrome/browser/notifications | |
parent | 4fc7baba80b0df795c3438bd351029645a33d609 (diff) | |
download | chromium_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/browser/notifications')
-rw-r--r-- | chrome/browser/notifications/notification_object_proxy.cc | 56 | ||||
-rw-r--r-- | chrome/browser/notifications/notification_object_proxy.h | 5 |
2 files changed, 16 insertions, 45 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. |