Chromium Code Reviews| 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 { | 15 namespace blink { |
| 16 enum class WebNavigationHintType; | 16 enum class WebNavigationHintType; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 | 20 |
| 21 class StoragePartition; | |
|
michaeln
2016/09/24 01:46:51
no longer needed?
lazyboy
2016/09/27 21:26:45
Done.
| |
| 22 | |
| 21 // Represents the per-StoragePartition ServiceWorker data. | 23 // Represents the per-StoragePartition ServiceWorker data. |
| 22 class ServiceWorkerContext { | 24 class ServiceWorkerContext { |
| 23 public: | 25 public: |
| 24 // https://rawgithub.com/slightlyoff/ServiceWorker/master/spec/service_worker/ index.html#url-scope: | 26 // https://rawgithub.com/slightlyoff/ServiceWorker/master/spec/service_worker/ index.html#url-scope: |
| 25 // roughly, must be of the form "<origin>/<path>/*". | 27 // roughly, must be of the form "<origin>/<path>/*". |
| 26 typedef GURL Scope; | 28 typedef GURL Scope; |
| 27 | 29 |
| 28 typedef base::Callback<void(bool success)> ResultCallback; | 30 typedef base::Callback<void(bool success)> ResultCallback; |
| 29 | 31 |
| 30 typedef base::Callback<void(const std::vector<ServiceWorkerUsageInfo>& | 32 typedef base::Callback<void(const std::vector<ServiceWorkerUsageInfo>& |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 53 // * |script_url| fails to parse or its top-level execution fails. | 55 // * |script_url| fails to parse or its top-level execution fails. |
| 54 // TODO: The error message for this needs to be available to developers. | 56 // TODO: The error message for this needs to be available to developers. |
| 55 // * Something unexpected goes wrong, like a renderer crash or a full disk. | 57 // * Something unexpected goes wrong, like a renderer crash or a full disk. |
| 56 // | 58 // |
| 57 // This function can be called from any thread, but the callback will always | 59 // This function can be called from any thread, but the callback will always |
| 58 // be called on the UI thread. | 60 // be called on the UI thread. |
| 59 virtual void RegisterServiceWorker(const Scope& pattern, | 61 virtual void RegisterServiceWorker(const Scope& pattern, |
| 60 const GURL& script_url, | 62 const GURL& script_url, |
| 61 const ResultCallback& callback) = 0; | 63 const ResultCallback& callback) = 0; |
| 62 | 64 |
| 65 virtual bool IncrementPendingActivity(int64_t service_worker_version_id) = 0; | |
| 66 virtual bool DecrementPendingActivity(int64_t service_worker_version_id) = 0; | |
| 67 | |
| 63 // Equivalent to calling navigator.serviceWorker.unregister(pattern) from a | 68 // Equivalent to calling navigator.serviceWorker.unregister(pattern) from a |
| 64 // renderer, except that |pattern| is an absolute URL instead of relative to | 69 // renderer, except that |pattern| is an absolute URL instead of relative to |
| 65 // some current origin. |callback| is passed true when the JS promise is | 70 // some current origin. |callback| is passed true when the JS promise is |
| 66 // fulfilled or false when the JS promise is rejected. | 71 // fulfilled or false when the JS promise is rejected. |
| 67 // | 72 // |
| 68 // Unregistration can fail if: | 73 // Unregistration can fail if: |
| 69 // * No Service Worker was registered for |pattern|. | 74 // * No Service Worker was registered for |pattern|. |
| 70 // * Something unexpected goes wrong, like a renderer crash. | 75 // * Something unexpected goes wrong, like a renderer crash. |
| 71 // | 76 // |
| 72 // This function can be called from any thread, but the callback will always | 77 // This function can be called from any thread, but the callback will always |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 const ResultCallback& callback) = 0; | 127 const ResultCallback& callback) = 0; |
| 123 | 128 |
| 124 protected: | 129 protected: |
| 125 ServiceWorkerContext() {} | 130 ServiceWorkerContext() {} |
| 126 virtual ~ServiceWorkerContext() {} | 131 virtual ~ServiceWorkerContext() {} |
| 127 }; | 132 }; |
| 128 | 133 |
| 129 } // namespace content | 134 } // namespace content |
| 130 | 135 |
| 131 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ | 136 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ |
| OLD | NEW |