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

Unified Diff: content/browser/push_messaging_message_filter.cc

Issue 219653002: Push API: send and receive IPC messages for registration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and address review comments. Created 6 years, 9 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/push_messaging_message_filter.cc
diff --git a/content/browser/push_messaging_message_filter.cc b/content/browser/push_messaging_message_filter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..19c0c8d466e6175b8539da30f50c43a920af99e2
--- /dev/null
+++ b/content/browser/push_messaging_message_filter.cc
@@ -0,0 +1,60 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/push_messaging_message_filter.h"
+
+#include <string>
+
+#include "content/common/push_messaging_messages.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace content {
+
+PushMessagingMessageFilter::PushMessagingMessageFilter()
+ : BrowserMessageFilter(PushMessagingMsgStart) {}
+
+PushMessagingMessageFilter::~PushMessagingMessageFilter() {}
+
+bool PushMessagingMessageFilter::OnMessageReceived(const IPC::Message& message,
+ bool* message_was_ok) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP_EX(PushMessagingMessageFilter, message, *message_was_ok)
+ IPC_MESSAGE_HANDLER(PushMessagingHostMsg_Register, OnRegister)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void PushMessagingMessageFilter::OnRegister(int routing_id,
+ int callbacks_id,
+ const std::string& sender_id) {
+ // TODO(mvanouwerkerk): Really implement, the below simply returns an error.
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ BrowserThread::PostTask(BrowserThread::UI,
Peter Beverloo 2014/04/02 14:46:05 mmm this doesn't look nice, but I think it still b
Michael van Ouwerkerk 2014/04/02 15:49:30 Acknowledged. Also, this is what you asked for.
+ FROM_HERE,
+ base::Bind(&PushMessagingMessageFilter::DidRegister,
+ this,
+ routing_id,
+ callbacks_id,
+ "",
+ "",
+ PUSH_MESSAGING_STATUS_UNKNOWN_ERROR));
+
+}
+
+void PushMessagingMessageFilter::DidRegister(int routing_id,
+ int callbacks_id,
+ const std::string& endpoint,
+ const std::string& registration_id,
+ PushMessagingStatus status) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (status == PUSH_MESSAGING_STATUS_OK) {
+ Send(new PushMessagingMsg_RegisterSuccess(
+ routing_id, callbacks_id, endpoint, registration_id));
+ } else {
+ Send(new PushMessagingMsg_RegisterError(routing_id, callbacks_id, status));
+ }
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698