OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "content/public/browser/push_messaging_service.h" | 5 #include "content/public/browser/push_messaging_service.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "content/browser/push_messaging/push_messaging_message_filter.h" | 8 #include "content/browser/push_messaging/push_messaging_message_filter.h" |
9 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 9 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
10 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_wrapper, | 41 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_wrapper, |
42 int64_t service_worker_registration_id, | 42 int64_t service_worker_registration_id, |
43 const std::string& key, | 43 const std::string& key, |
44 const PushMessagingService::StringCallback& callback) { | 44 const PushMessagingService::StringCallback& callback) { |
45 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 45 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
46 service_worker_context_wrapper->GetRegistrationUserData( | 46 service_worker_context_wrapper->GetRegistrationUserData( |
47 service_worker_registration_id, {key}, | 47 service_worker_registration_id, {key}, |
48 base::Bind(&CallStringCallbackFromIO, callback)); | 48 base::Bind(&CallStringCallbackFromIO, callback)); |
49 } | 49 } |
50 | 50 |
51 void ClearPushSubscriptionIDOnIO( | 51 void ClearPushSubscriptionIdOnIO( |
52 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context, | 52 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context, |
53 int64_t service_worker_registration_id, | 53 int64_t service_worker_registration_id, |
54 const base::Closure& callback) { | 54 const base::Closure& callback) { |
55 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 55 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
56 | 56 |
57 service_worker_context->ClearRegistrationUserData( | 57 service_worker_context->ClearRegistrationUserData( |
58 service_worker_registration_id, {kPushRegistrationIdServiceWorkerKey}, | 58 service_worker_registration_id, {kPushRegistrationIdServiceWorkerKey}, |
59 base::Bind(&CallClosureFromIO, callback)); | 59 base::Bind(&CallClosureFromIO, callback)); |
60 } | 60 } |
61 | 61 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 BrowserThread::IO, | 96 BrowserThread::IO, |
97 FROM_HERE, | 97 FROM_HERE, |
98 base::Bind(&GetUserDataOnIO, | 98 base::Bind(&GetUserDataOnIO, |
99 GetServiceWorkerContext(browser_context, origin), | 99 GetServiceWorkerContext(browser_context, origin), |
100 service_worker_registration_id, | 100 service_worker_registration_id, |
101 kPushSenderIdServiceWorkerKey, | 101 kPushSenderIdServiceWorkerKey, |
102 callback)); | 102 callback)); |
103 } | 103 } |
104 | 104 |
105 // static | 105 // static |
106 void PushMessagingService::ClearPushSubscriptionID( | 106 void PushMessagingService::ClearPushSubscriptionId( |
107 BrowserContext* browser_context, | 107 BrowserContext* browser_context, |
108 const GURL& origin, | 108 const GURL& origin, |
109 int64_t service_worker_registration_id, | 109 int64_t service_worker_registration_id, |
110 const base::Closure& callback) { | 110 const base::Closure& callback) { |
111 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 111 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
112 BrowserThread::PostTask( | 112 BrowserThread::PostTask( |
113 BrowserThread::IO, | 113 BrowserThread::IO, FROM_HERE, |
114 FROM_HERE, | 114 base::Bind(&ClearPushSubscriptionIdOnIO, |
115 base::Bind(&ClearPushSubscriptionIDOnIO, | |
116 GetServiceWorkerContext(browser_context, origin), | 115 GetServiceWorkerContext(browser_context, origin), |
117 service_worker_registration_id, | 116 service_worker_registration_id, callback)); |
118 callback)); | |
119 } | 117 } |
120 | 118 |
121 // static | 119 // static |
122 void PushMessagingService::StorePushSubscriptionForTesting( | 120 void PushMessagingService::StorePushSubscriptionForTesting( |
123 BrowserContext* browser_context, | 121 BrowserContext* browser_context, |
124 const GURL& origin, | 122 const GURL& origin, |
125 int64_t service_worker_registration_id, | 123 int64_t service_worker_registration_id, |
126 const std::string& subscription_id, | 124 const std::string& subscription_id, |
127 const std::string& sender_id, | 125 const std::string& sender_id, |
128 const base::Closure& callback) { | 126 const base::Closure& callback) { |
129 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 127 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
130 BrowserThread::PostTask( | 128 BrowserThread::PostTask( |
131 BrowserThread::IO, FROM_HERE, | 129 BrowserThread::IO, FROM_HERE, |
132 base::Bind(&StorePushSubscriptionOnIOForTesting, | 130 base::Bind(&StorePushSubscriptionOnIOForTesting, |
133 GetServiceWorkerContext(browser_context, origin), | 131 GetServiceWorkerContext(browser_context, origin), |
134 service_worker_registration_id, origin, subscription_id, | 132 service_worker_registration_id, origin, subscription_id, |
135 sender_id, callback)); | 133 sender_id, callback)); |
136 } | 134 } |
137 | 135 |
138 } // namespace content | 136 } // namespace content |
OLD | NEW |