| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 43 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 44 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); | 44 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void GetUserDataOnIO( | 47 void GetUserDataOnIO( |
| 48 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_wrapper, | 48 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_wrapper, |
| 49 int64 service_worker_registration_id, | 49 int64 service_worker_registration_id, |
| 50 const std::string& key, | 50 const std::string& key, |
| 51 const PushMessagingService::StringCallback& callback) { | 51 const PushMessagingService::StringCallback& callback) { |
| 52 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 52 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 53 service_worker_context_wrapper->context()->storage()->GetUserData( | 53 service_worker_context_wrapper->GetRegistrationUserData( |
| 54 service_worker_registration_id, key, | 54 service_worker_registration_id, key, |
| 55 base::Bind(&CallStringCallbackFromIO, callback)); | 55 base::Bind(&CallStringCallbackFromIO, callback)); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void SetNotificationsShownOnIO( | 58 void SetNotificationsShownOnIO( |
| 59 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_wrapper, | 59 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_wrapper, |
| 60 int64 service_worker_registration_id, const GURL& origin, | 60 int64 service_worker_registration_id, const GURL& origin, |
| 61 const std::string& data, | 61 const std::string& data, |
| 62 const PushMessagingService::ResultCallback& callback) { | 62 const PushMessagingService::ResultCallback& callback) { |
| 63 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 63 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 64 service_worker_context_wrapper->context()->storage()->StoreUserData( | 64 service_worker_context_wrapper->StoreRegistrationUserData( |
| 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_CURRENTLY_ON(BrowserThread::IO); | 74 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 75 | 75 |
| 76 service_worker_context->context()->storage()->ClearUserData( | 76 service_worker_context->ClearRegistrationUserData( |
| 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 = |
| 85 BrowserContext::GetStoragePartitionForSite(browser_context, origin); | 85 BrowserContext::GetStoragePartitionForSite(browser_context, origin); |
| 86 return make_scoped_refptr( | 86 return make_scoped_refptr( |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |