OLD | NEW |
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_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_MANAGER_H_ |
6 #define CONTENT_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_MANAGER_H_ | 6 #define CONTENT_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_MANAGER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 23 matching lines...) Expand all Loading... |
34 public: | 34 public: |
35 PushMessagingManager(int render_process_id, | 35 PushMessagingManager(int render_process_id, |
36 ServiceWorkerContextWrapper* service_worker_context); | 36 ServiceWorkerContextWrapper* service_worker_context); |
37 | 37 |
38 void BindRequest(mojom::PushMessagingRequest request); | 38 void BindRequest(mojom::PushMessagingRequest request); |
39 | 39 |
40 // mojom::PushMessaging impl, run on IO thread. | 40 // mojom::PushMessaging impl, run on IO thread. |
41 void Subscribe(int32_t render_frame_id, | 41 void Subscribe(int32_t render_frame_id, |
42 int64_t service_worker_registration_id, | 42 int64_t service_worker_registration_id, |
43 const PushSubscriptionOptions& options, | 43 const PushSubscriptionOptions& options, |
44 const SubscribeCallback& callback) override; | 44 SubscribeCallback callback) override; |
45 void Unsubscribe(int64_t service_worker_registration_id, | 45 void Unsubscribe(int64_t service_worker_registration_id, |
46 const UnsubscribeCallback& callback) override; | 46 UnsubscribeCallback callback) override; |
47 void GetSubscription(int64_t service_worker_registration_id, | 47 void GetSubscription(int64_t service_worker_registration_id, |
48 const GetSubscriptionCallback& callback) override; | 48 GetSubscriptionCallback callback) override; |
49 void GetPermissionStatus( | 49 void GetPermissionStatus(int64_t service_worker_registration_id, |
50 int64_t service_worker_registration_id, | 50 bool user_visible, |
51 bool user_visible, | 51 GetPermissionStatusCallback callback) override; |
52 const GetPermissionStatusCallback& callback) override; | |
53 | 52 |
54 private: | 53 private: |
55 struct RegisterData; | 54 struct RegisterData; |
56 class Core; | 55 class Core; |
57 | 56 |
58 friend class BrowserThread; | 57 friend class BrowserThread; |
59 friend class base::DeleteHelper<PushMessagingManager>; | 58 friend class base::DeleteHelper<PushMessagingManager>; |
60 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>; | 59 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>; |
61 | 60 |
62 ~PushMessagingManager() override; | 61 ~PushMessagingManager() override; |
63 | 62 |
64 void DidCheckForExistingRegistration( | 63 void DidCheckForExistingRegistration( |
65 const RegisterData& data, | 64 RegisterData data, |
66 const std::vector<std::string>& push_registration_id, | 65 const std::vector<std::string>& push_registration_id, |
67 ServiceWorkerStatusCode service_worker_status); | 66 ServiceWorkerStatusCode service_worker_status); |
68 | 67 |
69 void DidGetSenderIdFromStorage(const RegisterData& data, | 68 void DidGetSenderIdFromStorage(RegisterData data, |
70 const std::vector<std::string>& sender_id, | 69 const std::vector<std::string>& sender_id, |
71 ServiceWorkerStatusCode service_worker_status); | 70 ServiceWorkerStatusCode service_worker_status); |
72 | 71 |
73 // Called via PostTask from UI thread. | 72 // Called via PostTask from UI thread. |
74 void PersistRegistrationOnIO(const RegisterData& data, | 73 void PersistRegistrationOnIO(RegisterData data, |
75 const std::string& push_registration_id, | 74 const std::string& push_registration_id, |
76 const std::vector<uint8_t>& p256dh, | 75 const std::vector<uint8_t>& p256dh, |
77 const std::vector<uint8_t>& auth); | 76 const std::vector<uint8_t>& auth); |
78 | 77 |
79 void DidPersistRegistrationOnIO( | 78 void DidPersistRegistrationOnIO( |
80 const RegisterData& data, | 79 RegisterData data, |
81 const std::string& push_registration_id, | 80 const std::string& push_registration_id, |
82 const std::vector<uint8_t>& p256dh, | 81 const std::vector<uint8_t>& p256dh, |
83 const std::vector<uint8_t>& auth, | 82 const std::vector<uint8_t>& auth, |
84 ServiceWorkerStatusCode service_worker_status); | 83 ServiceWorkerStatusCode service_worker_status); |
85 | 84 |
86 // Called both from IO thread, and via PostTask from UI thread. | 85 // Called both from IO thread, and via PostTask from UI thread. |
87 void SendSubscriptionError(const RegisterData& data, | 86 void SendSubscriptionError(RegisterData data, PushRegistrationStatus status); |
88 PushRegistrationStatus status); | |
89 // Called both from IO thread, and via PostTask from UI thread. | 87 // Called both from IO thread, and via PostTask from UI thread. |
90 void SendSubscriptionSuccess(const RegisterData& data, | 88 void SendSubscriptionSuccess(RegisterData data, |
91 PushRegistrationStatus status, | 89 PushRegistrationStatus status, |
92 const std::string& push_subscription_id, | 90 const std::string& push_subscription_id, |
93 const std::vector<uint8_t>& p256dh, | 91 const std::vector<uint8_t>& p256dh, |
94 const std::vector<uint8_t>& auth); | 92 const std::vector<uint8_t>& auth); |
95 | 93 |
96 void UnsubscribeHavingGottenSenderId( | 94 void UnsubscribeHavingGottenSenderId( |
97 const UnsubscribeCallback& callback, | 95 UnsubscribeCallback callback, |
98 int64_t service_worker_registration_id, | 96 int64_t service_worker_registration_id, |
99 const GURL& requesting_origin, | 97 const GURL& requesting_origin, |
100 const std::vector<std::string>& sender_id, | 98 const std::vector<std::string>& sender_id, |
101 ServiceWorkerStatusCode service_worker_status); | 99 ServiceWorkerStatusCode service_worker_status); |
102 | 100 |
103 // Called both from IO thread, and via PostTask from UI thread. | 101 // Called both from IO thread, and via PostTask from UI thread. |
104 void DidUnregister(const UnsubscribeCallback& callback, | 102 void DidUnregister(UnsubscribeCallback callback, |
105 PushUnregistrationStatus unregistration_status); | 103 PushUnregistrationStatus unregistration_status); |
106 | 104 |
107 void DidGetSubscription( | 105 void DidGetSubscription( |
108 const GetSubscriptionCallback& callback, | 106 GetSubscriptionCallback callback, |
109 int64_t service_worker_registration_id, | 107 int64_t service_worker_registration_id, |
110 const std::vector<std::string>& push_subscription_id_and_sender_info, | 108 const std::vector<std::string>& push_subscription_id_and_sender_info, |
111 ServiceWorkerStatusCode service_worker_status); | 109 ServiceWorkerStatusCode service_worker_status); |
112 | 110 |
113 // Helper methods on either thread ------------------------------------------- | 111 // Helper methods on either thread ------------------------------------------- |
114 | 112 |
115 // Creates an endpoint for |subscription_id| with either the default protocol, | 113 // Creates an endpoint for |subscription_id| with either the default protocol, |
116 // or the standardized Web Push Protocol, depending on |standard_protocol|. | 114 // or the standardized Web Push Protocol, depending on |standard_protocol|. |
117 GURL CreateEndpoint(bool standard_protocol, | 115 GURL CreateEndpoint(bool standard_protocol, |
118 const std::string& subscription_id) const; | 116 const std::string& subscription_id) const; |
(...skipping 16 matching lines...) Expand all Loading... |
135 mojo::BindingSet<mojom::PushMessaging> bindings_; | 133 mojo::BindingSet<mojom::PushMessaging> bindings_; |
136 | 134 |
137 base::WeakPtrFactory<PushMessagingManager> weak_factory_io_to_io_; | 135 base::WeakPtrFactory<PushMessagingManager> weak_factory_io_to_io_; |
138 | 136 |
139 DISALLOW_COPY_AND_ASSIGN(PushMessagingManager); | 137 DISALLOW_COPY_AND_ASSIGN(PushMessagingManager); |
140 }; | 138 }; |
141 | 139 |
142 } // namespace content | 140 } // namespace content |
143 | 141 |
144 #endif // CONTENT_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_MANAGER_H_ | 142 #endif // CONTENT_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_MANAGER_H_ |
OLD | NEW |