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

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: Updates based on recent changes to mojo definitions. Created 5 years, 8 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..6d7f91660a21a72f3e38d088457cee6eb8c63ac4
--- /dev/null
+++ b/content/child/background_sync/background_sync_provider.h
@@ -0,0 +1,91 @@
+// 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;
+
jkarlin 2015/05/01 16:13:51 Add a class comment here.
iclelland 2015/05/05 14:52:02 Done.
+class BackgroundSyncProvider : public blink::WebSyncProvider,
+ public WorkerTaskRunner::Observer {
jkarlin 2015/05/01 16:13:51 Why is this a WorkerTaskRunner observer? I don't s
iclelland 2015/05/05 14:52:02 This was a holdover from the template I used; Shou
+ 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);
+
+ // WorkerTaskRunner::Observer implementation.
+ void OnWorkerRunLoopStopped() override;
+
+ // Entry points for Background Sync API calls from worker threads
+ void RegisterBackgroundSyncForWorker(
+ const blink::WebSyncRegistration* options,
jkarlin 2015/05/01 16:13:51 This should be a scoped_ptr.
iclelland 2015/05/07 06:03:50 Done.
+ 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,
jkarlin 2015/05/01 16:13:51 Caps: RegisterCallback
iclelland 2015/05/05 14:52:02 Done.
+ int worker_thread_id,
+ const SyncRegistrationPtr &options);
+ void unregisterCallback(blink::WebSyncUnregistrationCallbacks* callbacks,
jkarlin 2015/05/01 16:13:51 ditto
iclelland 2015/05/05 14:52:02 Done.
+ int worker_thread_id, bool success);
+ void getRegistrationsCallback(
jkarlin 2015/05/01 16:13:51 ditto
iclelland 2015/05/05 14:52:02 Done.
+ blink::WebSyncGetRegistrationsCallbacks* callbacks, int worker_thread_id,
+ 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