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

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

Issue 1358063004: Use mojo to connect to BackgroundSyncManager object (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add back Leaky to TLS instances of provider Created 5 years, 2 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
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_H_ 5 #ifndef CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_H_
6 #define CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_H_ 6 #define CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "content/child/worker_task_runner.h"
12 #include "content/common/background_sync_service.mojom.h" 11 #include "content/common/background_sync_service.mojom.h"
12 #include "content/public/child/worker_thread.h"
13 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncProv ider.h" 13 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncProv ider.h"
14 14
15 namespace base {
16 class SingleThreadTaskRunner;
17 }
18
15 namespace content { 19 namespace content {
16 20
17 class ServiceRegistry;
18
19 // The BackgroundSyncProvider is called by the SyncManager and SyncRegistration 21 // The BackgroundSyncProvider is called by the SyncManager and SyncRegistration
20 // objects (and their Periodic counterparts) and communicates with the 22 // objects (and their Periodic counterparts) and communicates with the
21 // BackgroundSyncManager object in the browser process. This class is 23 // BackgroundSyncManager object in the browser process. Each thread will have
22 // instantiated on the main thread by BlinkPlatformImpl, and its methods can be 24 // its own instance (e.g. main thread, worker threads), instantiated as needed
23 // called directly from the main thread. 25 // by BlinkPlatformImpl. Each instance of the provider creates a new mojo
24 class BackgroundSyncProvider : public blink::WebSyncProvider { 26 // connection to a new BackgroundSyncManagerImpl, which then talks to the
27 // BackgroundSyncManager object.
28 class BackgroundSyncProvider : public blink::WebSyncProvider,
29 public WorkerThread::Observer {
25 public: 30 public:
26 explicit BackgroundSyncProvider(ServiceRegistry* service_registry); 31 ~BackgroundSyncProvider() override;
27 32
28 ~BackgroundSyncProvider() override; 33 static BackgroundSyncProvider* GetOrCreateThreadSpecificInstance(
34 base::SingleThreadTaskRunner* main_thread_task_runner);
29 35
30 // blink::WebSyncProvider implementation 36 // blink::WebSyncProvider implementation
31 void registerBackgroundSync( 37 void registerBackgroundSync(
32 const blink::WebSyncRegistration* options, 38 const blink::WebSyncRegistration* options,
33 blink::WebServiceWorkerRegistration* service_worker_registration, 39 blink::WebServiceWorkerRegistration* service_worker_registration,
34 bool requested_from_service_worker, 40 bool requested_from_service_worker,
35 blink::WebSyncRegistrationCallbacks* callbacks) override; 41 blink::WebSyncRegistrationCallbacks* callbacks) override;
36 void unregisterBackgroundSync( 42 void unregisterBackgroundSync(
37 int64_t handle_id, 43 int64_t handle_id,
38 blink::WebServiceWorkerRegistration* service_worker_registration, 44 blink::WebServiceWorkerRegistration* service_worker_registration,
(...skipping 15 matching lines...) Expand all
54 void releaseRegistration(int64_t handle_id) override; 60 void releaseRegistration(int64_t handle_id) override;
55 void notifyWhenDone( 61 void notifyWhenDone(
56 int64_t handle_id, 62 int64_t handle_id,
57 blink::WebSyncNotifyWhenDoneCallbacks* callbacks) override; 63 blink::WebSyncNotifyWhenDoneCallbacks* callbacks) override;
58 64
59 void DuplicateRegistrationHandle( 65 void DuplicateRegistrationHandle(
60 int64_t handle_id, 66 int64_t handle_id,
61 const BackgroundSyncService::DuplicateRegistrationHandleCallback& 67 const BackgroundSyncService::DuplicateRegistrationHandleCallback&
62 callback); 68 callback);
63 69
70 // WorkerThread::Observer implementation.
71 void WillStopCurrentWorkerThread() override;
72
64 private: 73 private:
74 explicit BackgroundSyncProvider(
75 const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner);
76
65 // Callback handlers 77 // Callback handlers
66 void RegisterCallback( 78 void RegisterCallback(
67 scoped_ptr<blink::WebSyncRegistrationCallbacks> callbacks, 79 scoped_ptr<blink::WebSyncRegistrationCallbacks> callbacks,
68 BackgroundSyncError error, 80 BackgroundSyncError error,
69 const SyncRegistrationPtr& options); 81 const SyncRegistrationPtr& options);
70 void UnregisterCallback( 82 void UnregisterCallback(
71 scoped_ptr<blink::WebSyncUnregistrationCallbacks> callbacks, 83 scoped_ptr<blink::WebSyncUnregistrationCallbacks> callbacks,
72 BackgroundSyncError error); 84 BackgroundSyncError error);
73 void GetRegistrationCallback( 85 void GetRegistrationCallback(
74 scoped_ptr<blink::WebSyncRegistrationCallbacks> callbacks, 86 scoped_ptr<blink::WebSyncRegistrationCallbacks> callbacks,
75 BackgroundSyncError error, 87 BackgroundSyncError error,
76 const SyncRegistrationPtr& options); 88 const SyncRegistrationPtr& options);
77 void GetRegistrationsCallback( 89 void GetRegistrationsCallback(
78 scoped_ptr<blink::WebSyncGetRegistrationsCallbacks> callbacks, 90 scoped_ptr<blink::WebSyncGetRegistrationsCallbacks> callbacks,
79 BackgroundSyncError error, 91 BackgroundSyncError error,
80 const mojo::Array<SyncRegistrationPtr>& registrations); 92 const mojo::Array<SyncRegistrationPtr>& registrations);
81 void GetPermissionStatusCallback( 93 void GetPermissionStatusCallback(
82 scoped_ptr<blink::WebSyncGetPermissionStatusCallbacks> callbacks, 94 scoped_ptr<blink::WebSyncGetPermissionStatusCallbacks> callbacks,
83 BackgroundSyncError error, 95 BackgroundSyncError error,
84 PermissionStatus status); 96 PermissionStatus status);
85 void NotifyWhenDoneCallback( 97 void NotifyWhenDoneCallback(
86 scoped_ptr<blink::WebSyncNotifyWhenDoneCallbacks> callbacks, 98 scoped_ptr<blink::WebSyncNotifyWhenDoneCallbacks> callbacks,
87 BackgroundSyncError error, 99 BackgroundSyncError error,
88 BackgroundSyncState state); 100 BackgroundSyncState state);
89 101
90 // Helper method that returns an initialized BackgroundSyncServicePtr. 102 // Helper method that returns an initialized BackgroundSyncServicePtr.
91 BackgroundSyncServicePtr& GetBackgroundSyncServicePtr(); 103 BackgroundSyncServicePtr& GetBackgroundSyncServicePtr();
92 104
93 ServiceRegistry* service_registry_;
94 BackgroundSyncServicePtr background_sync_service_; 105 BackgroundSyncServicePtr background_sync_service_;
106 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
95 107
96 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncProvider); 108 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncProvider);
97 }; 109 };
98 110
99 } // namespace content 111 } // namespace content
100 112
101 #endif // CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_H_ 113 #endif // CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698