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

Unified 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 browser tests Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: content/child/background_sync/background_sync_provider.h
diff --git a/content/child/background_sync/background_sync_provider.h b/content/child/background_sync/background_sync_provider.h
index 0dc6d6c3a56d2acdad12b756f4369698ad532373..bf5489f42493d774948f76c8b5350363e857abac 100644
--- a/content/child/background_sync/background_sync_provider.h
+++ b/content/child/background_sync/background_sync_provider.h
@@ -8,24 +8,27 @@
#include <string>
#include "base/memory/scoped_ptr.h"
-#include "content/child/worker_task_runner.h"
#include "content/common/background_sync_service.mojom.h"
+#include "content/public/child/worker_thread.h"
#include "third_party/WebKit/public/platform/modules/background_sync/WebSyncProvider.h"
-namespace content {
+namespace base {
+class SingleThreadTaskRunner;
+}
-class ServiceRegistry;
+namespace content {
// The BackgroundSyncProvider is called by the SyncManager and SyncRegistration
// objects (and their Periodic counterparts) and communicates with the
-// BackgroundSyncManager object in the browser process. This class is
-// instantiated on the main thread by BlinkPlatformImpl, and its methods can be
-// called directly from the main thread.
-class BackgroundSyncProvider : public blink::WebSyncProvider {
+// BackgroundSyncManager object in the browser process. Each thread will have
jkarlin 2015/09/28 20:10:05 It communicates with the BackgroundSyncManager via
chasej 2015/10/08 03:28:53 Acknowledged.
+// its own instance (e.g. main thread, worker threads), instantiated as needed
+// by BlinkPlatformImpl. Each instance of the provider will create a separate
+// mojo connection to the BackgroundSyncManager object in the browser process.
jkarlin 2015/09/28 20:10:05 Each instance creates a new mojo connection to a n
chasej 2015/10/08 03:28:53 Comment updated to be more precise about the behav
+class BackgroundSyncProvider : public blink::WebSyncProvider,
+ public WorkerThread::Observer {
public:
- explicit BackgroundSyncProvider(ServiceRegistry* service_registry);
-
- ~BackgroundSyncProvider() override;
+ static BackgroundSyncProvider* GetThreadInstance(
+ base::SingleThreadTaskRunner* main_thread_task_runner);
// blink::WebSyncProvider implementation
// TODO(jkarlin) convert int64_t handle_id to int handle_id in all
@@ -66,7 +69,15 @@ class BackgroundSyncProvider : public blink::WebSyncProvider {
const BackgroundSyncService::DuplicateRegistrationHandleCallback&
callback);
+ // WorkerThread::Observer implementation.
+ void WillStopCurrentWorkerThread() override;
jkarlin 2015/09/28 20:12:51 I see how worker threads get killed, thanks to thi
michaeln 2015/10/02 00:13:08 For other threadspecific classes like this, the in
+
private:
+ explicit BackgroundSyncProvider(
+ const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner);
+
+ ~BackgroundSyncProvider() override;
+
// Callback handlers
void RegisterCallback(
scoped_ptr<blink::WebSyncRegistrationCallbacks> callbacks,
@@ -95,8 +106,8 @@ class BackgroundSyncProvider : public blink::WebSyncProvider {
// Helper method that returns an initialized BackgroundSyncServicePtr.
BackgroundSyncServicePtr& GetBackgroundSyncServicePtr();
- ServiceRegistry* service_registry_;
BackgroundSyncServicePtr background_sync_service_;
+ scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
DISALLOW_COPY_AND_ASSIGN(BackgroundSyncProvider);
};

Powered by Google App Engine
This is Rietveld 408576698