summaryrefslogtreecommitdiffstats
path: root/content/child
diff options
context:
space:
mode:
authorchasej <chasej@chromium.org>2015-10-19 19:52:50 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-20 02:53:35 +0000
commitf993b733666c5c3664889be5c61b65f3f48b222d (patch)
tree689c887706e0f245f31ec13d3e8409c2da3717c6 /content/child
parent8b060a56ea1303e48ecf1a28bbdd7bd9d8f57a43 (diff)
downloadchromium_src-f993b733666c5c3664889be5c61b65f3f48b222d.zip
chromium_src-f993b733666c5c3664889be5c61b65f3f48b222d.tar.gz
chromium_src-f993b733666c5c3664889be5c61b65f3f48b222d.tar.bz2
Use mojo to connect to BackgroundSyncManager object
Removes the BackgroundSyncProviderThreadProxy class, and the manual hopping from workers to the main thread. The proxy class was passing WebStrings across threads, which aren't thread-safe. With mojo connections, it lets mojo handle the thread hopping more efficiently, and the mojo structs passed are thread-safe. Tested using https://jakearchibald.github.io/isserviceworkerready/demos/sync/, as well as new browser tests. BUG=527601 Review URL: https://codereview.chromium.org/1358063004 Cr-Commit-Position: refs/heads/master@{#354963}
Diffstat (limited to 'content/child')
-rw-r--r--content/child/background_sync/background_sync_provider.cc65
-rw-r--r--content/child/background_sync/background_sync_provider.h35
-rw-r--r--content/child/background_sync/background_sync_provider_thread_proxy.cc253
-rw-r--r--content/child/background_sync/background_sync_provider_thread_proxy.h95
-rw-r--r--content/child/blink_platform_impl.cc14
-rw-r--r--content/child/blink_platform_impl.h2
6 files changed, 90 insertions, 374 deletions
diff --git a/content/child/background_sync/background_sync_provider.cc b/content/child/background_sync/background_sync_provider.cc
index 57f3d56..fb93ed3 100644
--- a/content/child/background_sync/background_sync_provider.cc
+++ b/content/child/background_sync/background_sync_provider.cc
@@ -5,16 +5,21 @@
#include "content/child/background_sync/background_sync_provider.h"
#include "base/bind.h"
+#include "base/lazy_instance.h"
#include "base/memory/scoped_ptr.h"
+#include "base/single_thread_task_runner.h"
+#include "base/threading/thread_local.h"
#include "content/child/background_sync/background_sync_type_converters.h"
+#include "content/child/child_thread_impl.h"
#include "content/child/service_worker/web_service_worker_registration_impl.h"
-#include "content/child/worker_task_runner.h"
#include "content/public/common/background_sync.mojom.h"
#include "content/public/common/permission_status.mojom.h"
-#include "content/public/common/service_registry.h"
#include "third_party/WebKit/public/platform/modules/background_sync/WebSyncError.h"
#include "third_party/WebKit/public/platform/modules/background_sync/WebSyncRegistration.h"
+using base::LazyInstance;
+using base::ThreadLocalPointer;
+
namespace content {
namespace {
@@ -26,15 +31,54 @@ int64 GetServiceWorkerRegistrationId(
service_worker_registration)->registration_id();
}
+void ConnectToServiceOnMainThread(
+ mojo::InterfaceRequest<BackgroundSyncService> request) {
+ DCHECK(ChildThreadImpl::current());
+ ChildThreadImpl::current()->service_registry()->ConnectToRemoteService(
+ request.Pass());
+}
+
+LazyInstance<ThreadLocalPointer<BackgroundSyncProvider>>::Leaky
+ g_sync_provider_tls = LAZY_INSTANCE_INITIALIZER;
+
} // namespace
BackgroundSyncProvider::BackgroundSyncProvider(
- ServiceRegistry* service_registry)
- : service_registry_(service_registry) {
- DCHECK(service_registry);
+ const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner)
+ : main_thread_task_runner_(main_task_runner) {
+ DCHECK(main_task_runner);
+ g_sync_provider_tls.Pointer()->Set(this);
}
BackgroundSyncProvider::~BackgroundSyncProvider() {
+ g_sync_provider_tls.Pointer()->Set(nullptr);
+}
+
+// static
+BackgroundSyncProvider*
+BackgroundSyncProvider::GetOrCreateThreadSpecificInstance(
+ base::SingleThreadTaskRunner* main_thread_task_runner) {
+ DCHECK(main_thread_task_runner);
+ if (g_sync_provider_tls.Pointer()->Get())
+ return g_sync_provider_tls.Pointer()->Get();
+
+ bool have_worker_id = (WorkerThread::GetCurrentId() > 0);
+ if (!main_thread_task_runner->BelongsToCurrentThread() && !have_worker_id) {
+ // On a worker thread, this could happen if this method is called
+ // very late (say by a garbage collected SyncRegistration).
+ return nullptr;
+ }
+
+ BackgroundSyncProvider* instance =
+ new BackgroundSyncProvider(main_thread_task_runner);
+
+ if (have_worker_id) {
+ // For worker threads, use the observer interface to clean up when workers
+ // are stopped.
+ WorkerThread::AddObserver(instance);
+ }
+
+ return instance;
}
void BackgroundSyncProvider::registerBackgroundSync(
@@ -163,6 +207,10 @@ void BackgroundSyncProvider::DuplicateRegistrationHandle(
callback);
}
+void BackgroundSyncProvider::WillStopCurrentWorkerThread() {
+ delete this;
+}
+
void BackgroundSyncProvider::RegisterCallback(
scoped_ptr<blink::WebSyncRegistrationCallbacks> callbacks,
BackgroundSyncError error,
@@ -376,8 +424,11 @@ void BackgroundSyncProvider::NotifyWhenDoneCallback(
BackgroundSyncServicePtr&
BackgroundSyncProvider::GetBackgroundSyncServicePtr() {
if (!background_sync_service_.get()) {
- service_registry_->ConnectToRemoteService(
- mojo::GetProxy(&background_sync_service_));
+ mojo::InterfaceRequest<BackgroundSyncService> request =
+ mojo::GetProxy(&background_sync_service_);
+ main_thread_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&ConnectToServiceOnMainThread, base::Passed(&request)));
}
return background_sync_service_;
}
diff --git a/content/child/background_sync/background_sync_provider.h b/content/child/background_sync/background_sync_provider.h
index cb4f6af..66460cf 100644
--- a/content/child/background_sync/background_sync_provider.h
+++ b/content/child/background_sync/background_sync_provider.h
@@ -8,25 +8,39 @@
#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
+// its own instance (e.g. main thread, worker threads), instantiated as needed
+// by BlinkPlatformImpl. Each instance of the provider creates a new mojo
+// connection to a new BackgroundSyncManagerImpl, which then talks to the
+// BackgroundSyncManager object.
+class BackgroundSyncProvider : public blink::WebSyncProvider,
+ public WorkerThread::Observer {
public:
- explicit BackgroundSyncProvider(ServiceRegistry* service_registry);
+ // Constructor made public to allow BlinkPlatformImpl to own a copy for the
+ // main thread. Everyone else should use GetOrCreateThreadSpecificInstance().
+ explicit BackgroundSyncProvider(
+ const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner);
~BackgroundSyncProvider() override;
+ // Returns thread-specific instance (if exists). Otherwise, a new instance
+ // will be created for the thread, except when called for a worker thread that
+ // has already been stopped.
+ static BackgroundSyncProvider* GetOrCreateThreadSpecificInstance(
+ base::SingleThreadTaskRunner* main_thread_task_runner);
+
// blink::WebSyncProvider implementation
void registerBackgroundSync(
const blink::WebSyncRegistration* options,
@@ -61,6 +75,9 @@ class BackgroundSyncProvider : public blink::WebSyncProvider {
const BackgroundSyncService::DuplicateRegistrationHandleCallback&
callback);
+ // WorkerThread::Observer implementation.
+ void WillStopCurrentWorkerThread() override;
+
private:
// Callback handlers
void RegisterCallback(
@@ -90,8 +107,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);
};
diff --git a/content/child/background_sync/background_sync_provider_thread_proxy.cc b/content/child/background_sync/background_sync_provider_thread_proxy.cc
deleted file mode 100644
index 021df27..0000000
--- a/content/child/background_sync/background_sync_provider_thread_proxy.cc
+++ /dev/null
@@ -1,253 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/child/background_sync/background_sync_provider_thread_proxy.h"
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/lazy_instance.h"
-#include "base/location.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/single_thread_task_runner.h"
-#include "base/threading/thread_local.h"
-#include "content/child/background_sync/background_sync_provider.h"
-
-using base::LazyInstance;
-using base::ThreadLocalPointer;
-
-namespace content {
-
-namespace {
-
-template <typename T>
-struct WebCallbacksMatcher;
-
-template <typename Stype, typename Ttype>
-struct WebCallbacksMatcher<blink::WebCallbacks<Stype, Ttype>> {
- using S = Stype;
- using T = Ttype;
- using WebCallbacks = typename blink::WebCallbacks<S, T>;
-};
-
-// CallbackThreadAdapter<WebCallbacks<S, T>> is a wrapper for WebCallbacks<S, T>
-// which switches to a specific thread before calling the wrapped callback's
-// onSuccess or onError methods.
-//
-// Takes ownership of the WebCallbacks object which it wraps.
-template <typename X>
-class CallbackThreadAdapter : public WebCallbacksMatcher<X>::WebCallbacks {
- using S = typename WebCallbacksMatcher<X>::S;
- using T = typename WebCallbacksMatcher<X>::T;
- using OnSuccessType = void (blink::WebCallbacks<S, T>::*)(S);
- using OnErrorType = void (blink::WebCallbacks<S, T>::*)(T);
-
- public:
- CallbackThreadAdapter(scoped_ptr<blink::WebCallbacks<S, T>> callbacks,
- int worker_thread_id)
- : worker_thread_id_(worker_thread_id) {
- callbacks_.reset(callbacks.release());
- }
-
- virtual void onSuccess(S results) {
- OnSuccessType on_success = &blink::WebCallbacks<S, T>::onSuccess;
- // If the worker thread has been destroyed, then this task will be
- // silently discarded.
- WorkerTaskRunner::Instance()->PostTask(
- worker_thread_id_,
- base::Bind(on_success, base::Owned(callbacks_.release()), results));
- }
-
- virtual void onError(T error) {
- OnErrorType on_error = &blink::WebCallbacks<S, T>::onError;
- // If the worker thread has been destroyed, then this task will be
- // silently discarded.
- WorkerTaskRunner::Instance()->PostTask(
- worker_thread_id_,
- base::Bind(on_error, base::Owned(callbacks_.release()), error));
- }
-
- private:
- scoped_ptr<blink::WebCallbacks<S, T>> callbacks_;
- int worker_thread_id_;
-};
-
-LazyInstance<ThreadLocalPointer<BackgroundSyncProviderThreadProxy>>::Leaky
- g_sync_provider_tls = LAZY_INSTANCE_INITIALIZER;
-
-void DuplicateRegistrationHandleCallbackOnSWThread(
- const BackgroundSyncProviderThreadProxy::
- DuplicateRegistrationHandleCallback& callback,
- BackgroundSyncError error,
- SyncRegistrationPtr registration) {
- callback.Run(error, registration.Pass());
-}
-
-void DuplicateRegistrationHandleCallbackOnMainThread(
- int worker_thread_id,
- const BackgroundSyncProviderThreadProxy::
- DuplicateRegistrationHandleCallback& callback,
- BackgroundSyncError error,
- SyncRegistrationPtr registration) {
- WorkerTaskRunner::Instance()->PostTask(
- worker_thread_id,
- base::Bind(&DuplicateRegistrationHandleCallbackOnSWThread, callback,
- error, base::Passed(registration.Pass())));
-}
-
-} // anonymous namespace
-
-// static
-BackgroundSyncProviderThreadProxy*
-BackgroundSyncProviderThreadProxy::GetThreadInstance(
- base::SingleThreadTaskRunner* main_thread_task_runner,
- BackgroundSyncProvider* sync_provider) {
- if (g_sync_provider_tls.Pointer()->Get())
- return g_sync_provider_tls.Pointer()->Get();
-
- if (!WorkerThread::GetCurrentId()) {
- // This could happen if GetThreadInstance is called very late (say by a
- // garbage collected SyncRegistration).
- return nullptr;
- }
-
- BackgroundSyncProviderThreadProxy* instance =
- new BackgroundSyncProviderThreadProxy(main_thread_task_runner,
- sync_provider);
- WorkerThread::AddObserver(instance);
- return instance;
-}
-
-void BackgroundSyncProviderThreadProxy::registerBackgroundSync(
- const blink::WebSyncRegistration* options,
- blink::WebServiceWorkerRegistration* service_worker_registration,
- bool requested_from_service_worker,
- blink::WebSyncRegistrationCallbacks* callbacks) {
- DCHECK(options);
- DCHECK(service_worker_registration);
- DCHECK(callbacks);
- main_thread_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(
- &BackgroundSyncProvider::registerBackgroundSync,
- base::Unretained(sync_provider_), options,
- service_worker_registration, requested_from_service_worker,
- new CallbackThreadAdapter<blink::WebSyncRegistrationCallbacks>(
- make_scoped_ptr(callbacks), WorkerThread::GetCurrentId())));
-}
-
-void BackgroundSyncProviderThreadProxy::unregisterBackgroundSync(
- int64_t handle_id,
- blink::WebServiceWorkerRegistration* service_worker_registration,
- blink::WebSyncUnregistrationCallbacks* callbacks) {
- DCHECK(service_worker_registration);
- DCHECK(callbacks);
- main_thread_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(
- &BackgroundSyncProvider::unregisterBackgroundSync,
- base::Unretained(sync_provider_), handle_id,
- service_worker_registration,
- new CallbackThreadAdapter<blink::WebSyncUnregistrationCallbacks>(
- make_scoped_ptr(callbacks), WorkerThread::GetCurrentId())));
-}
-
-void BackgroundSyncProviderThreadProxy::getRegistration(
- blink::WebSyncRegistration::Periodicity periodicity,
- const blink::WebString& tag,
- blink::WebServiceWorkerRegistration* service_worker_registration,
- blink::WebSyncRegistrationCallbacks* callbacks) {
- DCHECK(service_worker_registration);
- DCHECK(callbacks);
- main_thread_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(
- &BackgroundSyncProvider::getRegistration,
- base::Unretained(sync_provider_), periodicity,
- // We cast WebString to string16 before crossing threads
- // for thread-safety.
- static_cast<base::string16>(tag), service_worker_registration,
- new CallbackThreadAdapter<blink::WebSyncRegistrationCallbacks>(
- make_scoped_ptr(callbacks), WorkerThread::GetCurrentId())));
-}
-
-void BackgroundSyncProviderThreadProxy::getRegistrations(
- blink::WebSyncRegistration::Periodicity periodicity,
- blink::WebServiceWorkerRegistration* service_worker_registration,
- blink::WebSyncGetRegistrationsCallbacks* callbacks) {
- DCHECK(service_worker_registration);
- DCHECK(callbacks);
- main_thread_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(
- &BackgroundSyncProvider::getRegistrations,
- base::Unretained(sync_provider_), periodicity,
- service_worker_registration,
- new CallbackThreadAdapter<blink::WebSyncGetRegistrationsCallbacks>(
- make_scoped_ptr(callbacks), WorkerThread::GetCurrentId())));
-}
-
-void BackgroundSyncProviderThreadProxy::getPermissionStatus(
- blink::WebSyncRegistration::Periodicity periodicity,
- blink::WebServiceWorkerRegistration* service_worker_registration,
- blink::WebSyncGetPermissionStatusCallbacks* callbacks) {
- DCHECK(service_worker_registration);
- DCHECK(callbacks);
- main_thread_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(
- &BackgroundSyncProvider::getPermissionStatus,
- base::Unretained(sync_provider_), periodicity,
- service_worker_registration,
- new CallbackThreadAdapter<blink::WebSyncGetPermissionStatusCallbacks>(
- make_scoped_ptr(callbacks), WorkerThread::GetCurrentId())));
-}
-
-void BackgroundSyncProviderThreadProxy::releaseRegistration(int64_t handle_id) {
- main_thread_task_runner_->PostTask(
- FROM_HERE, base::Bind(&BackgroundSyncProvider::releaseRegistration,
- base::Unretained(sync_provider_), handle_id));
-}
-
-void BackgroundSyncProviderThreadProxy::notifyWhenDone(
- int64_t handle_id,
- blink::WebSyncNotifyWhenDoneCallbacks* callbacks) {
- DCHECK(callbacks);
-
- main_thread_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(
- &BackgroundSyncProvider::notifyWhenDone,
- base::Unretained(sync_provider_), handle_id,
- new CallbackThreadAdapter<blink::WebSyncNotifyWhenDoneCallbacks>(
- make_scoped_ptr(callbacks), WorkerThread::GetCurrentId())));
-}
-
-void BackgroundSyncProviderThreadProxy::DuplicateRegistrationHandle(
- int64_t handle_id,
- const DuplicateRegistrationHandleCallback& callback) {
- main_thread_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&BackgroundSyncProvider::DuplicateRegistrationHandle,
- base::Unretained(sync_provider_), handle_id,
- base::Bind(&DuplicateRegistrationHandleCallbackOnMainThread,
- WorkerThread::GetCurrentId(), callback)));
-}
-
-void BackgroundSyncProviderThreadProxy::WillStopCurrentWorkerThread() {
- delete this;
-}
-
-BackgroundSyncProviderThreadProxy::BackgroundSyncProviderThreadProxy(
- base::SingleThreadTaskRunner* main_thread_task_runner,
- BackgroundSyncProvider* sync_provider)
- : main_thread_task_runner_(main_thread_task_runner),
- sync_provider_(sync_provider) {
- g_sync_provider_tls.Pointer()->Set(this);
-}
-
-BackgroundSyncProviderThreadProxy::~BackgroundSyncProviderThreadProxy() {
- g_sync_provider_tls.Pointer()->Set(nullptr);
-}
-
-} // namespace content
diff --git a/content/child/background_sync/background_sync_provider_thread_proxy.h b/content/child/background_sync/background_sync_provider_thread_proxy.h
deleted file mode 100644
index f48a479..0000000
--- a/content/child/background_sync/background_sync_provider_thread_proxy.h
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_THREAD_PROXY_H_
-#define CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_THREAD_PROXY_H_
-
-#include "base/macros.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 base {
-class SingleThreadTaskRunner;
-}
-
-namespace content {
-
-class BackgroundSyncProvider;
-
-// BackgroundSyncProviderThreadProxy is a proxy to the BackgroundSyncProvider
-// for callers running on a different thread than the main thread. There is one
-// instance per worker thread.
-//
-// This class handles all of the thread switching, jumping to the main thread to
-// call the WebSyncProvider methods, and wrapping the callbacks passed in with
-// code to switch back to the original calling thread.
-class BackgroundSyncProviderThreadProxy : public blink::WebSyncProvider,
- public WorkerThread::Observer {
- public:
- using DuplicateRegistrationHandleCallback =
- base::Callback<void(BackgroundSyncError, SyncRegistrationPtr)>;
-
- static BackgroundSyncProviderThreadProxy* GetThreadInstance(
- base::SingleThreadTaskRunner* main_thread_task_runner,
- BackgroundSyncProvider* permissions_dispatcher);
-
- // blink::WebSyncProvider implementation
- void registerBackgroundSync(
- const blink::WebSyncRegistration* options,
- blink::WebServiceWorkerRegistration* service_worker_registration,
- bool requested_from_service_worker,
- blink::WebSyncRegistrationCallbacks* callbacks) override;
- void unregisterBackgroundSync(
- int64_t handle_id,
- blink::WebServiceWorkerRegistration* service_worker_registration,
- blink::WebSyncUnregistrationCallbacks* callbacks) override;
- void getRegistration(
- blink::WebSyncRegistration::Periodicity,
- const blink::WebString& tag,
- blink::WebServiceWorkerRegistration* service_worker_registration,
- blink::WebSyncRegistrationCallbacks* callbacks) override;
- void getRegistrations(
- blink::WebSyncRegistration::Periodicity periodicity,
- blink::WebServiceWorkerRegistration* service_worker_registration,
- blink::WebSyncGetRegistrationsCallbacks* callbacks) override;
- void getPermissionStatus(
- blink::WebSyncRegistration::Periodicity periodicity,
- blink::WebServiceWorkerRegistration* service_worker_registration,
- blink::WebSyncGetPermissionStatusCallbacks* callbacks) override;
- void releaseRegistration(int64_t handle_id) override;
- void notifyWhenDone(
- int64_t handle_id,
- blink::WebSyncNotifyWhenDoneCallbacks* callbacks) override;
-
- // Given |handle_id|, ask the provider for a new handle with the same
- // underlying registration.
- void DuplicateRegistrationHandle(
- int64_t handle_id,
- const DuplicateRegistrationHandleCallback& callback);
-
- // WorkerThread::Observer implementation.
- void WillStopCurrentWorkerThread() override;
-
- private:
- BackgroundSyncProviderThreadProxy(
- base::SingleThreadTaskRunner* main_thread_task_runner,
- BackgroundSyncProvider* sync_provider);
-
- ~BackgroundSyncProviderThreadProxy() override;
-
- scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
-
- // This belongs to the renderer main thread, (created by BlinkPlatformImpl)
- // and so should outlive the BackgroundSyncProviderThreadProxy, which is
- // created for a worker thread.
- BackgroundSyncProvider* sync_provider_;
-
- DISALLOW_COPY_AND_ASSIGN(BackgroundSyncProviderThreadProxy);
-};
-
-} // namespace content
-
-#endif // CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_THREAD_PROXY_H_
diff --git a/content/child/blink_platform_impl.cc b/content/child/blink_platform_impl.cc
index 3b26b61..16f06ad 100644
--- a/content/child/blink_platform_impl.cc
+++ b/content/child/blink_platform_impl.cc
@@ -39,7 +39,6 @@
#include "content/app/resources/grit/content_resources.h"
#include "content/app/strings/grit/content_strings.h"
#include "content/child/background_sync/background_sync_provider.h"
-#include "content/child/background_sync/background_sync_provider_thread_proxy.h"
#include "content/child/child_thread_impl.h"
#include "content/child/content_child_helpers.h"
#include "content/child/geofencing/web_geofencing_provider_impl.h"
@@ -460,8 +459,8 @@ void BlinkPlatformImpl::InternalInit() {
push_dispatcher_ = ChildThreadImpl::current()->push_dispatcher();
permission_client_.reset(new PermissionDispatcher(
ChildThreadImpl::current()->service_registry()));
- sync_provider_.reset(new BackgroundSyncProvider(
- ChildThreadImpl::current()->service_registry()));
+ main_thread_sync_provider_.reset(
+ new BackgroundSyncProvider(main_thread_task_runner_.get()));
}
}
@@ -1215,14 +1214,11 @@ blink::WebPermissionClient* BlinkPlatformImpl::permissionClient() {
}
blink::WebSyncProvider* BlinkPlatformImpl::backgroundSyncProvider() {
- if (!sync_provider_.get())
- return nullptr;
-
if (IsMainThread())
- return sync_provider_.get();
+ return main_thread_sync_provider_.get();
- return BackgroundSyncProviderThreadProxy::GetThreadInstance(
- main_thread_task_runner_.get(), sync_provider_.get());
+ return BackgroundSyncProvider::GetOrCreateThreadSpecificInstance(
+ main_thread_task_runner_.get());
}
WebThemeEngine* BlinkPlatformImpl::themeEngine() {
diff --git a/content/child/blink_platform_impl.h b/content/child/blink_platform_impl.h
index f9bf754..4f23575 100644
--- a/content/child/blink_platform_impl.h
+++ b/content/child/blink_platform_impl.h
@@ -209,7 +209,7 @@ class CONTENT_EXPORT BlinkPlatformImpl
scoped_refptr<NotificationDispatcher> notification_dispatcher_;
scoped_refptr<PushDispatcher> push_dispatcher_;
scoped_ptr<PermissionDispatcher> permission_client_;
- scoped_ptr<BackgroundSyncProvider> sync_provider_;
+ scoped_ptr<BackgroundSyncProvider> main_thread_sync_provider_;
};
} // namespace content