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 #ifndef CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_THREAD_PROXY_H_ | 5 #ifndef CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_THREAD_PROXY_H_ |
6 #define CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_THREAD_PROXY_H_ | 6 #define CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_THREAD_PROXY_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "content/child/worker_task_runner.h" | 9 #include "content/child/worker_task_runner.h" |
10 #include "content/common/background_sync_service.mojom.h" | |
10 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncProv ider.h" | 11 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncProv ider.h" |
11 | 12 |
12 namespace base { | 13 namespace base { |
13 class SingleThreadTaskRunner; | 14 class SingleThreadTaskRunner; |
14 } | 15 } |
15 | 16 |
16 namespace content { | 17 namespace content { |
17 | 18 |
18 class BackgroundSyncProvider; | 19 class BackgroundSyncProvider; |
19 | 20 |
20 // BackgroundSyncProviderThreadProxy is a proxy to the BackgroundSyncProvider | 21 // BackgroundSyncProviderThreadProxy is a proxy to the BackgroundSyncProvider |
21 // for callers running on a different thread than the main thread. There is one | 22 // for callers running on a different thread than the main thread. There is one |
22 // instance per worker thread. | 23 // instance per worker thread. |
23 // | 24 // |
24 // This class handles all of the thread switching, jumping to the main thread to | 25 // This class handles all of the thread switching, jumping to the main thread to |
25 // call the WebSyncProvider methods, and wrapping the callbacks passed in with | 26 // call the WebSyncProvider methods, and wrapping the callbacks passed in with |
26 // code to switch back to the original calling thread. | 27 // code to switch back to the original calling thread. |
27 class BackgroundSyncProviderThreadProxy : public blink::WebSyncProvider, | 28 class BackgroundSyncProviderThreadProxy : public blink::WebSyncProvider, |
michaeln
2015/08/28 02:53:11
I don't think we're taking full advantage of mojo
iclelland
2015/08/28 12:55:21
That's actually a good idea -- I wrote the origina
jkarlin
2015/09/02 23:51:41
Agree that this should be done. Also agree it's fo
| |
28 public WorkerTaskRunner::Observer { | 29 public WorkerTaskRunner::Observer { |
29 public: | 30 public: |
30 static BackgroundSyncProviderThreadProxy* GetThreadInstance( | 31 static BackgroundSyncProviderThreadProxy* GetThreadInstance( |
31 base::SingleThreadTaskRunner* main_thread_task_runner, | 32 base::SingleThreadTaskRunner* main_thread_task_runner, |
32 BackgroundSyncProvider* permissions_dispatcher); | 33 BackgroundSyncProvider* permissions_dispatcher); |
33 | 34 |
34 // blink::WebSyncProvider implementation | 35 // blink::WebSyncProvider implementation |
35 void registerBackgroundSync( | 36 void registerBackgroundSync( |
36 const blink::WebSyncRegistration* options, | 37 const blink::WebSyncRegistration* options, |
37 blink::WebServiceWorkerRegistration* service_worker_registration, | 38 blink::WebServiceWorkerRegistration* service_worker_registration, |
38 blink::WebSyncRegistrationCallbacks* callbacks); | 39 blink::WebSyncRegistrationCallbacks* callbacks); |
39 void unregisterBackgroundSync( | 40 void unregisterBackgroundSync( |
40 blink::WebSyncRegistration::Periodicity periodicity, | 41 blink::WebSyncRegistration::Periodicity periodicity, |
41 int64_t id, | 42 int64_t id, |
michaeln
2015/08/28 02:53:11
is this an int handle_id and are the other inputs
jkarlin
2015/09/02 23:51:41
Needs to be done in a follow-up cl. TODO added.
| |
42 const blink::WebString& tag, | 43 const blink::WebString& tag, |
43 blink::WebServiceWorkerRegistration* service_worker_registration, | 44 blink::WebServiceWorkerRegistration* service_worker_registration, |
44 blink::WebSyncUnregistrationCallbacks* callbacks); | 45 blink::WebSyncUnregistrationCallbacks* callbacks); |
45 void getRegistration( | 46 void getRegistration( |
46 blink::WebSyncRegistration::Periodicity, | 47 blink::WebSyncRegistration::Periodicity, |
47 const blink::WebString& tag, | 48 const blink::WebString& tag, |
48 blink::WebServiceWorkerRegistration* service_worker_registration, | 49 blink::WebServiceWorkerRegistration* service_worker_registration, |
49 blink::WebSyncRegistrationCallbacks* callbacks); | 50 blink::WebSyncRegistrationCallbacks* callbacks); |
50 void getRegistrations( | 51 void getRegistrations( |
51 blink::WebSyncRegistration::Periodicity periodicity, | 52 blink::WebSyncRegistration::Periodicity periodicity, |
52 blink::WebServiceWorkerRegistration* service_worker_registration, | 53 blink::WebServiceWorkerRegistration* service_worker_registration, |
53 blink::WebSyncGetRegistrationsCallbacks* callbacks); | 54 blink::WebSyncGetRegistrationsCallbacks* callbacks); |
54 void getPermissionStatus( | 55 void getPermissionStatus( |
55 blink::WebSyncRegistration::Periodicity periodicity, | 56 blink::WebSyncRegistration::Periodicity periodicity, |
56 blink::WebServiceWorkerRegistration* service_worker_registration, | 57 blink::WebServiceWorkerRegistration* service_worker_registration, |
57 blink::WebSyncGetPermissionStatusCallbacks* callbacks); | 58 blink::WebSyncGetPermissionStatusCallbacks* callbacks); |
59 // TODO(jkarlin): Rename to releaseRegistrationHandle. | |
60 void releaseRegistration(int64_t handle_id); | |
61 | |
62 // Given |handle_id|, ask the provider for a new handle with the same | |
63 // underlying registration. | |
64 void DuplicateRegistrationHandle( | |
65 int64 handle_id, | |
66 int64 service_worker_registration_id, | |
67 const BackgroundSyncService::DuplicateRegistrationHandleCallback& | |
68 callback); | |
58 | 69 |
59 // WorkerTaskRunner::Observer implementation. | 70 // WorkerTaskRunner::Observer implementation. |
60 void OnWorkerRunLoopStopped() override; | 71 void OnWorkerRunLoopStopped() override; |
61 | 72 |
62 private: | 73 private: |
63 BackgroundSyncProviderThreadProxy( | 74 BackgroundSyncProviderThreadProxy( |
64 base::SingleThreadTaskRunner* main_thread_task_runner, | 75 base::SingleThreadTaskRunner* main_thread_task_runner, |
65 BackgroundSyncProvider* sync_provider); | 76 BackgroundSyncProvider* sync_provider); |
66 | 77 |
67 virtual ~BackgroundSyncProviderThreadProxy(); | 78 virtual ~BackgroundSyncProviderThreadProxy(); |
68 | 79 |
69 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 80 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
70 | 81 |
71 // This belongs to the renderer main thread, (created by BlinkPlatformImpl) | 82 // This belongs to the renderer main thread, (created by BlinkPlatformImpl) |
72 // and so should outlive the BackgroundSyncProviderThreadProxy, which is | 83 // and so should outlive the BackgroundSyncProviderThreadProxy, which is |
73 // created for a worker thread. | 84 // created for a worker thread. |
74 BackgroundSyncProvider* sync_provider_; | 85 BackgroundSyncProvider* sync_provider_; |
75 | 86 |
76 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncProviderThreadProxy); | 87 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncProviderThreadProxy); |
77 }; | 88 }; |
78 | 89 |
79 } // namespace content | 90 } // namespace content |
80 | 91 |
81 #endif // CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_THREAD_PROXY_H _ | 92 #endif // CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_THREAD_PROXY_H _ |
OLD | NEW |