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

Side by Side Diff: content/public/browser/service_worker_context.h

Issue 238043002: Teach EmbeddedWorkerInstance to create a process when it needs one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Null out browser_context_ in Shutdown Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_
6 #define CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ 6 #define CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/callback_forward.h" 9 #include "base/callback_forward.h"
10 #include "url/gurl.h" 10 #include "url/gurl.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 class BrowserContext;
15
14 // Represents the per-StoragePartition ServiceWorker data. Must be used from 16 // Represents the per-StoragePartition ServiceWorker data. Must be used from
15 // the UI thread. 17 // the UI thread.
16 class ServiceWorkerContext { 18 class ServiceWorkerContext {
17 public: 19 public:
18 // https://rawgithub.com/slightlyoff/ServiceWorker/master/spec/service_worker/ index.html#url-scope: 20 // https://rawgithub.com/slightlyoff/ServiceWorker/master/spec/service_worker/ index.html#url-scope:
19 // roughly, must be of the form "<origin>/<path>/*". 21 // roughly, must be of the form "<origin>/<path>/*".
20 typedef GURL Scope; 22 typedef GURL Scope;
21 23
22 typedef base::Callback<void(bool success)> ResultCallback; 24 typedef base::Callback<void(bool success)> ResultCallback;
23 25
24 // Equivalent to calling navigator.serviceWorker.register(script_url, {scope: 26 // Equivalent to calling navigator.serviceWorker.register(script_url, {scope:
25 // pattern}) from a renderer in |source_process_id|, except that |pattern| is 27 // pattern}) from a renderer running in |site_instance|, except that |pattern|
26 // an absolute URL instead of relative to some current origin. |callback| is 28 // is an absolute URL instead of relative to some current origin. |callback|
27 // passed true when the JS promise is fulfilled or false when the JS 29 // is passed true when the JS promise is fulfilled or false when the JS
28 // promise is rejected. 30 // promise is rejected.
29 // 31 //
30 // The registration can fail if: 32 // The registration can fail if:
31 // * |script_url| is on a different origin from |pattern| 33 // * |script_url| is on a different origin from |pattern|
32 // * Fetching |script_url| fails. 34 // * Fetching |script_url| fails.
33 // * |script_url| fails to parse or its top-level execution fails. 35 // * |script_url| fails to parse or its top-level execution fails.
34 // TODO: The error message for this needs to be available to developers. 36 // TODO: The error message for this needs to be available to developers.
35 // * Something unexpected goes wrong, like a renderer crash or a full disk. 37 // * Something unexpected goes wrong, like a renderer crash or a full disk.
36 virtual void RegisterServiceWorker(const Scope& pattern, 38 virtual void RegisterServiceWorker(const Scope& pattern,
37 const GURL& script_url, 39 const GURL& script_url,
38 int source_process_id, 40 BrowserContext* context,
jam 2014/04/25 04:59:30 this seems redundant since ServiceWorkerContext sh
Jeffrey Yasskin 2014/04/26 03:52:19 At the moment, ServiceWorkerContext doesn't know i
39 const ResultCallback& callback) = 0; 41 const ResultCallback& callback) = 0;
40 42
41 // Equivalent to calling navigator.serviceWorker.unregister(pattern) from a 43 // Equivalent to calling navigator.serviceWorker.unregister(pattern) from a
42 // renderer in |source_process_id|, except that |pattern| is an absolute URL 44 // renderer in |source_process_id|, except that |pattern| is an absolute URL
43 // instead of relative to some current origin. |callback| is passed true 45 // instead of relative to some current origin. |callback| is passed true
44 // when the JS promise is fulfilled or false when the JS promise is rejected. 46 // when the JS promise is fulfilled or false when the JS promise is rejected.
45 // 47 //
46 // Unregistration can fail if: 48 // Unregistration can fail if:
47 // * No Service Worker was registered for |pattern|. 49 // * No Service Worker was registered for |pattern|.
48 // * Something unexpected goes wrong, like a renderer crash. 50 // * Something unexpected goes wrong, like a renderer crash.
49 virtual void UnregisterServiceWorker(const Scope& pattern, 51 virtual void UnregisterServiceWorker(const Scope& pattern,
50 int source_process_id, 52 int source_process_id,
51 const ResultCallback& callback) = 0; 53 const ResultCallback& callback) = 0;
52 54
53 // TODO(jyasskin): Provide a way to SendMessage to a Scope. 55 // TODO(jyasskin): Provide a way to SendMessage to a Scope.
54 56
55 protected: 57 protected:
56 ServiceWorkerContext() {} 58 ServiceWorkerContext() {}
57 virtual ~ServiceWorkerContext() {} 59 virtual ~ServiceWorkerContext() {}
58 }; 60 };
59 61
60 } // namespace content 62 } // namespace content
61 63
62 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ 64 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698