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

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: 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..288397e49e6cc34185c2388326967dc148606b7a
--- /dev/null
+++ b/content/browser/push_messaging_message_filter.cc
@@ -0,0 +1,49 @@
+// 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)
Peter Beverloo 2014/04/01 14:53:18 Please indent the IPC_MESSAGE_HANDLER and IPC_MESS
Michael van Ouwerkerk 2014/04/02 14:25:15 Done.
+ 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: implement.
Peter Beverloo 2014/04/01 14:53:18 Please attribute your TODOs (this is different fro
Peter Beverloo 2014/04/01 14:53:18 Should we perhaps post a task to call DidRegister
Michael van Ouwerkerk 2014/04/02 14:25:15 Done.
Michael van Ouwerkerk 2014/04/02 14:25:15 Done.
+}
+
+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