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

Unified Diff: content/child/push_messaging/push_provider.cc

Issue 793403002: Implement WebPushProvider.unregister() in Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mvan_2
Patch Set: jochen review comments Created 6 years 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
« no previous file with comments | « content/child/push_messaging/push_provider.h ('k') | content/common/DEPS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/push_messaging/push_provider.cc
diff --git a/content/child/push_messaging/push_provider.cc b/content/child/push_messaging/push_provider.cc
index 0075650634acd47807f74ea2b277aefb8234ec91..64b3409c82278f64b36fe4356665a34ea7e1e009 100644
--- a/content/child/push_messaging/push_provider.cc
+++ b/content/child/push_messaging/push_provider.cc
@@ -13,7 +13,6 @@
#include "content/child/thread_safe_sender.h"
#include "content/child/worker_task_runner.h"
#include "content/common/push_messaging_messages.h"
-#include "third_party/WebKit/public/platform/WebPushError.h"
#include "third_party/WebKit/public/platform/WebPushRegistration.h"
#include "third_party/WebKit/public/platform/WebString.h"
@@ -78,6 +77,21 @@ void PushProvider::registerPushMessaging(
request_id, service_worker_registration_id));
}
+void PushProvider::unregister(
+ blink::WebServiceWorkerRegistration* service_worker_registration,
+ blink::WebPushUnregisterCallbacks* callbacks) {
+ DCHECK(service_worker_registration);
+ DCHECK(callbacks);
+
+ int request_id = push_dispatcher_->GenerateRequestId(CurrentWorkerId());
+ unregister_callbacks_.AddWithID(callbacks, request_id);
+
+ int64 service_worker_registration_id =
+ GetServiceWorkerRegistrationId(service_worker_registration);
+ thread_safe_sender_->Send(new PushMessagingHostMsg_Unregister(
+ request_id, service_worker_registration_id));
+}
+
void PushProvider::getPermissionStatus(
blink::WebServiceWorkerRegistration* service_worker_registration,
blink::WebPushPermissionStatusCallbacks* callbacks) {
@@ -98,6 +112,10 @@ bool PushProvider::OnMessageReceived(const IPC::Message& message) {
OnRegisterFromWorkerSuccess);
IPC_MESSAGE_HANDLER(PushMessagingMsg_RegisterFromWorkerError,
OnRegisterFromWorkerError);
+ IPC_MESSAGE_HANDLER(PushMessagingMsg_UnregisterSuccess,
+ OnUnregisterSuccess);
+ IPC_MESSAGE_HANDLER(PushMessagingMsg_UnregisterError,
+ OnUnregisterError);
IPC_MESSAGE_HANDLER(PushMessagingMsg_GetPermissionStatusSuccess,
OnGetPermissionStatusSuccess);
IPC_MESSAGE_HANDLER(PushMessagingMsg_GetPermissionStatusError,
@@ -141,6 +159,33 @@ void PushProvider::OnRegisterFromWorkerError(int request_id,
registration_callbacks_.Remove(request_id);
}
+void PushProvider::OnUnregisterSuccess(int request_id, bool did_unregister) {
+ blink::WebPushUnregisterCallbacks* callbacks =
+ unregister_callbacks_.Lookup(request_id);
+ if (!callbacks)
+ return;
+
+ callbacks->onSuccess(&did_unregister);
+
+ unregister_callbacks_.Remove(request_id);
+}
+
+void PushProvider::OnUnregisterError(
+ int request_id,
+ blink::WebPushError::ErrorType error_type,
+ const std::string& error_message) {
+ blink::WebPushUnregisterCallbacks* callbacks =
+ unregister_callbacks_.Lookup(request_id);
+ if (!callbacks)
+ return;
+
+ scoped_ptr<blink::WebPushError> error(new blink::WebPushError(
+ error_type, blink::WebString::fromUTF8(error_message)));
+ callbacks->onError(error.release());
+
+ unregister_callbacks_.Remove(request_id);
+}
+
void PushProvider::OnGetPermissionStatusSuccess(
int request_id,
blink::WebPushPermissionStatus status) {
« no previous file with comments | « content/child/push_messaging/push_provider.h ('k') | content/common/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698