summaryrefslogtreecommitdiffstats
path: root/chrome/browser/notifications
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/notifications')
-rw-r--r--chrome/browser/notifications/notification_object_proxy.cc56
-rw-r--r--chrome/browser/notifications/notification_object_proxy.h5
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.