cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / content / child / background_sync / background_sync_provider_thread_proxy.h
blob7b6e8fe0e80a71f71c10953885f4edd3f6fd0c90
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.
5 #ifndef CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_THREAD_PROXY_H_
6 #define CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_THREAD_PROXY_H_
8 #include "base/macros.h"
9 #include "content/child/worker_task_runner.h"
10 #include "content/public/child/worker_thread.h"
11 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncProvider.h"
13 namespace base {
14 class SingleThreadTaskRunner;
17 namespace content {
19 class BackgroundSyncProvider;
21 // BackgroundSyncProviderThreadProxy is a proxy to the BackgroundSyncProvider
22 // for callers running on a different thread than the main thread. There is one
23 // instance per worker thread.
25 // This class handles all of the thread switching, jumping to the main thread to
26 // call the WebSyncProvider methods, and wrapping the callbacks passed in with
27 // code to switch back to the original calling thread.
28 class BackgroundSyncProviderThreadProxy : public blink::WebSyncProvider,
29 public WorkerThread::Observer {
30 public:
31 static BackgroundSyncProviderThreadProxy* GetThreadInstance(
32 base::SingleThreadTaskRunner* main_thread_task_runner,
33 BackgroundSyncProvider* permissions_dispatcher);
35 // blink::WebSyncProvider implementation
36 void registerBackgroundSync(
37 const blink::WebSyncRegistration* options,
38 blink::WebServiceWorkerRegistration* service_worker_registration,
39 bool requested_from_service_worker,
40 blink::WebSyncRegistrationCallbacks* callbacks);
41 void unregisterBackgroundSync(
42 blink::WebSyncRegistration::Periodicity periodicity,
43 int64_t id,
44 const blink::WebString& tag,
45 blink::WebServiceWorkerRegistration* service_worker_registration,
46 blink::WebSyncUnregistrationCallbacks* callbacks);
47 void getRegistration(
48 blink::WebSyncRegistration::Periodicity,
49 const blink::WebString& tag,
50 blink::WebServiceWorkerRegistration* service_worker_registration,
51 blink::WebSyncRegistrationCallbacks* callbacks);
52 void getRegistrations(
53 blink::WebSyncRegistration::Periodicity periodicity,
54 blink::WebServiceWorkerRegistration* service_worker_registration,
55 blink::WebSyncGetRegistrationsCallbacks* callbacks);
56 void getPermissionStatus(
57 blink::WebSyncRegistration::Periodicity periodicity,
58 blink::WebServiceWorkerRegistration* service_worker_registration,
59 blink::WebSyncGetPermissionStatusCallbacks* callbacks);
61 // WorkerThread::Observer implementation.
62 void WillStopCurrentWorkerThread() override;
64 private:
65 BackgroundSyncProviderThreadProxy(
66 base::SingleThreadTaskRunner* main_thread_task_runner,
67 BackgroundSyncProvider* sync_provider);
69 virtual ~BackgroundSyncProviderThreadProxy();
71 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
73 // This belongs to the renderer main thread, (created by BlinkPlatformImpl)
74 // and so should outlive the BackgroundSyncProviderThreadProxy, which is
75 // created for a worker thread.
76 BackgroundSyncProvider* sync_provider_;
78 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncProviderThreadProxy);
81 } // namespace content
83 #endif // CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_THREAD_PROXY_H_