Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(595)

Side by Side Diff: content/child/background_sync/background_sync_provider_thread_proxy.h

Issue 1104283002: [Background Sync] Add renderer code to interface between JS API and back-end service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bgsync-mojo
Patch Set: Move CallbackThreadAdapter template into implementation file Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 of that class per thread.
jkarlin 2015/05/12 13:19:51 s/of that class per thread/per worker thread/g
iclelland 2015/05/12 14:40:05 Done.
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 :
28 public blink::WebSyncProvider,
29 public WorkerTaskRunner::Observer {
30
31 public:
32 static BackgroundSyncProviderThreadProxy* GetThreadInstance(
33 base::SingleThreadTaskRunner* main_thread_task_runner,
34 BackgroundSyncProvider* permissions_dispatcher);
35
36 // blink::WebSyncProvider implementation
37 void registerBackgroundSync(
38 const blink::WebSyncRegistration* options,
39 blink::WebServiceWorkerRegistration* service_worker_registration,
40 blink::WebSyncRegistrationCallbacks* callbacks);
41 void unregisterBackgroundSync(
42 blink::WebSyncRegistration::Periodicity periodicity,
43 int64_t id, const blink::WebString& tag,
44 blink::WebServiceWorkerRegistration* service_worker_registration,
45 blink::WebSyncUnregistrationCallbacks* callbacks);
46 void getRegistration(
47 blink::WebSyncRegistration::Periodicity,
48 const blink::WebString& tag,
49 blink::WebServiceWorkerRegistration* service_worker_registration,
50 blink::WebSyncRegistrationCallbacks* callbacks);
51 void getRegistrations(
52 blink::WebSyncRegistration::Periodicity periodicity,
53 blink::WebServiceWorkerRegistration* service_worker_registration,
54 blink::WebSyncGetRegistrationsCallbacks* callbacks);
55
56 // WorkerTaskRunner::Observer implementation.
57 void OnWorkerRunLoopStopped() override;
58
59 private:
60 BackgroundSyncProviderThreadProxy(
61 base::SingleThreadTaskRunner* main_thread_task_runner,
62 BackgroundSyncProvider* sync_provider);
63
64 virtual ~BackgroundSyncProviderThreadProxy();
65
66 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
jkarlin 2015/05/12 13:19:51 insert vertical space here so that you can more ea
iclelland 2015/05/12 14:40:05 Done.
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698