Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: content/browser/notifications/platform_notification_context_impl.cc

Issue 1904163002: Move Web Notifications to use Mojo Base URL: https://chromium.googlesource.com/chromium/src.git@skbitmap-blink
Patch Set: it works \o/ Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/stl_util.h"
10 #include "base/threading/sequenced_worker_pool.h" 11 #include "base/threading/sequenced_worker_pool.h"
12 #include "content/browser/notifications/blink_notification_service_impl.h"
11 #include "content/browser/notifications/notification_database.h" 13 #include "content/browser/notifications/notification_database.h"
12 #include "content/browser/service_worker/service_worker_context_wrapper.h" 14 #include "content/browser/service_worker/service_worker_context_wrapper.h"
15 #include "content/public/browser/browser_context.h"
13 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/content_browser_client.h" 17 #include "content/public/browser/content_browser_client.h"
15 #include "content/public/browser/notification_database_data.h" 18 #include "content/public/browser/notification_database_data.h"
16 #include "content/public/browser/platform_notification_service.h" 19 #include "content/public/browser/platform_notification_service.h"
17 20
18 using base::DoNothing; 21 using base::DoNothing;
19 22
20 namespace content { 23 namespace content {
21 24
22 // Name of the directory in the user's profile directory where the notification 25 // Name of the directory in the user's profile directory where the notification
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 void PlatformNotificationContextImpl::Shutdown() { 90 void PlatformNotificationContextImpl::Shutdown() {
88 DCHECK_CURRENTLY_ON(BrowserThread::UI); 91 DCHECK_CURRENTLY_ON(BrowserThread::UI);
89 BrowserThread::PostTask( 92 BrowserThread::PostTask(
90 BrowserThread::IO, FROM_HERE, 93 BrowserThread::IO, FROM_HERE,
91 base::Bind(&PlatformNotificationContextImpl::ShutdownOnIO, this)); 94 base::Bind(&PlatformNotificationContextImpl::ShutdownOnIO, this));
92 } 95 }
93 96
94 void PlatformNotificationContextImpl::ShutdownOnIO() { 97 void PlatformNotificationContextImpl::ShutdownOnIO() {
95 DCHECK_CURRENTLY_ON(BrowserThread::IO); 98 DCHECK_CURRENTLY_ON(BrowserThread::IO);
96 99
100 STLDeleteElements(&services_);
101
97 // |service_worker_context_| may be NULL in tests. 102 // |service_worker_context_| may be NULL in tests.
98 if (service_worker_context_) 103 if (service_worker_context_)
99 service_worker_context_->RemoveObserver(this); 104 service_worker_context_->RemoveObserver(this);
100 } 105 }
101 106
107 void PlatformNotificationContextImpl::CreateService(
108 int render_process_id,
109 mojo::InterfaceRequest<blink::mojom::NotificationService> request) {
110 DCHECK_CURRENTLY_ON(BrowserThread::UI);
111 BrowserThread::PostTask(
112 BrowserThread::IO, FROM_HERE,
113 base::Bind(&PlatformNotificationContextImpl::CreateServiceOnIO, this,
114 render_process_id, browser_context_->GetResourceContext(),
115 base::Passed(&request)));
116 }
117
118 void PlatformNotificationContextImpl::CreateServiceOnIO(
119 int render_process_id,
120 ResourceContext* resource_context,
121 mojo::InterfaceRequest<blink::mojom::NotificationService> request) {
122 DCHECK_CURRENTLY_ON(BrowserThread::IO);
123 services_.insert(new BlinkNotificationServiceImpl(
124 this, browser_context_, resource_context, render_process_id,
125 std::move(request)));
126 }
127
128 void PlatformNotificationContextImpl::RemoveService(
129 BlinkNotificationServiceImpl* service) {
130 DCHECK_CURRENTLY_ON(BrowserThread::IO);
131 DCHECK(ContainsValue(services_, service));
132
133 services_.erase(service);
134 delete service;
135 }
136
102 void PlatformNotificationContextImpl::ReadNotificationData( 137 void PlatformNotificationContextImpl::ReadNotificationData(
103 int64_t notification_id, 138 int64_t notification_id,
104 const GURL& origin, 139 const GURL& origin,
105 const ReadResultCallback& callback) { 140 const ReadResultCallback& callback) {
106 DCHECK_CURRENTLY_ON(BrowserThread::IO); 141 DCHECK_CURRENTLY_ON(BrowserThread::IO);
107 LazyInitialize( 142 LazyInitialize(
108 base::Bind(&PlatformNotificationContextImpl::DoReadNotificationData, this, 143 base::Bind(&PlatformNotificationContextImpl::DoReadNotificationData, this,
109 notification_id, origin, callback), 144 notification_id, origin, callback),
110 base::Bind(callback, false /* success */, NotificationDatabaseData())); 145 base::Bind(callback, false /* success */, NotificationDatabaseData()));
111 } 146 }
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 437
403 return path_.Append(kPlatformNotificationsDirectory); 438 return path_.Append(kPlatformNotificationsDirectory);
404 } 439 }
405 440
406 void PlatformNotificationContextImpl::SetTaskRunnerForTesting( 441 void PlatformNotificationContextImpl::SetTaskRunnerForTesting(
407 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { 442 const scoped_refptr<base::SequencedTaskRunner>& task_runner) {
408 task_runner_ = task_runner; 443 task_runner_ = task_runner;
409 } 444 }
410 445
411 } // namespace content 446 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/notifications/platform_notification_context_impl.h ('k') | content/browser/notifications/type_converters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698