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 |
11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
12 #include "content/public/browser/service_worker_usage_info.h" | 12 #include "content/public/browser/service_worker_usage_info.h" |
13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
14 | 14 |
15 namespace blink { | |
16 enum class WebNavigationHintType; | |
17 } | |
18 | |
15 namespace content { | 19 namespace content { |
16 | 20 |
17 // Represents the per-StoragePartition ServiceWorker data. | 21 // Represents the per-StoragePartition ServiceWorker data. |
18 class ServiceWorkerContext { | 22 class ServiceWorkerContext { |
19 public: | 23 public: |
20 // https://rawgithub.com/slightlyoff/ServiceWorker/master/spec/service_worker/ index.html#url-scope: | 24 // https://rawgithub.com/slightlyoff/ServiceWorker/master/spec/service_worker/ index.html#url-scope: |
21 // roughly, must be of the form "<origin>/<path>/*". | 25 // roughly, must be of the form "<origin>/<path>/*". |
22 typedef GURL Scope; | 26 typedef GURL Scope; |
23 | 27 |
24 typedef base::Callback<void(bool success)> ResultCallback; | 28 typedef base::Callback<void(bool success)> ResultCallback; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 virtual void StopAllServiceWorkersForOrigin(const GURL& origin) = 0; | 102 virtual void StopAllServiceWorkersForOrigin(const GURL& origin) = 0; |
99 | 103 |
100 // Stops all running service workers and unregisters all service worker | 104 // Stops all running service workers and unregisters all service worker |
101 // registrations. This method is used in LayoutTests to make sure that the | 105 // registrations. This method is used in LayoutTests to make sure that the |
102 // existing service worker will not affect the succeeding tests. | 106 // existing service worker will not affect the succeeding tests. |
103 // | 107 // |
104 // This function can be called from any thread, but the callback will always | 108 // This function can be called from any thread, but the callback will always |
105 // be called on the UI thread. | 109 // be called on the UI thread. |
106 virtual void ClearAllServiceWorkersForTest(const base::Closure& callback) = 0; | 110 virtual void ClearAllServiceWorkersForTest(const base::Closure& callback) = 0; |
107 | 111 |
112 // Starts a Service Worker for |document_url| for a navigation hint in the | |
113 // specified render process |render_process_id|. Must be called from the UI | |
114 // thread. The |callback| will always be called on the UI thred. | |
nhiroki
2016/07/25 06:15:13
s/UI thred/UI thread/
horo
2016/07/25 08:24:27
Done.
| |
115 // This method can fail if: | |
116 // * No Service Worker was registered for |document_url|. | |
117 // * The specified render process is suitable for loading |document_url|. | |
nhiroki
2016/07/25 06:15:13
is suitable -> is not suitable ?
horo
2016/07/25 08:24:27
Done.
| |
118 // This check is done by RenderProcessHostImpl::IsSuitableHost(). | |
nhiroki
2016/07/25 06:15:13
RenderProcessHostImpl::IsSuitableHost() is an impl
horo
2016/07/25 08:24:27
Done.
| |
119 // * Something unexpected goes wrong, like a renderer crash. | |
nhiroki
2016/07/25 06:15:13
This would be obvious and not necessary.
horo
2016/07/25 08:24:27
Done.
| |
120 virtual void StartServiceWorkerForNavigationHint( | |
121 const GURL& document_url, | |
122 blink::WebNavigationHintType type, | |
123 int render_process_id, | |
124 const ResultCallback& callback) = 0; | |
125 | |
108 protected: | 126 protected: |
109 ServiceWorkerContext() {} | 127 ServiceWorkerContext() {} |
110 virtual ~ServiceWorkerContext() {} | 128 virtual ~ServiceWorkerContext() {} |
111 }; | 129 }; |
112 | 130 |
113 } // namespace content | 131 } // namespace content |
114 | 132 |
115 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ | 133 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ |
OLD | NEW |