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 14 matching lines...) Expand all Loading... | |
25 public: | 25 public: |
26 // 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: |
27 // roughly, must be of the form "<origin>/<path>/*". | 27 // roughly, must be of the form "<origin>/<path>/*". |
28 typedef GURL Scope; | 28 typedef GURL Scope; |
29 | 29 |
30 typedef base::Callback<void(bool success)> ResultCallback; | 30 typedef base::Callback<void(bool success)> ResultCallback; |
31 | 31 |
32 typedef base::Callback<void(const std::vector<ServiceWorkerUsageInfo>& | 32 typedef base::Callback<void(const std::vector<ServiceWorkerUsageInfo>& |
33 usage_info)> GetUsageInfoCallback; | 33 usage_info)> GetUsageInfoCallback; |
34 | 34 |
35 typedef base::Callback<void(bool has_same_service_worker)> | |
36 CheckHasSameServiceWorkerCallback; | |
37 | |
35 // Registers the header name which should not be passed to the ServiceWorker. | 38 // Registers the header name which should not be passed to the ServiceWorker. |
36 // Must be called from the IO thread. | 39 // Must be called from the IO thread. |
37 CONTENT_EXPORT static void AddExcludedHeadersForFetchEvent( | 40 CONTENT_EXPORT static void AddExcludedHeadersForFetchEvent( |
38 const std::set<std::string>& header_names); | 41 const std::set<std::string>& header_names); |
39 | 42 |
40 // Returns true if the header name should not be passed to the ServiceWorker. | 43 // Returns true if the header name should not be passed to the ServiceWorker. |
41 // Must be called from the IO thread. | 44 // Must be called from the IO thread. |
42 static bool IsExcludedHeaderNameForFetchEvent(const std::string& header_name); | 45 static bool IsExcludedHeaderNameForFetchEvent(const std::string& header_name); |
43 | 46 |
44 // Retrieves the ServiceWorkerContext, if any, associated with |request|. | 47 // Retrieves the ServiceWorkerContext, if any, associated with |request|. |
(...skipping 21 matching lines...) Expand all Loading... | |
66 // fulfilled or false when the JS promise is rejected. | 69 // fulfilled or false when the JS promise is rejected. |
67 // | 70 // |
68 // Unregistration can fail if: | 71 // Unregistration can fail if: |
69 // * No Service Worker was registered for |pattern|. | 72 // * No Service Worker was registered for |pattern|. |
70 // * Something unexpected goes wrong, like a renderer crash. | 73 // * Something unexpected goes wrong, like a renderer crash. |
71 virtual void UnregisterServiceWorker(const Scope& pattern, | 74 virtual void UnregisterServiceWorker(const Scope& pattern, |
72 const ResultCallback& callback) = 0; | 75 const ResultCallback& callback) = 0; |
73 | 76 |
74 // TODO(jyasskin): Provide a way to SendMessage to a Scope. | 77 // TODO(jyasskin): Provide a way to SendMessage to a Scope. |
75 | 78 |
76 // Determines if a request for 'url' can be satisfied while offline. | 79 // Determines if a request for |url| can be satisfied while offline. |
77 // This method always completes asynchronously. | 80 // This method always completes asynchronously. |
78 virtual void CanHandleMainResourceOffline(const GURL& url, | 81 virtual void CanHandleMainResourceOffline(const GURL& url, |
79 const GURL& first_party, | 82 const GURL& first_party, |
80 const net::CompletionCallback& | 83 const net::CompletionCallback& |
81 callback) = 0; | 84 callback) = 0; |
82 | 85 |
83 // Methods used in response to browsing data and quota manager requests. | 86 // Methods used in response to browsing data and quota manager requests. |
84 virtual void GetAllOriginsInfo(const GetUsageInfoCallback& callback) = 0; | 87 virtual void GetAllOriginsInfo(const GetUsageInfoCallback& callback) = 0; |
85 virtual void DeleteForOrigin(const GURL& origin_url) = 0; | 88 virtual void DeleteForOrigin(const GURL& origin_url) = 0; |
86 | 89 |
90 // Determines if |url| has a controlling Service Worker, and if that Service | |
91 // Worker also controls |other_url|. | |
falken
2015/02/05 10:26:11
The language in the comment is a bit wrong, right
benwells
2015/02/05 12:38:29
Done.
| |
92 virtual void CheckHasSameServiceWorker( | |
93 const GURL& url, | |
94 const GURL& other_url, | |
95 const CheckHasSameServiceWorkerCallback& callback) = 0; | |
96 | |
87 protected: | 97 protected: |
88 ServiceWorkerContext() {} | 98 ServiceWorkerContext() {} |
89 virtual ~ServiceWorkerContext() {} | 99 virtual ~ServiceWorkerContext() {} |
90 }; | 100 }; |
91 | 101 |
92 } // namespace content | 102 } // namespace content |
93 | 103 |
94 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ | 104 #endif // CONTENT_PUBLIC_BROWSER_SERVICE_WORKER_CONTEXT_H_ |
OLD | NEW |