OLD | NEW |
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 using CheckHasServiceWorkerCallback = | 52 using CheckHasServiceWorkerCallback = |
53 base::Callback<void(ServiceWorkerCapability capability)>; | 53 base::Callback<void(ServiceWorkerCapability capability)>; |
54 | 54 |
55 using CountExternalRequestsCallback = | 55 using CountExternalRequestsCallback = |
56 base::Callback<void(size_t external_request_count)>; | 56 base::Callback<void(size_t external_request_count)>; |
57 | 57 |
58 using StartServiceWorkerForNavigationHintCallback = | 58 using StartServiceWorkerForNavigationHintCallback = |
59 base::Callback<void(StartServiceWorkerForNavigationHintResult result)>; | 59 base::Callback<void(StartServiceWorkerForNavigationHintResult result)>; |
60 | 60 |
| 61 using StartActiveWorkerCallback = |
| 62 base::OnceCallback<void(int process_id, int thread_id)>; |
| 63 |
61 // Registers the header name which should not be passed to the ServiceWorker. | 64 // Registers the header name which should not be passed to the ServiceWorker. |
62 // Must be called from the IO thread. | 65 // Must be called from the IO thread. |
63 CONTENT_EXPORT static void AddExcludedHeadersForFetchEvent( | 66 CONTENT_EXPORT static void AddExcludedHeadersForFetchEvent( |
64 const std::set<std::string>& header_names); | 67 const std::set<std::string>& header_names); |
65 | 68 |
66 // Returns true if the header name should not be passed to the ServiceWorker. | 69 // Returns true if the header name should not be passed to the ServiceWorker. |
67 // Must be called from the IO thread. | 70 // Must be called from the IO thread. |
68 static bool IsExcludedHeaderNameForFetchEvent(const std::string& header_name); | 71 static bool IsExcludedHeaderNameForFetchEvent(const std::string& header_name); |
69 | 72 |
70 // Returns true if |url| is within the service worker |scope|. | 73 // Returns true if |url| is within the service worker |scope|. |
(...skipping 29 matching lines...) Expand all Loading... |
100 // shut the worker down while embedder is expecting the worker to be kept | 103 // shut the worker down while embedder is expecting the worker to be kept |
101 // alive. | 104 // alive. |
102 // | 105 // |
103 // Must be called from the IO thread. Returns whether or not changing the ref | 106 // Must be called from the IO thread. Returns whether or not changing the ref |
104 // count succeeded. | 107 // count succeeded. |
105 virtual bool StartingExternalRequest(int64_t service_worker_version_id, | 108 virtual bool StartingExternalRequest(int64_t service_worker_version_id, |
106 const std::string& request_uuid) = 0; | 109 const std::string& request_uuid) = 0; |
107 virtual bool FinishedExternalRequest(int64_t service_worker_version_id, | 110 virtual bool FinishedExternalRequest(int64_t service_worker_version_id, |
108 const std::string& request_uuid) = 0; | 111 const std::string& request_uuid) = 0; |
109 | 112 |
| 113 // Starts the active worker of the registration whose scope is |pattern|. |
| 114 // |info_callback| is passed the worker's render process id and thread id. |
| 115 // |
| 116 // Must be called on IO thread. |
| 117 virtual void StartActiveWorkerForPattern( |
| 118 const GURL& pattern, |
| 119 StartActiveWorkerCallback info_callback, |
| 120 base::OnceClosure failure_callback) = 0; |
| 121 |
110 // Equivalent to calling navigator.serviceWorker.unregister(pattern) from a | 122 // Equivalent to calling navigator.serviceWorker.unregister(pattern) from a |
111 // renderer, except that |pattern| is an absolute URL instead of relative to | 123 // renderer, except that |pattern| is an absolute URL instead of relative to |
112 // some current origin. |callback| is passed true when the JS promise is | 124 // some current origin. |callback| is passed true when the JS promise is |
113 // fulfilled or false when the JS promise is rejected. | 125 // fulfilled or false when the JS promise is rejected. |
114 // | 126 // |
115 // Unregistration can fail if: | 127 // Unregistration can fail if: |
116 // * No Service Worker was registered for |pattern|. | 128 // * No Service Worker was registered for |pattern|. |
117 // * Something unexpected goes wrong, like a renderer crash. | 129 // * Something unexpected goes wrong, like a renderer crash. |
118 // | 130 // |
119 // This function can be called from any thread, but the callback will always | 131 // This function can be called from any thread, but the callback will always |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 const StartServiceWorkerForNavigationHintCallback& callback) = 0; | 186 const StartServiceWorkerForNavigationHintCallback& callback) = 0; |
175 | 187 |
176 protected: | 188 protected: |
177 ServiceWorkerContext() {} | 189 ServiceWorkerContext() {} |
178 virtual ~ServiceWorkerContext() {} | 190 virtual ~ServiceWorkerContext() {} |
179 }; | 191 }; |
180 | 192 |
181 } // namespace content | 193 } // namespace content |
182 | 194 |
183 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ | 195 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ |
OLD | NEW |