OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_THREAD_PROXY_H_ |
| 6 #define CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_THREAD_PROXY_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "content/child/worker_task_runner.h" |
| 10 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncProv
ider.h" |
| 11 |
| 12 namespace base { |
| 13 class SingleThreadTaskRunner; |
| 14 } |
| 15 |
| 16 namespace content { |
| 17 |
| 18 class BackgroundSyncProvider; |
| 19 |
| 20 // BackgroundSyncProviderThreadProxy is a proxy to the BackgroundSyncProvider |
| 21 // for callers running on a different thread than the main thread. There is one |
| 22 // instance per worker thread. |
| 23 // |
| 24 // 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 // code to switch back to the original calling thread. |
| 27 class BackgroundSyncProviderThreadProxy : public blink::WebSyncProvider, |
| 28 public WorkerTaskRunner::Observer { |
| 29 public: |
| 30 static BackgroundSyncProviderThreadProxy* GetThreadInstance( |
| 31 base::SingleThreadTaskRunner* main_thread_task_runner, |
| 32 BackgroundSyncProvider* permissions_dispatcher); |
| 33 |
| 34 // blink::WebSyncProvider implementation |
| 35 void registerBackgroundSync( |
| 36 const blink::WebSyncRegistration* options, |
| 37 blink::WebServiceWorkerRegistration* service_worker_registration, |
| 38 blink::WebSyncRegistrationCallbacks* callbacks); |
| 39 void unregisterBackgroundSync( |
| 40 blink::WebSyncRegistration::Periodicity periodicity, |
| 41 int64_t id, |
| 42 const blink::WebString& tag, |
| 43 blink::WebServiceWorkerRegistration* service_worker_registration, |
| 44 blink::WebSyncUnregistrationCallbacks* callbacks); |
| 45 void getRegistration( |
| 46 blink::WebSyncRegistration::Periodicity, |
| 47 const blink::WebString& tag, |
| 48 blink::WebServiceWorkerRegistration* service_worker_registration, |
| 49 blink::WebSyncRegistrationCallbacks* callbacks); |
| 50 void getRegistrations( |
| 51 blink::WebSyncRegistration::Periodicity periodicity, |
| 52 blink::WebServiceWorkerRegistration* service_worker_registration, |
| 53 blink::WebSyncGetRegistrationsCallbacks* callbacks); |
| 54 |
| 55 // WorkerTaskRunner::Observer implementation. |
| 56 void OnWorkerRunLoopStopped() override; |
| 57 |
| 58 private: |
| 59 BackgroundSyncProviderThreadProxy( |
| 60 base::SingleThreadTaskRunner* main_thread_task_runner, |
| 61 BackgroundSyncProvider* sync_provider); |
| 62 |
| 63 virtual ~BackgroundSyncProviderThreadProxy(); |
| 64 |
| 65 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
| 66 |
| 67 // This belongs to the renderer main thread, (created by BlinkPlatformImpl) |
| 68 // and so should outlive the BackgroundSyncProviderThreadProxy, which is |
| 69 // created for a worker thread. |
| 70 BackgroundSyncProvider* sync_provider_; |
| 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncProviderThreadProxy); |
| 73 }; |
| 74 |
| 75 } // namespace content |
| 76 |
| 77 #endif // CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_THREAD_PROXY_H
_ |
OLD | NEW |