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> | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 8 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 9 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
| 10 #include "content/public/browser/service_worker_usage_info.h" | 14 #include "content/public/browser/service_worker_usage_info.h" |
| 11 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 12 | 16 |
| 13 namespace content { | 17 namespace content { |
| 14 | 18 |
| 15 // Represents the per-StoragePartition ServiceWorker data. Must be used from | 19 // Represents the per-StoragePartition ServiceWorker data. Must be used from |
| 16 // the IO thread. | 20 // the IO thread except for AddExcludedHeadersForFetchEvent. |
| 17 class ServiceWorkerContext { | 21 class ServiceWorkerContext { |
| 18 public: | 22 public: |
| 19 // https://rawgithub.com/slightlyoff/ServiceWorker/master/spec/service_worker/ index.html#url-scope: | 23 // https://rawgithub.com/slightlyoff/ServiceWorker/master/spec/service_worker/ index.html#url-scope: |
| 20 // roughly, must be of the form "<origin>/<path>/*". | 24 // roughly, must be of the form "<origin>/<path>/*". |
| 21 typedef GURL Scope; | 25 typedef GURL Scope; |
| 22 | 26 |
| 23 typedef base::Callback<void(bool success)> ResultCallback; | 27 typedef base::Callback<void(bool success)> ResultCallback; |
| 24 | 28 |
| 25 typedef base::Callback<void(const std::vector<ServiceWorkerUsageInfo>& | 29 typedef base::Callback<void(const std::vector<ServiceWorkerUsageInfo>& |
| 26 usage_info)> GetUsageInfoCallback; | 30 usage_info)> GetUsageInfoCallback; |
| 27 | 31 |
| 32 // Registers the header name which should not be passed to the ServiceWorker. | |
| 33 CONTENT_EXPORT static void AddExcludedHeadersForFetchEvent( | |
| 34 const std::vector<std::string> header_names); | |
|
michaeln
2014/10/28 20:57:22
can this be a const ref?
horo
2014/10/29 01:56:25
Done.
| |
| 35 | |
| 36 // Returns true if the header name should not be passed to the ServiceWorker. | |
| 37 static bool IsExcludedHeaderNameForFetchEvent(const std::string& header_name); | |
| 38 | |
| 28 // Equivalent to calling navigator.serviceWorker.register(script_url, {scope: | 39 // Equivalent to calling navigator.serviceWorker.register(script_url, {scope: |
| 29 // pattern}) from a renderer, except that |pattern| is an absolute URL instead | 40 // pattern}) from a renderer, except that |pattern| is an absolute URL instead |
| 30 // of relative to some current origin. |callback| is passed true when the JS | 41 // of relative to some current origin. |callback| is passed true when the JS |
| 31 // promise is fulfilled or false when the JS promise is rejected. | 42 // promise is fulfilled or false when the JS promise is rejected. |
| 32 // | 43 // |
| 33 // The registration can fail if: | 44 // The registration can fail if: |
| 34 // * |script_url| is on a different origin from |pattern| | 45 // * |script_url| is on a different origin from |pattern| |
| 35 // * Fetching |script_url| fails. | 46 // * Fetching |script_url| fails. |
| 36 // * |script_url| fails to parse or its top-level execution fails. | 47 // * |script_url| fails to parse or its top-level execution fails. |
| 37 // TODO: The error message for this needs to be available to developers. | 48 // TODO: The error message for this needs to be available to developers. |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 63 virtual void DeleteForOrigin(const GURL& origin_url) = 0; | 74 virtual void DeleteForOrigin(const GURL& origin_url) = 0; |
| 64 | 75 |
| 65 protected: | 76 protected: |
| 66 ServiceWorkerContext() {} | 77 ServiceWorkerContext() {} |
| 67 virtual ~ServiceWorkerContext() {} | 78 virtual ~ServiceWorkerContext() {} |
| 68 }; | 79 }; |
| 69 | 80 |
| 70 } // namespace content | 81 } // namespace content |
| 71 | 82 |
| 72 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ | 83 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ |
| OLD | NEW |