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

Side by Side Diff: content/child/push_messaging/push_provider.h

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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_CHILD_PUSH_MESSAGING_PUSH_MANAGER_H_ 5 #ifndef CONTENT_CHILD_PUSH_MESSAGING_PUSH_MANAGER_H_
6 #define CONTENT_CHILD_PUSH_MESSAGING_PUSH_MANAGER_H_ 6 #define CONTENT_CHILD_PUSH_MESSAGING_PUSH_MANAGER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/id_map.h" 10 #include "base/id_map.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "content/child/push_messaging/push_dispatcher.h" 12 #include "content/child/push_messaging/push_dispatcher.h"
13 #include "content/child/worker_task_runner.h" 13 #include "content/child/worker_task_runner.h"
14 #include "third_party/WebKit/public/platform/WebPushError.h"
14 #include "third_party/WebKit/public/platform/WebPushProvider.h" 15 #include "third_party/WebKit/public/platform/WebPushProvider.h"
15 16
16 class GURL; 17 class GURL;
17 18
18 namespace content { 19 namespace content {
19 20
20 class ThreadSafeSender; 21 class ThreadSafeSender;
21 22
22 class PushProvider : public blink::WebPushProvider, 23 class PushProvider : public blink::WebPushProvider,
23 public WorkerTaskRunner::Observer { 24 public WorkerTaskRunner::Observer {
24 public: 25 public:
25 ~PushProvider() override; 26 ~PushProvider() override;
26 27
27 // The |thread_safe_sender| and |push_dispatcher| are used if calling this 28 // The |thread_safe_sender| and |push_dispatcher| are used if calling this
28 // leads to construction. 29 // leads to construction.
29 static PushProvider* ThreadSpecificInstance( 30 static PushProvider* ThreadSpecificInstance(
30 ThreadSafeSender* thread_safe_sender, 31 ThreadSafeSender* thread_safe_sender,
31 PushDispatcher* push_dispatcher); 32 PushDispatcher* push_dispatcher);
32 33
33 // WorkerTaskRunner::Observer implementation. 34 // WorkerTaskRunner::Observer implementation.
34 void OnWorkerRunLoopStopped() override; 35 void OnWorkerRunLoopStopped() override;
35 36
36 // blink::WebPushProvider implementation. 37 // blink::WebPushProvider implementation.
37 void registerPushMessaging(blink::WebServiceWorkerRegistration*, 38 virtual void registerPushMessaging(blink::WebServiceWorkerRegistration*,
38 blink::WebPushRegistrationCallbacks*) override; 39 blink::WebPushRegistrationCallbacks*);
39 void getPermissionStatus(blink::WebServiceWorkerRegistration*, 40 virtual void unregister(blink::WebServiceWorkerRegistration*,
40 blink::WebPushPermissionStatusCallbacks*) override; 41 blink::WebPushUnregisterCallbacks*);
42 virtual void getPermissionStatus(blink::WebServiceWorkerRegistration*,
43 blink::WebPushPermissionStatusCallbacks*);
41 44
42 // Called by the PushDispatcher. 45 // Called by the PushDispatcher.
43 bool OnMessageReceived(const IPC::Message& message); 46 bool OnMessageReceived(const IPC::Message& message);
44 47
45 private: 48 private:
46 PushProvider(ThreadSafeSender* thread_safe_sender, 49 PushProvider(ThreadSafeSender* thread_safe_sender,
47 PushDispatcher* push_dispatcher); 50 PushDispatcher* push_dispatcher);
48 51
49 // IPC message handlers. 52 // IPC message handlers.
50 void OnRegisterFromWorkerSuccess(int request_id, 53 void OnRegisterFromWorkerSuccess(int request_id,
51 const GURL& endpoint, 54 const GURL& endpoint,
52 const std::string& registration_id); 55 const std::string& registration_id);
53 void OnRegisterFromWorkerError(int request_id, PushRegistrationStatus status); 56 void OnRegisterFromWorkerError(int request_id, PushRegistrationStatus status);
57 void OnUnregisterSuccess(int request_id, bool did_unregister);
58 void OnUnregisterError(int request_id,
59 blink::WebPushError::ErrorType error_type,
60 const std::string& error_message);
54 void OnGetPermissionStatusSuccess(int request_id, 61 void OnGetPermissionStatusSuccess(int request_id,
55 blink::WebPushPermissionStatus status); 62 blink::WebPushPermissionStatus status);
56 void OnGetPermissionStatusError(int request_id); 63 void OnGetPermissionStatusError(int request_id);
57 64
58 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 65 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
59 scoped_refptr<PushDispatcher> push_dispatcher_; 66 scoped_refptr<PushDispatcher> push_dispatcher_;
60 67
61 // Stores the registration callbacks with their request ids. This class owns 68 // Stores the registration callbacks with their request ids. This class owns
62 // the callbacks. 69 // the callbacks.
63 IDMap<blink::WebPushRegistrationCallbacks, IDMapOwnPointer> 70 IDMap<blink::WebPushRegistrationCallbacks, IDMapOwnPointer>
64 registration_callbacks_; 71 registration_callbacks_;
65 72
66 // Stores the permission status callbacks with their request ids. This class 73 // Stores the permission status callbacks with their request ids. This class
67 // owns the callbacks. 74 // owns the callbacks.
68 IDMap<blink::WebPushPermissionStatusCallbacks, IDMapOwnPointer> 75 IDMap<blink::WebPushPermissionStatusCallbacks, IDMapOwnPointer>
69 permission_status_callbacks_; 76 permission_status_callbacks_;
70 77
78 // Stores the unregistration callbacks with their request ids. This class owns
79 // the callbacks.
80 IDMap<blink::WebPushUnregisterCallbacks, IDMapOwnPointer>
81 unregister_callbacks_;
82
71 DISALLOW_COPY_AND_ASSIGN(PushProvider); 83 DISALLOW_COPY_AND_ASSIGN(PushProvider);
72 }; 84 };
73 85
74 } // namespace content 86 } // namespace content
75 87
76 #endif // CONTENT_CHILD_PUSH_MESSAGING_PUSH_MANAGER_H_ 88 #endif // CONTENT_CHILD_PUSH_MESSAGING_PUSH_MANAGER_H_
OLDNEW
« no previous file with comments | « content/child/push_messaging/push_dispatcher.cc ('k') | content/child/push_messaging/push_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698