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

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

Issue 1757023003: Document confusing threading requirements in ServiceWorkerContext(Wrapper). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « content/browser/service_worker/service_worker_context_wrapper.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // pattern}) from a renderer, except that |pattern| is an absolute URL instead 42 // pattern}) from a renderer, except that |pattern| is an absolute URL instead
43 // of relative to some current origin. |callback| is passed true when the JS 43 // of relative to some current origin. |callback| is passed true when the JS
44 // promise is fulfilled or false when the JS promise is rejected. 44 // promise is fulfilled or false when the JS promise is rejected.
45 // 45 //
46 // The registration can fail if: 46 // The registration can fail if:
47 // * |script_url| is on a different origin from |pattern| 47 // * |script_url| is on a different origin from |pattern|
48 // * Fetching |script_url| fails. 48 // * Fetching |script_url| fails.
49 // * |script_url| fails to parse or its top-level execution fails. 49 // * |script_url| fails to parse or its top-level execution fails.
50 // TODO: The error message for this needs to be available to developers. 50 // TODO: The error message for this needs to be available to developers.
51 // * Something unexpected goes wrong, like a renderer crash or a full disk. 51 // * Something unexpected goes wrong, like a renderer crash or a full disk.
52 //
53 // This function can be called from any thread, but the callback will always
54 // be called on the UI thread.
52 virtual void RegisterServiceWorker(const Scope& pattern, 55 virtual void RegisterServiceWorker(const Scope& pattern,
53 const GURL& script_url, 56 const GURL& script_url,
54 const ResultCallback& callback) = 0; 57 const ResultCallback& callback) = 0;
55 58
56 // Equivalent to calling navigator.serviceWorker.unregister(pattern) from a 59 // Equivalent to calling navigator.serviceWorker.unregister(pattern) from a
57 // renderer, except that |pattern| is an absolute URL instead of relative to 60 // renderer, except that |pattern| is an absolute URL instead of relative to
58 // some current origin. |callback| is passed true when the JS promise is 61 // some current origin. |callback| is passed true when the JS promise is
59 // fulfilled or false when the JS promise is rejected. 62 // fulfilled or false when the JS promise is rejected.
60 // 63 //
61 // Unregistration can fail if: 64 // Unregistration can fail if:
62 // * No Service Worker was registered for |pattern|. 65 // * No Service Worker was registered for |pattern|.
63 // * Something unexpected goes wrong, like a renderer crash. 66 // * Something unexpected goes wrong, like a renderer crash.
67 //
68 // This function can be called from any thread, but the callback will always
69 // be called on the UI thread.
64 virtual void UnregisterServiceWorker(const Scope& pattern, 70 virtual void UnregisterServiceWorker(const Scope& pattern,
65 const ResultCallback& callback) = 0; 71 const ResultCallback& callback) = 0;
66 72
67 // Methods used in response to browsing data and quota manager requests. 73 // Methods used in response to browsing data and quota manager requests.
74
75 // Must be called from the IO thread.
68 virtual void GetAllOriginsInfo(const GetUsageInfoCallback& callback) = 0; 76 virtual void GetAllOriginsInfo(const GetUsageInfoCallback& callback) = 0;
77
78 // This function can be called from any thread, but the callback will always
79 // be called on the IO thread.
69 virtual void DeleteForOrigin(const GURL& origin_url, 80 virtual void DeleteForOrigin(const GURL& origin_url,
70 const ResultCallback& callback) = 0; 81 const ResultCallback& callback) = 0;
71 82
72 // Returns true if a Service Worker registration exists that matches |url|, 83 // Returns true if a Service Worker registration exists that matches |url|,
73 // and if |other_url| falls inside the scope of the same registration. Note 84 // and if |other_url| falls inside the scope of the same registration. Note
74 // this still returns true even if there is a Service Worker registration 85 // this still returns true even if there is a Service Worker registration
75 // which has a longer match for |other_url|. 86 // which has a longer match for |other_url|.
87 //
76 // This function can be called from any thread, but the callback will always 88 // This function can be called from any thread, but the callback will always
77 // be called on the UI thread. 89 // be called on the UI thread.
78 virtual void CheckHasServiceWorker( 90 virtual void CheckHasServiceWorker(
79 const GURL& url, 91 const GURL& url,
80 const GURL& other_url, 92 const GURL& other_url,
81 const CheckHasServiceWorkerCallback& callback) = 0; 93 const CheckHasServiceWorkerCallback& callback) = 0;
82 94
83 // Stops all running workers on the given |origin|. 95 // Stops all running workers on the given |origin|.
96 //
97 // This function can be called from any thread.
84 virtual void StopAllServiceWorkersForOrigin(const GURL& origin) = 0; 98 virtual void StopAllServiceWorkersForOrigin(const GURL& origin) = 0;
85 99
86 // Stops all running service workers and unregisters all service worker 100 // Stops all running service workers and unregisters all service worker
87 // registrations. This method is used in LayoutTests to make sure that the 101 // registrations. This method is used in LayoutTests to make sure that the
88 // existing service worker will not affect the succeeding tests. 102 // existing service worker will not affect the succeeding tests.
103 //
104 // This function can be called from any thread, but the callback will always
105 // be called on the UI thread.
89 virtual void ClearAllServiceWorkersForTest(const base::Closure& callback) = 0; 106 virtual void ClearAllServiceWorkersForTest(const base::Closure& callback) = 0;
90 107
91 protected: 108 protected:
92 ServiceWorkerContext() {} 109 ServiceWorkerContext() {}
93 virtual ~ServiceWorkerContext() {} 110 virtual ~ServiceWorkerContext() {}
94 }; 111 };
95 112
96 } // namespace content 113 } // namespace content
97 114
98 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ 115 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_context_wrapper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698