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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 service_worker_context_wrapper->context()->storage()->StoreUserData( | 64 service_worker_context_wrapper->context()->storage()->StoreUserData( |
65 service_worker_registration_id, origin, | 65 service_worker_registration_id, origin, |
66 kNotificationsShownServiceWorkerKey, data, | 66 kNotificationsShownServiceWorkerKey, data, |
67 base::Bind(&CallResultCallbackFromIO, callback)); | 67 base::Bind(&CallResultCallbackFromIO, callback)); |
68 } | 68 } |
69 | 69 |
70 void ClearPushRegistrationIDOnIO( | 70 void ClearPushRegistrationIDOnIO( |
71 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context, | 71 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context, |
72 int64 service_worker_registration_id, | 72 int64 service_worker_registration_id, |
73 const base::Closure& callback) { | 73 const base::Closure& callback) { |
74 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 74 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
75 | 75 |
76 service_worker_context->context()->storage()->ClearUserData( | 76 service_worker_context->context()->storage()->ClearUserData( |
77 service_worker_registration_id, | 77 service_worker_registration_id, |
78 kPushRegistrationIdServiceWorkerKey, | 78 kPushRegistrationIdServiceWorkerKey, |
79 base::Bind(&CallClosureFromIO, callback)); | 79 base::Bind(&CallClosureFromIO, callback)); |
80 } | 80 } |
81 | 81 |
82 scoped_refptr<ServiceWorkerContextWrapper> GetServiceWorkerContext( | 82 scoped_refptr<ServiceWorkerContextWrapper> GetServiceWorkerContext( |
83 BrowserContext* browser_context, const GURL& origin) { | 83 BrowserContext* browser_context, const GURL& origin) { |
84 StoragePartition* partition = | 84 StoragePartition* partition = |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 origin, | 123 origin, |
124 notifications_shown, | 124 notifications_shown, |
125 callback)); | 125 callback)); |
126 } | 126 } |
127 | 127 |
128 // static | 128 // static |
129 void PushMessagingService::GetSenderId(BrowserContext* browser_context, | 129 void PushMessagingService::GetSenderId(BrowserContext* browser_context, |
130 const GURL& origin, | 130 const GURL& origin, |
131 int64 service_worker_registration_id, | 131 int64 service_worker_registration_id, |
132 const StringCallback& callback) { | 132 const StringCallback& callback) { |
133 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 133 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
134 BrowserThread::PostTask( | 134 BrowserThread::PostTask( |
135 BrowserThread::IO, | 135 BrowserThread::IO, |
136 FROM_HERE, | 136 FROM_HERE, |
137 base::Bind(&GetUserDataOnIO, | 137 base::Bind(&GetUserDataOnIO, |
138 GetServiceWorkerContext(browser_context, origin), | 138 GetServiceWorkerContext(browser_context, origin), |
139 service_worker_registration_id, | 139 service_worker_registration_id, |
140 kPushSenderIdServiceWorkerKey, | 140 kPushSenderIdServiceWorkerKey, |
141 callback)); | 141 callback)); |
142 } | 142 } |
143 | 143 |
144 // static | 144 // static |
145 void PushMessagingService::ClearPushRegistrationID( | 145 void PushMessagingService::ClearPushRegistrationID( |
146 BrowserContext* browser_context, | 146 BrowserContext* browser_context, |
147 const GURL& origin, | 147 const GURL& origin, |
148 int64 service_worker_registration_id, | 148 int64 service_worker_registration_id, |
149 const base::Closure& callback) { | 149 const base::Closure& callback) { |
150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 150 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
151 BrowserThread::PostTask( | 151 BrowserThread::PostTask( |
152 BrowserThread::IO, | 152 BrowserThread::IO, |
153 FROM_HERE, | 153 FROM_HERE, |
154 base::Bind(&ClearPushRegistrationIDOnIO, | 154 base::Bind(&ClearPushRegistrationIDOnIO, |
155 GetServiceWorkerContext(browser_context, origin), | 155 GetServiceWorkerContext(browser_context, origin), |
156 service_worker_registration_id, | 156 service_worker_registration_id, |
157 callback)); | 157 callback)); |
158 } | 158 } |
159 | 159 |
160 } // namespace content | 160 } // namespace content |
OLD | NEW |