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

Unified Diff: content/child/background_sync/background_sync_provider.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: Style / Formatting fixes 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 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
new file mode 100644
index 0000000000000000000000000000000000000000..93d4fefbd732db5e6b161b7ded6305d2d9665859
--- /dev/null
+++ b/content/child/background_sync/background_sync_provider.h
@@ -0,0 +1,74 @@
+// 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.
+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);
+
+ private:
+ // Callback handlers
+ void RegisterCallback(
+ scoped_ptr<blink::WebSyncRegistrationCallbacks> callbacks,
+ const SyncRegistrationPtr& options);
+ void UnregisterCallback(
+ scoped_ptr<blink::WebSyncUnregistrationCallbacks> callbacks,
+ bool success);
+ void GetRegistrationsCallback(
+ scoped_ptr<blink::WebSyncGetRegistrationsCallbacks> callbacks,
+ const mojo::Array<SyncRegistrationPtr>& registrations);
+
+ // 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_

Powered by Google App Engine
This is Rietveld 408576698