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

Side by Side Diff: content/child/background_sync/background_sync_provider.cc

Issue 1544293002: Convert Pass()→std::move() in //content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/child/background_sync/background_sync_provider.h" 5 #include "content/child/background_sync/background_sync_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
12 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
13 #include "base/threading/thread_local.h" 14 #include "base/threading/thread_local.h"
14 #include "content/child/background_sync/background_sync_type_converters.h" 15 #include "content/child/background_sync/background_sync_type_converters.h"
15 #include "content/child/child_thread_impl.h" 16 #include "content/child/child_thread_impl.h"
16 #include "content/child/service_worker/web_service_worker_registration_impl.h" 17 #include "content/child/service_worker/web_service_worker_registration_impl.h"
17 #include "content/public/common/background_sync.mojom.h" 18 #include "content/public/common/background_sync.mojom.h"
(...skipping 12 matching lines...) Expand all
30 int64_t GetServiceWorkerRegistrationId( 31 int64_t GetServiceWorkerRegistrationId(
31 blink::WebServiceWorkerRegistration* service_worker_registration) { 32 blink::WebServiceWorkerRegistration* service_worker_registration) {
32 return static_cast<WebServiceWorkerRegistrationImpl*>( 33 return static_cast<WebServiceWorkerRegistrationImpl*>(
33 service_worker_registration)->registration_id(); 34 service_worker_registration)->registration_id();
34 } 35 }
35 36
36 void ConnectToServiceOnMainThread( 37 void ConnectToServiceOnMainThread(
37 mojo::InterfaceRequest<BackgroundSyncService> request) { 38 mojo::InterfaceRequest<BackgroundSyncService> request) {
38 DCHECK(ChildThreadImpl::current()); 39 DCHECK(ChildThreadImpl::current());
39 ChildThreadImpl::current()->service_registry()->ConnectToRemoteService( 40 ChildThreadImpl::current()->service_registry()->ConnectToRemoteService(
40 request.Pass()); 41 std::move(request));
41 } 42 }
42 43
43 LazyInstance<ThreadLocalPointer<BackgroundSyncProvider>>::Leaky 44 LazyInstance<ThreadLocalPointer<BackgroundSyncProvider>>::Leaky
44 g_sync_provider_tls = LAZY_INSTANCE_INITIALIZER; 45 g_sync_provider_tls = LAZY_INSTANCE_INITIALIZER;
45 46
46 } // namespace 47 } // namespace
47 48
48 BackgroundSyncProvider::BackgroundSyncProvider( 49 BackgroundSyncProvider::BackgroundSyncProvider(
49 const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) 50 const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner)
50 : main_thread_task_runner_(main_task_runner) { 51 : main_thread_task_runner_(main_task_runner) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 GetServiceWorkerRegistrationId(service_worker_registration); 96 GetServiceWorkerRegistrationId(service_worker_registration);
96 scoped_ptr<const blink::WebSyncRegistration> optionsPtr(options); 97 scoped_ptr<const blink::WebSyncRegistration> optionsPtr(options);
97 scoped_ptr<blink::WebSyncRegistrationCallbacks> callbacksPtr(callbacks); 98 scoped_ptr<blink::WebSyncRegistrationCallbacks> callbacksPtr(callbacks);
98 99
99 // base::Unretained is safe here, as the mojo channel will be deleted (and 100 // base::Unretained is safe here, as the mojo channel will be deleted (and
100 // will wipe its callbacks) before 'this' is deleted. 101 // will wipe its callbacks) before 'this' is deleted.
101 GetBackgroundSyncServicePtr()->Register( 102 GetBackgroundSyncServicePtr()->Register(
102 mojo::ConvertTo<SyncRegistrationPtr>(*(optionsPtr.get())), 103 mojo::ConvertTo<SyncRegistrationPtr>(*(optionsPtr.get())),
103 service_worker_registration_id, requested_from_service_worker, 104 service_worker_registration_id, requested_from_service_worker,
104 base::Bind(&BackgroundSyncProvider::RegisterCallback, 105 base::Bind(&BackgroundSyncProvider::RegisterCallback,
105 base::Unretained(this), base::Passed(callbacksPtr.Pass()))); 106 base::Unretained(this),
107 base::Passed(std::move(callbacksPtr))));
106 } 108 }
107 109
108 void BackgroundSyncProvider::unregisterBackgroundSync( 110 void BackgroundSyncProvider::unregisterBackgroundSync(
109 int64_t handle_id, 111 int64_t handle_id,
110 blink::WebServiceWorkerRegistration* service_worker_registration, 112 blink::WebServiceWorkerRegistration* service_worker_registration,
111 blink::WebSyncUnregistrationCallbacks* callbacks) { 113 blink::WebSyncUnregistrationCallbacks* callbacks) {
112 DCHECK(service_worker_registration); 114 DCHECK(service_worker_registration);
113 DCHECK(callbacks); 115 DCHECK(callbacks);
114 int64_t service_worker_registration_id = 116 int64_t service_worker_registration_id =
115 GetServiceWorkerRegistrationId(service_worker_registration); 117 GetServiceWorkerRegistrationId(service_worker_registration);
116 scoped_ptr<blink::WebSyncUnregistrationCallbacks> callbacksPtr(callbacks); 118 scoped_ptr<blink::WebSyncUnregistrationCallbacks> callbacksPtr(callbacks);
117 119
118 // base::Unretained is safe here, as the mojo channel will be deleted (and 120 // base::Unretained is safe here, as the mojo channel will be deleted (and
119 // will wipe its callbacks) before 'this' is deleted. 121 // will wipe its callbacks) before 'this' is deleted.
120 GetBackgroundSyncServicePtr()->Unregister( 122 GetBackgroundSyncServicePtr()->Unregister(
121 handle_id, service_worker_registration_id, 123 handle_id, service_worker_registration_id,
122 base::Bind(&BackgroundSyncProvider::UnregisterCallback, 124 base::Bind(&BackgroundSyncProvider::UnregisterCallback,
123 base::Unretained(this), base::Passed(callbacksPtr.Pass()))); 125 base::Unretained(this),
126 base::Passed(std::move(callbacksPtr))));
124 } 127 }
125 128
126 void BackgroundSyncProvider::getRegistration( 129 void BackgroundSyncProvider::getRegistration(
127 blink::WebSyncRegistration::Periodicity periodicity, 130 blink::WebSyncRegistration::Periodicity periodicity,
128 const blink::WebString& tag, 131 const blink::WebString& tag,
129 blink::WebServiceWorkerRegistration* service_worker_registration, 132 blink::WebServiceWorkerRegistration* service_worker_registration,
130 blink::WebSyncRegistrationCallbacks* callbacks) { 133 blink::WebSyncRegistrationCallbacks* callbacks) {
131 DCHECK(service_worker_registration); 134 DCHECK(service_worker_registration);
132 DCHECK(callbacks); 135 DCHECK(callbacks);
133 int64_t service_worker_registration_id = 136 int64_t service_worker_registration_id =
134 GetServiceWorkerRegistrationId(service_worker_registration); 137 GetServiceWorkerRegistrationId(service_worker_registration);
135 scoped_ptr<blink::WebSyncRegistrationCallbacks> callbacksPtr(callbacks); 138 scoped_ptr<blink::WebSyncRegistrationCallbacks> callbacksPtr(callbacks);
136 139
137 // base::Unretained is safe here, as the mojo channel will be deleted (and 140 // base::Unretained is safe here, as the mojo channel will be deleted (and
138 // will wipe its callbacks) before 'this' is deleted. 141 // will wipe its callbacks) before 'this' is deleted.
139 GetBackgroundSyncServicePtr()->GetRegistration( 142 GetBackgroundSyncServicePtr()->GetRegistration(
140 mojo::ConvertTo<BackgroundSyncPeriodicity>(periodicity), tag.utf8(), 143 mojo::ConvertTo<BackgroundSyncPeriodicity>(periodicity), tag.utf8(),
141 service_worker_registration_id, 144 service_worker_registration_id,
142 base::Bind(&BackgroundSyncProvider::GetRegistrationCallback, 145 base::Bind(&BackgroundSyncProvider::GetRegistrationCallback,
143 base::Unretained(this), base::Passed(callbacksPtr.Pass()))); 146 base::Unretained(this),
147 base::Passed(std::move(callbacksPtr))));
144 } 148 }
145 149
146 void BackgroundSyncProvider::getRegistrations( 150 void BackgroundSyncProvider::getRegistrations(
147 blink::WebSyncRegistration::Periodicity periodicity, 151 blink::WebSyncRegistration::Periodicity periodicity,
148 blink::WebServiceWorkerRegistration* service_worker_registration, 152 blink::WebServiceWorkerRegistration* service_worker_registration,
149 blink::WebSyncGetRegistrationsCallbacks* callbacks) { 153 blink::WebSyncGetRegistrationsCallbacks* callbacks) {
150 DCHECK(service_worker_registration); 154 DCHECK(service_worker_registration);
151 DCHECK(callbacks); 155 DCHECK(callbacks);
152 int64_t service_worker_registration_id = 156 int64_t service_worker_registration_id =
153 GetServiceWorkerRegistrationId(service_worker_registration); 157 GetServiceWorkerRegistrationId(service_worker_registration);
154 scoped_ptr<blink::WebSyncGetRegistrationsCallbacks> callbacksPtr(callbacks); 158 scoped_ptr<blink::WebSyncGetRegistrationsCallbacks> callbacksPtr(callbacks);
155 159
156 // base::Unretained is safe here, as the mojo channel will be deleted (and 160 // base::Unretained is safe here, as the mojo channel will be deleted (and
157 // will wipe its callbacks) before 'this' is deleted. 161 // will wipe its callbacks) before 'this' is deleted.
158 GetBackgroundSyncServicePtr()->GetRegistrations( 162 GetBackgroundSyncServicePtr()->GetRegistrations(
159 mojo::ConvertTo<BackgroundSyncPeriodicity>(periodicity), 163 mojo::ConvertTo<BackgroundSyncPeriodicity>(periodicity),
160 service_worker_registration_id, 164 service_worker_registration_id,
161 base::Bind(&BackgroundSyncProvider::GetRegistrationsCallback, 165 base::Bind(&BackgroundSyncProvider::GetRegistrationsCallback,
162 base::Unretained(this), base::Passed(callbacksPtr.Pass()))); 166 base::Unretained(this),
167 base::Passed(std::move(callbacksPtr))));
163 } 168 }
164 169
165 void BackgroundSyncProvider::getPermissionStatus( 170 void BackgroundSyncProvider::getPermissionStatus(
166 blink::WebSyncRegistration::Periodicity periodicity, 171 blink::WebSyncRegistration::Periodicity periodicity,
167 blink::WebServiceWorkerRegistration* service_worker_registration, 172 blink::WebServiceWorkerRegistration* service_worker_registration,
168 blink::WebSyncGetPermissionStatusCallbacks* callbacks) { 173 blink::WebSyncGetPermissionStatusCallbacks* callbacks) {
169 DCHECK(service_worker_registration); 174 DCHECK(service_worker_registration);
170 DCHECK(callbacks); 175 DCHECK(callbacks);
171 int64_t service_worker_registration_id = 176 int64_t service_worker_registration_id =
172 GetServiceWorkerRegistrationId(service_worker_registration); 177 GetServiceWorkerRegistrationId(service_worker_registration);
173 scoped_ptr<blink::WebSyncGetPermissionStatusCallbacks> callbacksPtr( 178 scoped_ptr<blink::WebSyncGetPermissionStatusCallbacks> callbacksPtr(
174 callbacks); 179 callbacks);
175 180
176 // base::Unretained is safe here, as the mojo channel will be deleted (and 181 // base::Unretained is safe here, as the mojo channel will be deleted (and
177 // will wipe its callbacks) before 'this' is deleted. 182 // will wipe its callbacks) before 'this' is deleted.
178 GetBackgroundSyncServicePtr()->GetPermissionStatus( 183 GetBackgroundSyncServicePtr()->GetPermissionStatus(
179 mojo::ConvertTo<BackgroundSyncPeriodicity>(periodicity), 184 mojo::ConvertTo<BackgroundSyncPeriodicity>(periodicity),
180 service_worker_registration_id, 185 service_worker_registration_id,
181 base::Bind(&BackgroundSyncProvider::GetPermissionStatusCallback, 186 base::Bind(&BackgroundSyncProvider::GetPermissionStatusCallback,
182 base::Unretained(this), base::Passed(callbacksPtr.Pass()))); 187 base::Unretained(this),
188 base::Passed(std::move(callbacksPtr))));
183 } 189 }
184 190
185 void BackgroundSyncProvider::releaseRegistration(int64_t handle_id) { 191 void BackgroundSyncProvider::releaseRegistration(int64_t handle_id) {
186 GetBackgroundSyncServicePtr()->ReleaseRegistration(handle_id); 192 GetBackgroundSyncServicePtr()->ReleaseRegistration(handle_id);
187 } 193 }
188 194
189 void BackgroundSyncProvider::notifyWhenFinished( 195 void BackgroundSyncProvider::notifyWhenFinished(
190 int64_t handle_id, 196 int64_t handle_id,
191 blink::WebSyncNotifyWhenFinishedCallbacks* callbacks) { 197 blink::WebSyncNotifyWhenFinishedCallbacks* callbacks) {
192 DCHECK(callbacks); 198 DCHECK(callbacks);
193 199
194 scoped_ptr<blink::WebSyncNotifyWhenFinishedCallbacks> callbacks_ptr( 200 scoped_ptr<blink::WebSyncNotifyWhenFinishedCallbacks> callbacks_ptr(
195 callbacks); 201 callbacks);
196 202
197 // base::Unretained is safe here, as the mojo channel will be deleted (and 203 // base::Unretained is safe here, as the mojo channel will be deleted (and
198 // will wipe its callbacks) before 'this' is deleted. 204 // will wipe its callbacks) before 'this' is deleted.
199 GetBackgroundSyncServicePtr()->NotifyWhenFinished( 205 GetBackgroundSyncServicePtr()->NotifyWhenFinished(
200 handle_id, 206 handle_id, base::Bind(&BackgroundSyncProvider::NotifyWhenFinishedCallback,
201 base::Bind(&BackgroundSyncProvider::NotifyWhenFinishedCallback, 207 base::Unretained(this),
202 base::Unretained(this), base::Passed(callbacks_ptr.Pass()))); 208 base::Passed(std::move(callbacks_ptr))));
203 } 209 }
204 210
205 void BackgroundSyncProvider::DuplicateRegistrationHandle( 211 void BackgroundSyncProvider::DuplicateRegistrationHandle(
206 int64_t handle_id, 212 int64_t handle_id,
207 const BackgroundSyncService::DuplicateRegistrationHandleCallback& 213 const BackgroundSyncService::DuplicateRegistrationHandleCallback&
208 callback) { 214 callback) {
209 GetBackgroundSyncServicePtr()->DuplicateRegistrationHandle(handle_id, 215 GetBackgroundSyncServicePtr()->DuplicateRegistrationHandle(handle_id,
210 callback); 216 callback);
211 } 217 }
212 218
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 mojo::InterfaceRequest<BackgroundSyncService> request = 439 mojo::InterfaceRequest<BackgroundSyncService> request =
434 mojo::GetProxy(&background_sync_service_); 440 mojo::GetProxy(&background_sync_service_);
435 main_thread_task_runner_->PostTask( 441 main_thread_task_runner_->PostTask(
436 FROM_HERE, 442 FROM_HERE,
437 base::Bind(&ConnectToServiceOnMainThread, base::Passed(&request))); 443 base::Bind(&ConnectToServiceOnMainThread, base::Passed(&request)));
438 } 444 }
439 return background_sync_service_; 445 return background_sync_service_;
440 } 446 }
441 447
442 } // namespace content 448 } // namespace content
OLDNEW
« no previous file with comments | « content/app/content_main_runner.cc ('k') | content/child/background_sync/background_sync_type_converters.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698