| 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
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..bec32a97d6386882a3797bec51229639bf55e990
|
| --- /dev/null
|
| +++ b/content/child/background_sync/background_sync_provider.h
|
| @@ -0,0 +1,96 @@
|
| +// 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_H_
|
| +#define CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_H_
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "content/child/worker_task_runner.h"
|
| +#include "content/common/background_sync_service.mojom.h"
|
| +#include "third_party/WebKit/public/platform/modules/background_sync/WebSyncProvider.h"
|
| +
|
| +namespace content {
|
| +
|
| +class ServiceRegistry;
|
| +
|
| +// 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.
|
| +//
|
| +// When being called from a worker thread, this class is called through a
|
| +// BackgroundSyncProviderThreadProxy, which will call the *ForWorker methods,
|
| +// passing a worker thread id.
|
| +class BackgroundSyncProvider : public blink::WebSyncProvider {
|
| + public:
|
| + explicit BackgroundSyncProvider(ServiceRegistry* service_registry);
|
| +
|
| + ~BackgroundSyncProvider() override;
|
| +
|
| + // blink::WebSyncProvider implementation
|
| + void registerBackgroundSync(
|
| + const blink::WebSyncRegistration* options,
|
| + blink::WebServiceWorkerRegistration* service_worker_registration,
|
| + blink::WebSyncRegistrationCallbacks* callbacks);
|
| + void unregisterBackgroundSync(
|
| + blink::WebSyncRegistration::Periodicity periodicity,
|
| + int64_t id, const blink::WebString& tag,
|
| + blink::WebServiceWorkerRegistration* service_worker_registration,
|
| + blink::WebSyncUnregistrationCallbacks* callbacks);
|
| + void getRegistration(
|
| + blink::WebSyncRegistration::Periodicity,
|
| + const blink::WebString& tag,
|
| + blink::WebServiceWorkerRegistration* service_worker_registration,
|
| + blink::WebSyncRegistrationCallbacks* callbacks);
|
| + void getRegistrations(
|
| + blink::WebSyncRegistration::Periodicity periodicity,
|
| + blink::WebServiceWorkerRegistration* service_worker_registration,
|
| + blink::WebSyncGetRegistrationsCallbacks* callbacks);
|
| +
|
| + // Entry points for Background Sync API calls from worker threads
|
| + void RegisterBackgroundSyncForWorker(
|
| + scoped_ptr<blink::WebSyncRegistration> options,
|
| + blink::WebServiceWorkerRegistration* service_worker_registration,
|
| + blink::WebSyncRegistrationCallbacks* callbacks, int worker_thread_id);
|
| + void UnregisterBackgroundSyncForWorker(
|
| + blink::WebSyncRegistration::Periodicity periodicity, int64_t id,
|
| + const blink::WebString& tag,
|
| + blink::WebServiceWorkerRegistration* service_worker_registration,
|
| + blink::WebSyncUnregistrationCallbacks* callbacks, int worker_thread_id);
|
| + void GetRegistrationForWorker(
|
| + blink::WebSyncRegistration::Periodicity periodicity,
|
| + const blink::WebString& tag,
|
| + blink::WebServiceWorkerRegistration* service_worker_registration,
|
| + blink::WebSyncRegistrationCallbacks* callbacks, int worker_thread_id);
|
| + void GetRegistrationsForWorker(
|
| + blink::WebSyncRegistration::Periodicity periodicity,
|
| + blink::WebServiceWorkerRegistration* service_worker_registration,
|
| + blink::WebSyncGetRegistrationsCallbacks* callbacks, int worker_thread_id);
|
| +
|
| + private:
|
| + // Callback handlers
|
| + void RegisterCallback(blink::WebSyncRegistrationCallbacks* callbacks,
|
| + int worker_thread_id,
|
| + const SyncRegistrationPtr &options);
|
| + void UnregisterCallback(blink::WebSyncUnregistrationCallbacks* callbacks,
|
| + int worker_thread_id, bool success);
|
| + void GetRegistrationsCallback(
|
| + blink::WebSyncGetRegistrationsCallbacks* callbacks, int worker_thread_id,
|
| + const mojo::Array<SyncRegistrationPtr> ®istrations);
|
| +
|
| + // Helper method that returns an initialized BackgroundSyncServicePtr.
|
| + BackgroundSyncServicePtr& GetBackgroundSyncServicePtr();
|
| +
|
| + ServiceRegistry* service_registry_;
|
| + BackgroundSyncServicePtr background_sync_service_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(BackgroundSyncProvider);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_H_
|
|
|