| 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/browser/notifications/platform_notification_context_impl.h" | 5 #include "content/browser/notifications/platform_notification_context_impl.h" |
| 6 | 6 |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
| 11 #include "content/browser/notifications/blink_notification_service_impl.h" |
| 11 #include "content/browser/notifications/notification_database.h" | 12 #include "content/browser/notifications/notification_database.h" |
| 12 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 13 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 13 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/browser/content_browser_client.h" | 15 #include "content/public/browser/content_browser_client.h" |
| 15 #include "content/public/browser/notification_database_data.h" | 16 #include "content/public/browser/notification_database_data.h" |
| 16 #include "content/public/browser/platform_notification_service.h" | 17 #include "content/public/browser/platform_notification_service.h" |
| 17 | 18 |
| 18 using base::DoNothing; | 19 using base::DoNothing; |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 93 } |
| 93 | 94 |
| 94 void PlatformNotificationContextImpl::ShutdownOnIO() { | 95 void PlatformNotificationContextImpl::ShutdownOnIO() { |
| 95 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 96 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 96 | 97 |
| 97 // |service_worker_context_| may be NULL in tests. | 98 // |service_worker_context_| may be NULL in tests. |
| 98 if (service_worker_context_) | 99 if (service_worker_context_) |
| 99 service_worker_context_->RemoveObserver(this); | 100 service_worker_context_->RemoveObserver(this); |
| 100 } | 101 } |
| 101 | 102 |
| 103 void PlatformNotificationContextImpl::CreateService( |
| 104 mojo::InterfaceRequest<blink::mojom::NotificationService> request) { |
| 105 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 106 |
| 107 // TODO: This should be initialized (and bound to) the IO thread. |
| 108 // TODO: Probably shouldn't be leaking the memories. |
| 109 new BlinkNotificationServiceImpl(this, std::move(request)); |
| 110 } |
| 111 |
| 102 void PlatformNotificationContextImpl::ReadNotificationData( | 112 void PlatformNotificationContextImpl::ReadNotificationData( |
| 103 int64_t notification_id, | 113 int64_t notification_id, |
| 104 const GURL& origin, | 114 const GURL& origin, |
| 105 const ReadResultCallback& callback) { | 115 const ReadResultCallback& callback) { |
| 106 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 116 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 107 LazyInitialize( | 117 LazyInitialize( |
| 108 base::Bind(&PlatformNotificationContextImpl::DoReadNotificationData, this, | 118 base::Bind(&PlatformNotificationContextImpl::DoReadNotificationData, this, |
| 109 notification_id, origin, callback), | 119 notification_id, origin, callback), |
| 110 base::Bind(callback, false /* success */, NotificationDatabaseData())); | 120 base::Bind(callback, false /* success */, NotificationDatabaseData())); |
| 111 } | 121 } |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 | 412 |
| 403 return path_.Append(kPlatformNotificationsDirectory); | 413 return path_.Append(kPlatformNotificationsDirectory); |
| 404 } | 414 } |
| 405 | 415 |
| 406 void PlatformNotificationContextImpl::SetTaskRunnerForTesting( | 416 void PlatformNotificationContextImpl::SetTaskRunnerForTesting( |
| 407 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { | 417 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { |
| 408 task_runner_ = task_runner; | 418 task_runner_ = task_runner; |
| 409 } | 419 } |
| 410 | 420 |
| 411 } // namespace content | 421 } // namespace content |
| OLD | NEW |