Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1048)

Unified Diff: content/browser/renderer_host/render_message_filter.cc

Issue 25492006: Makes the response to CheckNotificationPermission asynchronous. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_message_filter.cc
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
index 29e1e1f199a4d0cfe286083e5f870ecdcd337bcf..53826b4d5aa26fda84621ebc7d03c432230528ed 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -130,6 +130,21 @@ class RenderMessageCompletionCallback {
IPC::Message* reply_msg_;
};
+class CheckNotificationPermissionCallback
+ : public RenderMessageCompletionCallback {
+ public:
+ CheckNotificationPermissionCallback(RenderMessageFilter* filter,
+ IPC::Message* reply_msg)
+ : RenderMessageCompletionCallback(filter, reply_msg) {}
+
+ void GotNotificationPermission(
+ WebKit::WebNotificationPresenter::Permission permission) {
+ DesktopNotificationHostMsg_CheckPermission::WriteReplyParams(
+ reply_msg(), static_cast<int>(permission));
+ SendReplyAndDeleteThis();
+ }
+};
+
class OpenChannelToPpapiPluginCallback
: public RenderMessageCompletionCallback,
public PpapiPluginProcessHost::PluginClient {
@@ -396,8 +411,8 @@ bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message,
IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_UpdateRect,
render_widget_helper_->DidReceiveBackingStoreMsg(message))
IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateIsDelayed, OnUpdateIsDelayed)
- IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_CheckPermission,
- OnCheckNotificationPermission)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(DesktopNotificationHostMsg_CheckPermission,
+ OnCheckNotificationPermission)
IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateSharedMemory,
OnAllocateSharedMemory)
#if defined(OS_POSIX) && !defined(TOOLKIT_GTK) && !defined(OS_ANDROID)
@@ -850,13 +865,27 @@ void RenderMessageFilter::OnDownloadUrl(const IPC::Message& message,
}
void RenderMessageFilter::OnCheckNotificationPermission(
- const GURL& source_origin, int* result) {
+ const GURL& source_origin,
+ IPC::Message* reply_msg) {
+ // |callback| will delete itself when GotNotificationPermission is called.
+ CheckNotificationPermissionCallback* callback =
+ new CheckNotificationPermissionCallback(this, reply_msg);
+
#if defined(ENABLE_NOTIFICATIONS)
- *result = GetContentClient()->browser()->
- CheckDesktopNotificationPermission(source_origin, resource_context_,
- render_process_id_);
+ BrowserThread::PostTaskAndReplyWithResult(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&ContentBrowserClient::CheckDesktopNotificationPermission,
+ base::Unretained(GetContentClient()->browser()), // XXX TODO
+ source_origin,
+ resource_context_,
+ render_process_id_),
+ base::Bind(
+ &CheckNotificationPermissionCallback::GotNotificationPermission,
+ base::Unretained(callback)));
#else
- *result = WebKit::WebNotificationPresenter::PermissionAllowed;
+ callback->GotNotificationPermission(
+ WebKit::WebNotificationPresenter::PermissionAllowed);
#endif
}
« no previous file with comments | « content/browser/renderer_host/render_message_filter.h ('k') | content/public/browser/content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698