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

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

Issue 1316743002: Reland of [Background Sync] Allow sync manager access from uncontrolled clients (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "content/child/background_sync/background_sync_type_converters.h" 9 #include "content/child/background_sync/background_sync_type_converters.h"
10 #include "content/child/service_worker/web_service_worker_registration_impl.h" 10 #include "content/child/service_worker/web_service_worker_registration_impl.h"
(...skipping 22 matching lines...) Expand all
33 : service_registry_(service_registry) { 33 : service_registry_(service_registry) {
34 DCHECK(service_registry); 34 DCHECK(service_registry);
35 } 35 }
36 36
37 BackgroundSyncProvider::~BackgroundSyncProvider() { 37 BackgroundSyncProvider::~BackgroundSyncProvider() {
38 } 38 }
39 39
40 void BackgroundSyncProvider::registerBackgroundSync( 40 void BackgroundSyncProvider::registerBackgroundSync(
41 const blink::WebSyncRegistration* options, 41 const blink::WebSyncRegistration* options,
42 blink::WebServiceWorkerRegistration* service_worker_registration, 42 blink::WebServiceWorkerRegistration* service_worker_registration,
43 bool requested_from_service_worker,
43 blink::WebSyncRegistrationCallbacks* callbacks) { 44 blink::WebSyncRegistrationCallbacks* callbacks) {
44 DCHECK(options); 45 DCHECK(options);
45 DCHECK(service_worker_registration); 46 DCHECK(service_worker_registration);
46 DCHECK(callbacks); 47 DCHECK(callbacks);
47 int64 service_worker_registration_id = 48 int64 service_worker_registration_id =
48 GetServiceWorkerRegistrationId(service_worker_registration); 49 GetServiceWorkerRegistrationId(service_worker_registration);
49 scoped_ptr<const blink::WebSyncRegistration> optionsPtr(options); 50 scoped_ptr<const blink::WebSyncRegistration> optionsPtr(options);
50 scoped_ptr<blink::WebSyncRegistrationCallbacks> callbacksPtr(callbacks); 51 scoped_ptr<blink::WebSyncRegistrationCallbacks> callbacksPtr(callbacks);
51 52
52 // base::Unretained is safe here, as the mojo channel will be deleted (and 53 // base::Unretained is safe here, as the mojo channel will be deleted (and
53 // will wipe its callbacks) before 'this' is deleted. 54 // will wipe its callbacks) before 'this' is deleted.
54 GetBackgroundSyncServicePtr()->Register( 55 GetBackgroundSyncServicePtr()->Register(
55 mojo::ConvertTo<SyncRegistrationPtr>(*(optionsPtr.get())), 56 mojo::ConvertTo<SyncRegistrationPtr>(*(optionsPtr.get())),
56 service_worker_registration_id, 57 service_worker_registration_id, requested_from_service_worker,
57 base::Bind(&BackgroundSyncProvider::RegisterCallback, 58 base::Bind(&BackgroundSyncProvider::RegisterCallback,
58 base::Unretained(this), base::Passed(callbacksPtr.Pass()))); 59 base::Unretained(this), base::Passed(callbacksPtr.Pass())));
59 } 60 }
60 61
61 void BackgroundSyncProvider::unregisterBackgroundSync( 62 void BackgroundSyncProvider::unregisterBackgroundSync(
62 blink::WebSyncRegistration::Periodicity periodicity, 63 blink::WebSyncRegistration::Periodicity periodicity,
63 int64_t id, 64 int64_t id,
64 const blink::WebString& tag, 65 const blink::WebString& tag,
65 blink::WebServiceWorkerRegistration* service_worker_registration, 66 blink::WebServiceWorkerRegistration* service_worker_registration,
66 blink::WebSyncUnregistrationCallbacks* callbacks) { 67 blink::WebSyncUnregistrationCallbacks* callbacks) {
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 BackgroundSyncServicePtr& 315 BackgroundSyncServicePtr&
315 BackgroundSyncProvider::GetBackgroundSyncServicePtr() { 316 BackgroundSyncProvider::GetBackgroundSyncServicePtr() {
316 if (!background_sync_service_.get()) { 317 if (!background_sync_service_.get()) {
317 service_registry_->ConnectToRemoteService( 318 service_registry_->ConnectToRemoteService(
318 mojo::GetProxy(&background_sync_service_)); 319 mojo::GetProxy(&background_sync_service_));
319 } 320 }
320 return background_sync_service_; 321 return background_sync_service_;
321 } 322 }
322 323
323 } // namespace content 324 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698