| 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/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| 11 #include "base/stl_util.h" |
| 11 #include "base/threading/sequenced_worker_pool.h" | 12 #include "base/threading/sequenced_worker_pool.h" |
| 12 #include "content/browser/notifications/blink_notification_service_impl.h" | 13 #include "content/browser/notifications/blink_notification_service_impl.h" |
| 13 #include "content/browser/notifications/notification_database.h" | 14 #include "content/browser/notifications/notification_database.h" |
| 14 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 15 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 15 #include "content/public/browser/browser_context.h" | 16 #include "content/public/browser/browser_context.h" |
| 16 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/public/browser/content_browser_client.h" | 18 #include "content/public/browser/content_browser_client.h" |
| 18 #include "content/public/browser/notification_database_data.h" | 19 #include "content/public/browser/notification_database_data.h" |
| 19 #include "content/public/browser/platform_notification_service.h" | 20 #include "content/public/browser/platform_notification_service.h" |
| 20 | 21 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 ResourceContext* resource_context, | 125 ResourceContext* resource_context, |
| 125 mojo::InterfaceRequest<blink::mojom::NotificationService> request) { | 126 mojo::InterfaceRequest<blink::mojom::NotificationService> request) { |
| 126 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 127 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 127 services_.push_back(base::MakeUnique<BlinkNotificationServiceImpl>( | 128 services_.push_back(base::MakeUnique<BlinkNotificationServiceImpl>( |
| 128 this, resource_context, render_process_id, std::move(request))); | 129 this, resource_context, render_process_id, std::move(request))); |
| 129 } | 130 } |
| 130 | 131 |
| 131 void PlatformNotificationContextImpl::RemoveService( | 132 void PlatformNotificationContextImpl::RemoveService( |
| 132 BlinkNotificationServiceImpl* service) { | 133 BlinkNotificationServiceImpl* service) { |
| 133 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 134 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 134 auto services_to_remove = std::remove_if( | 135 base::EraseIf( |
| 135 services_.begin(), services_.end(), | 136 services_, |
| 136 [service](const std::unique_ptr<BlinkNotificationServiceImpl>& ptr) { | 137 [service](const std::unique_ptr<BlinkNotificationServiceImpl>& ptr) { |
| 137 return ptr.get() == service; | 138 return ptr.get() == service; |
| 138 }); | 139 }); |
| 139 | |
| 140 services_.erase(services_to_remove, services_.end()); | |
| 141 } | 140 } |
| 142 | 141 |
| 143 void PlatformNotificationContextImpl::ReadNotificationData( | 142 void PlatformNotificationContextImpl::ReadNotificationData( |
| 144 const std::string& notification_id, | 143 const std::string& notification_id, |
| 145 const GURL& origin, | 144 const GURL& origin, |
| 146 const ReadResultCallback& callback) { | 145 const ReadResultCallback& callback) { |
| 147 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 146 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 148 | 147 |
| 149 LazyInitialize( | 148 LazyInitialize( |
| 150 base::Bind(&PlatformNotificationContextImpl::DoReadNotificationData, this, | 149 base::Bind(&PlatformNotificationContextImpl::DoReadNotificationData, this, |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 | 538 |
| 540 return path_.Append(kPlatformNotificationsDirectory); | 539 return path_.Append(kPlatformNotificationsDirectory); |
| 541 } | 540 } |
| 542 | 541 |
| 543 void PlatformNotificationContextImpl::SetTaskRunnerForTesting( | 542 void PlatformNotificationContextImpl::SetTaskRunnerForTesting( |
| 544 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { | 543 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { |
| 545 task_runner_ = task_runner; | 544 task_runner_ = task_runner; |
| 546 } | 545 } |
| 547 | 546 |
| 548 } // namespace content | 547 } // namespace content |
| OLD | NEW |