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

Unified Diff: content/public/browser/service_worker_context.h

Issue 208843004: Add the beginning of a public Service Worker API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix #include guard name Created 6 years, 9 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/public/browser/service_worker_context.h
diff --git a/content/browser/service_worker/service_worker_context.h b/content/public/browser/service_worker_context.h
similarity index 25%
rename from content/browser/service_worker/service_worker_context.h
rename to content/public/browser/service_worker_context.h
index d9f51f3165c14c89f134d2d74807bceb7a8a2b69..36f4a25c5cc2bc01b2e32cb439dc8248f8c429ef 100644
--- a/content/browser/service_worker/service_worker_context.h
+++ b/content/public/browser/service_worker_context.h
@@ -2,18 +2,39 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_H_
-#define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_H_
+#ifndef CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_
+#define CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_
#include "base/basictypes.h"
+#include "base/callback_forward.h"
+#include "content/public/common/service_worker_status_code.h"
+#include "url/gurl.h"
namespace content {
-// Represents the per-BrowserContext ServiceWorker data.
+// Represents the per-StoragePartition ServiceWorker data. Must be used from
+// the UI thread.
class ServiceWorkerContext {
public:
- // TODO(michaeln): This class is a place holder for content/public api
- // which will come later. Promote this class when we get there.
+ // https://rawgithub.com/slightlyoff/ServiceWorker/master/spec/service_worker/index.html#url-scope:
+ // roughly, must be of the form "<origin>/<path>/*".
+ typedef GURL Scope;
+
+ typedef base::Callback<void(ServiceWorkerStatusCode status)>
+ RegistrationCallback;
+ virtual void RegisterServiceWorker(const Scope& pattern,
+ const GURL& script_url,
+ int source_process_id,
+ const RegistrationCallback& callback) = 0;
+
+ typedef base::Callback<void(ServiceWorkerStatusCode status)>
+ UnregistrationCallback;
kinuko 2014/03/26 05:01:34 nit: feels slightly verbose to typedef two callbac
Jeffrey Yasskin 2014/03/26 19:58:52 I'm suspicious that we'll want the RegistrationCal
+ virtual void UnregisterServiceWorker(
+ const GURL& pattern,
+ int source_process_id,
+ const UnregistrationCallback& callback) = 0;
+
+ // TODO(jyasskin): Provide a way to SendMessage to a Scope.
protected:
ServiceWorkerContext() {}
@@ -25,4 +46,4 @@ class ServiceWorkerContext {
} // namespace content
-#endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_H_
+#endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_

Powered by Google App Engine
This is Rietveld 408576698