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 "content/child/background_sync/background_sync_provider_thread_proxy.h" | 7 #include "content/child/background_sync/background_sync_provider.h" |
8 #include "content/child/background_sync/background_sync_type_converters.h" | 8 #include "content/child/background_sync/background_sync_type_converters.h" |
9 #include "content/renderer/service_worker/service_worker_context_client.h" | 9 #include "content/renderer/service_worker/service_worker_context_client.h" |
10 #include "third_party/WebKit/public/platform/Platform.h" | 10 #include "third_party/WebKit/public/platform/Platform.h" |
11 #include "third_party/WebKit/public/platform/WebThread.h" | 11 #include "third_party/WebKit/public/platform/WebThread.h" |
12 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncProv
ider.h" | 12 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncProv
ider.h" |
13 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncRegi
stration.h" | 13 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncRegi
stration.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 // static | 17 // static |
(...skipping 13 matching lines...) Expand all Loading... |
31 callback_seq_num_(0) {} | 31 callback_seq_num_(0) {} |
32 | 32 |
33 void BackgroundSyncClientImpl::Sync(int64_t handle_id, | 33 void BackgroundSyncClientImpl::Sync(int64_t handle_id, |
34 const SyncCallback& callback) { | 34 const SyncCallback& callback) { |
35 DCHECK(!blink::Platform::current()->mainThread()->isCurrentThread()); | 35 DCHECK(!blink::Platform::current()->mainThread()->isCurrentThread()); |
36 // Get a registration for the given handle_id from the provider. This way | 36 // Get a registration for the given handle_id from the provider. This way |
37 // the provider knows about the handle and can delete it once Blink releases | 37 // the provider knows about the handle and can delete it once Blink releases |
38 // it. | 38 // it. |
39 // TODO(jkarlin): Change the WebSyncPlatform to support | 39 // TODO(jkarlin): Change the WebSyncPlatform to support |
40 // DuplicateRegistrationHandle and then this cast can go. | 40 // DuplicateRegistrationHandle and then this cast can go. |
41 BackgroundSyncProviderThreadProxy* provider = | 41 BackgroundSyncProvider* provider = static_cast<BackgroundSyncProvider*>( |
42 static_cast<BackgroundSyncProviderThreadProxy*>( | 42 blink::Platform::current()->backgroundSyncProvider()); |
43 blink::Platform::current()->backgroundSyncProvider()); | |
44 DCHECK(provider); | 43 DCHECK(provider); |
45 | 44 |
46 // TODO(jkarlin): Find a way to claim the handle safely without requiring a | 45 // TODO(jkarlin): Find a way to claim the handle safely without requiring a |
47 // round-trip IPC. | 46 // round-trip IPC. |
48 int64_t id = ++callback_seq_num_; | 47 int64_t id = ++callback_seq_num_; |
49 sync_callbacks_[id] = callback; | 48 sync_callbacks_[id] = callback; |
50 provider->DuplicateRegistrationHandle( | 49 provider->DuplicateRegistrationHandle( |
51 handle_id, base::Bind(&BackgroundSyncClientImpl::SyncDidGetRegistration, | 50 handle_id, base::Bind(&BackgroundSyncClientImpl::SyncDidGetRegistration, |
52 base::Unretained(this), id)); | 51 base::Unretained(this), id)); |
53 } | 52 } |
(...skipping 20 matching lines...) Expand all Loading... |
74 return; | 73 return; |
75 } | 74 } |
76 | 75 |
77 scoped_ptr<blink::WebSyncRegistration> web_registration = | 76 scoped_ptr<blink::WebSyncRegistration> web_registration = |
78 mojo::ConvertTo<scoped_ptr<blink::WebSyncRegistration>>(registration); | 77 mojo::ConvertTo<scoped_ptr<blink::WebSyncRegistration>>(registration); |
79 | 78 |
80 client->DispatchSyncEvent(*web_registration, callback); | 79 client->DispatchSyncEvent(*web_registration, callback); |
81 } | 80 } |
82 | 81 |
83 } // namespace content | 82 } // namespace content |
OLD | NEW |