| 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 | |
| 19 namespace content { | 15 namespace content { |
| 20 | 16 |
| 21 // Represents the per-StoragePartition ServiceWorker data. | 17 // Represents the per-StoragePartition ServiceWorker data. |
| 22 class ServiceWorkerContext { | 18 class ServiceWorkerContext { |
| 23 public: | 19 public: |
| 24 // 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: |
| 25 // roughly, must be of the form "<origin>/<path>/*". | 21 // roughly, must be of the form "<origin>/<path>/*". |
| 26 typedef GURL Scope; | 22 typedef GURL Scope; |
| 27 | 23 |
| 28 typedef base::Callback<void(bool success)> ResultCallback; | 24 typedef base::Callback<void(bool success)> ResultCallback; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 virtual void StopAllServiceWorkersForOrigin(const GURL& origin) = 0; | 98 virtual void StopAllServiceWorkersForOrigin(const GURL& origin) = 0; |
| 103 | 99 |
| 104 // Stops all running service workers and unregisters all service worker | 100 // Stops all running service workers and unregisters all service worker |
| 105 // 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 |
| 106 // existing service worker will not affect the succeeding tests. | 102 // existing service worker will not affect the succeeding tests. |
| 107 // | 103 // |
| 108 // This function can be called from any thread, but the callback will always | 104 // This function can be called from any thread, but the callback will always |
| 109 // be called on the UI thread. | 105 // be called on the UI thread. |
| 110 virtual void ClearAllServiceWorkersForTest(const base::Closure& callback) = 0; | 106 virtual void ClearAllServiceWorkersForTest(const base::Closure& callback) = 0; |
| 111 | 107 |
| 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 thread. | |
| 115 // This method can fail if: | |
| 116 // * No Service Worker was registered for |document_url|. | |
| 117 // * The specified render process is not suitable for loading |document_url|. | |
| 118 virtual void StartServiceWorkerForNavigationHint( | |
| 119 const GURL& document_url, | |
| 120 blink::WebNavigationHintType type, | |
| 121 int render_process_id, | |
| 122 const ResultCallback& callback) = 0; | |
| 123 | |
| 124 protected: | 108 protected: |
| 125 ServiceWorkerContext() {} | 109 ServiceWorkerContext() {} |
| 126 virtual ~ServiceWorkerContext() {} | 110 virtual ~ServiceWorkerContext() {} |
| 127 }; | 111 }; |
| 128 | 112 |
| 129 } // namespace content | 113 } // namespace content |
| 130 | 114 |
| 131 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ | 115 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ |
| OLD | NEW |