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

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

Issue 1282013004: BackgroundSyncManager tracks client registrations (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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 // base::Unretained is safe here, as the mojo channel will be deleted (and 52 // base::Unretained is safe here, as the mojo channel will be deleted (and
53 // will wipe its callbacks) before 'this' is deleted. 53 // will wipe its callbacks) before 'this' is deleted.
54 GetBackgroundSyncServicePtr()->Register( 54 GetBackgroundSyncServicePtr()->Register(
55 mojo::ConvertTo<SyncRegistrationPtr>(*(optionsPtr.get())), 55 mojo::ConvertTo<SyncRegistrationPtr>(*(optionsPtr.get())),
56 service_worker_registration_id, 56 service_worker_registration_id,
57 base::Bind(&BackgroundSyncProvider::RegisterCallback, 57 base::Bind(&BackgroundSyncProvider::RegisterCallback,
58 base::Unretained(this), base::Passed(callbacksPtr.Pass()))); 58 base::Unretained(this), base::Passed(callbacksPtr.Pass())));
59 } 59 }
60 60
61 // TODO(jkarlin) remove |tag| parameter.
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,
michaeln 2015/08/28 02:53:11 this is an int handle_id? is that right?
jkarlin 2015/09/02 23:51:41 Yes, conversion to int and the removal of tag will
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) {
67 DCHECK(service_worker_registration); 68 DCHECK(service_worker_registration);
68 DCHECK(callbacks); 69 DCHECK(callbacks);
69 int64 service_worker_registration_id = 70 int64 service_worker_registration_id =
70 GetServiceWorkerRegistrationId(service_worker_registration); 71 GetServiceWorkerRegistrationId(service_worker_registration);
71 scoped_ptr<blink::WebSyncUnregistrationCallbacks> callbacksPtr(callbacks); 72 scoped_ptr<blink::WebSyncUnregistrationCallbacks> callbacksPtr(callbacks);
72 73
73 // base::Unretained is safe here, as the mojo channel will be deleted (and 74 // base::Unretained is safe here, as the mojo channel will be deleted (and
74 // will wipe its callbacks) before 'this' is deleted. 75 // will wipe its callbacks) before 'this' is deleted.
75 GetBackgroundSyncServicePtr()->Unregister( 76 GetBackgroundSyncServicePtr()->Unregister(
76 mojo::ConvertTo<BackgroundSyncPeriodicity>(periodicity), id, tag.utf8(), 77 mojo::ConvertTo<BackgroundSyncPeriodicity>(periodicity), id,
77 service_worker_registration_id, 78 service_worker_registration_id,
78 base::Bind(&BackgroundSyncProvider::UnregisterCallback, 79 base::Bind(&BackgroundSyncProvider::UnregisterCallback,
79 base::Unretained(this), base::Passed(callbacksPtr.Pass()))); 80 base::Unretained(this), base::Passed(callbacksPtr.Pass())));
80 } 81 }
81 82
82 void BackgroundSyncProvider::getRegistration( 83 void BackgroundSyncProvider::getRegistration(
83 blink::WebSyncRegistration::Periodicity periodicity, 84 blink::WebSyncRegistration::Periodicity periodicity,
84 const blink::WebString& tag, 85 const blink::WebString& tag,
85 blink::WebServiceWorkerRegistration* service_worker_registration, 86 blink::WebServiceWorkerRegistration* service_worker_registration,
86 blink::WebSyncRegistrationCallbacks* callbacks) { 87 blink::WebSyncRegistrationCallbacks* callbacks) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 132
132 // base::Unretained is safe here, as the mojo channel will be deleted (and 133 // base::Unretained is safe here, as the mojo channel will be deleted (and
133 // will wipe its callbacks) before 'this' is deleted. 134 // will wipe its callbacks) before 'this' is deleted.
134 GetBackgroundSyncServicePtr()->GetPermissionStatus( 135 GetBackgroundSyncServicePtr()->GetPermissionStatus(
135 mojo::ConvertTo<BackgroundSyncPeriodicity>(periodicity), 136 mojo::ConvertTo<BackgroundSyncPeriodicity>(periodicity),
136 service_worker_registration_id, 137 service_worker_registration_id,
137 base::Bind(&BackgroundSyncProvider::GetPermissionStatusCallback, 138 base::Bind(&BackgroundSyncProvider::GetPermissionStatusCallback,
138 base::Unretained(this), base::Passed(callbacksPtr.Pass()))); 139 base::Unretained(this), base::Passed(callbacksPtr.Pass())));
139 } 140 }
140 141
142 void BackgroundSyncProvider::releaseRegistration(int64_t handle_id) {
michaeln 2015/08/28 02:53:11 int?
jkarlin 2015/09/02 23:51:41 Yes, but for a future CL as it requires a WebSyncP
143 GetBackgroundSyncServicePtr()->ReleaseRegistration(handle_id);
144 }
145
146 void BackgroundSyncProvider::DuplicateRegistrationHandle(
147 int64_t handle_id,
michaeln 2015/08/28 02:53:11 int?
jkarlin 2015/09/02 23:51:41 Done.
148 int64_t service_worker_registration_id,
149 const BackgroundSyncService::DuplicateRegistrationHandleCallback&
150 callback) {
151 GetBackgroundSyncServicePtr()->DuplicateRegistrationHandle(
152 handle_id, service_worker_registration_id, callback);
153 }
154
141 void BackgroundSyncProvider::RegisterCallback( 155 void BackgroundSyncProvider::RegisterCallback(
142 scoped_ptr<blink::WebSyncRegistrationCallbacks> callbacks, 156 scoped_ptr<blink::WebSyncRegistrationCallbacks> callbacks,
143 BackgroundSyncError error, 157 BackgroundSyncError error,
144 const SyncRegistrationPtr& options) { 158 const SyncRegistrationPtr& options) {
145 // TODO(iclelland): Determine the correct error message to return in each case 159 // TODO(iclelland): Determine the correct error message to return in each case
146 scoped_ptr<blink::WebSyncRegistration> result; 160 scoped_ptr<blink::WebSyncRegistration> result;
147 switch (error) { 161 switch (error) {
148 case BACKGROUND_SYNC_ERROR_NONE: 162 case BACKGROUND_SYNC_ERROR_NONE:
149 if (!options.is_null()) 163 if (!options.is_null())
150 result = 164 result =
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 BackgroundSyncServicePtr& 328 BackgroundSyncServicePtr&
315 BackgroundSyncProvider::GetBackgroundSyncServicePtr() { 329 BackgroundSyncProvider::GetBackgroundSyncServicePtr() {
316 if (!background_sync_service_.get()) { 330 if (!background_sync_service_.get()) {
317 service_registry_->ConnectToRemoteService( 331 service_registry_->ConnectToRemoteService(
318 mojo::GetProxy(&background_sync_service_)); 332 mojo::GetProxy(&background_sync_service_));
319 } 333 }
320 return background_sync_service_; 334 return background_sync_service_;
321 } 335 }
322 336
323 } // namespace content 337 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698