OLD | NEW |
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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "content/child/background_sync/background_sync_provider.h" | 9 #include "content/child/background_sync/background_sync_provider.h" |
10 #include "content/child/background_sync/background_sync_type_converters.h" | 10 #include "content/child/background_sync/background_sync_type_converters.h" |
11 #include "content/renderer/service_worker/service_worker_context_client.h" | 11 #include "content/renderer/service_worker/service_worker_context_client.h" |
12 #include "third_party/WebKit/public/platform/Platform.h" | 12 #include "third_party/WebKit/public/platform/Platform.h" |
13 #include "third_party/WebKit/public/platform/WebThread.h" | 13 #include "third_party/WebKit/public/platform/WebThread.h" |
14 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncProv
ider.h" | 14 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncProv
ider.h" |
15 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncRegi
stration.h" | 15 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncRegi
stration.h" |
16 #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerCo
ntextProxy.h" | 16 #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerCo
ntextProxy.h" |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 | 19 |
20 // static | 20 // static |
21 void BackgroundSyncClientImpl::Create( | 21 void BackgroundSyncClientImpl::Create( |
22 int64_t service_worker_registration_id, | |
23 mojo::InterfaceRequest<BackgroundSyncServiceClient> request) { | 22 mojo::InterfaceRequest<BackgroundSyncServiceClient> request) { |
24 new BackgroundSyncClientImpl(service_worker_registration_id, | 23 new BackgroundSyncClientImpl(std::move(request)); |
25 std::move(request)); | |
26 } | 24 } |
27 | 25 |
28 BackgroundSyncClientImpl::~BackgroundSyncClientImpl() {} | 26 BackgroundSyncClientImpl::~BackgroundSyncClientImpl() {} |
29 | 27 |
30 BackgroundSyncClientImpl::BackgroundSyncClientImpl( | 28 BackgroundSyncClientImpl::BackgroundSyncClientImpl( |
31 int64_t service_worker_registration_id, | |
32 mojo::InterfaceRequest<BackgroundSyncServiceClient> request) | 29 mojo::InterfaceRequest<BackgroundSyncServiceClient> request) |
33 : service_worker_registration_id_(service_worker_registration_id), | 30 : binding_(this, std::move(request)), callback_seq_num_(0) {} |
34 binding_(this, std::move(request)), | |
35 callback_seq_num_(0) {} | |
36 | 31 |
37 void BackgroundSyncClientImpl::Sync( | 32 void BackgroundSyncClientImpl::Sync( |
38 int64_t handle_id, | 33 int64_t handle_id, |
39 content::BackgroundSyncEventLastChance last_chance, | 34 content::BackgroundSyncEventLastChance last_chance, |
40 const SyncCallback& callback) { | 35 const SyncCallback& callback) { |
41 DCHECK(!blink::Platform::current()->mainThread()->isCurrentThread()); | 36 DCHECK(!blink::Platform::current()->mainThread()->isCurrentThread()); |
42 // Get a registration for the given handle_id from the provider. This way | 37 // Get a registration for the given handle_id from the provider. This way |
43 // the provider knows about the handle and can delete it once Blink releases | 38 // the provider knows about the handle and can delete it once Blink releases |
44 // it. | 39 // it. |
45 // TODO(jkarlin): Change the WebSyncPlatform to support | 40 // TODO(jkarlin): Change the WebSyncPlatform to support |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 mojo::ConvertTo<scoped_ptr<blink::WebSyncRegistration>>(registration); | 86 mojo::ConvertTo<scoped_ptr<blink::WebSyncRegistration>>(registration); |
92 | 87 |
93 blink::WebServiceWorkerContextProxy::LastChanceOption web_last_chance = | 88 blink::WebServiceWorkerContextProxy::LastChanceOption web_last_chance = |
94 mojo::ConvertTo<blink::WebServiceWorkerContextProxy::LastChanceOption>( | 89 mojo::ConvertTo<blink::WebServiceWorkerContextProxy::LastChanceOption>( |
95 last_chance); | 90 last_chance); |
96 | 91 |
97 client->DispatchSyncEvent(*web_registration, web_last_chance, callback); | 92 client->DispatchSyncEvent(*web_registration, web_last_chance, callback); |
98 } | 93 } |
99 | 94 |
100 } // namespace content | 95 } // namespace content |
OLD | NEW |