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

Side by Side Diff: content/renderer/background_sync/background_sync_client_impl.cc

Issue 1282013004: BackgroundSyncManager tracks client registrations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up Created 5 years, 4 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/renderer/background_sync/background_sync_client_impl.h" 5 #include "content/renderer/background_sync/background_sync_client_impl.h"
6 6
7 #include "content/child/background_sync/background_sync_type_converters.h" 7 #include "content/child/background_sync/background_sync_type_converters.h"
8 #include "content/renderer/service_worker/service_worker_context_client.h" 8 #include "content/renderer/service_worker/service_worker_context_client.h"
9 #include "third_party/WebKit/public/platform/Platform.h"
10 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncProv ider.h"
9 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncRegi stration.h" 11 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncRegi stration.h"
10 12
11 namespace content { 13 namespace content {
12 14
13 // static 15 // static
14 void BackgroundSyncClientImpl::Create( 16 void BackgroundSyncClientImpl::Create(
15 mojo::InterfaceRequest<BackgroundSyncServiceClient> request) { 17 mojo::InterfaceRequest<BackgroundSyncServiceClient> request) {
16 new BackgroundSyncClientImpl(request.Pass()); 18 new BackgroundSyncClientImpl(request.Pass());
17 } 19 }
18 20
19 BackgroundSyncClientImpl::~BackgroundSyncClientImpl() {} 21 BackgroundSyncClientImpl::~BackgroundSyncClientImpl() {}
20 22
21 BackgroundSyncClientImpl::BackgroundSyncClientImpl( 23 BackgroundSyncClientImpl::BackgroundSyncClientImpl(
22 mojo::InterfaceRequest<BackgroundSyncServiceClient> request) 24 mojo::InterfaceRequest<BackgroundSyncServiceClient> request)
23 : binding_(this, request.Pass()) {} 25 : binding_(this, request.Pass()) {}
24 26
25 void BackgroundSyncClientImpl::Sync(content::SyncRegistrationPtr registration, 27 void BackgroundSyncClientImpl::Sync(content::SyncRegistrationPtr registration,
26 const SyncCallback& callback) { 28 const SyncCallback& callback) {
27 ServiceWorkerContextClient* client = 29 ServiceWorkerContextClient* client =
28 ServiceWorkerContextClient::ThreadSpecificInstance(); 30 ServiceWorkerContextClient::ThreadSpecificInstance();
29 if (!client) { 31 if (!client) {
30 callback.Run(SERVICE_WORKER_EVENT_STATUS_ABORTED); 32 callback.Run(SERVICE_WORKER_EVENT_STATUS_ABORTED);
31 return; 33 return;
32 } 34 }
33 scoped_ptr<blink::WebSyncRegistration> reg = 35
36 scoped_ptr<blink::WebSyncRegistration> web_registration =
34 mojo::ConvertTo<scoped_ptr<blink::WebSyncRegistration>>(registration); 37 mojo::ConvertTo<scoped_ptr<blink::WebSyncRegistration>>(registration);
35 client->DispatchSyncEvent(*reg, callback); 38
39 blink::WebSyncRegistration registration_copy = *web_registration;
40
41 // The BackgroundSyncServiceImpl doesn't know about this registration yet,
42 // inform it via trackRegistration.
43 blink::WebSyncProvider* web_sync_provider =
44 blink::Platform::current()->backgroundSyncProvider();
45 DCHECK(web_sync_provider);
46
47 // trackRegistration takes ownership of web_registration.
48 web_sync_provider->trackRegistration(web_registration.release());
michaeln 2015/08/21 02:39:25 track is an odd verb? take adopt acquire grab?
jkarlin 2015/08/25 17:32:59 went with DuplicateRegistrationHandle
49
50 client->DispatchSyncEvent(registration_copy, callback);
36 } 51 }
37 52
38 } // namespace content 53 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698