OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_BROWSER_SERVICE_WORKER_SERVICE_WORKER_RESPONSE_INFO_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_RESPONSE_INFO_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_RESPONSE_INFO_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_RESPONSE_INFO_H_ |
7 | 7 |
| 8 #include <vector> |
| 9 |
8 #include "base/supports_user_data.h" | 10 #include "base/supports_user_data.h" |
9 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
10 #include "content/common/service_worker/service_worker_types.h" | 12 #include "content/common/service_worker/service_worker_types.h" |
11 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerResponseType.h" | 13 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerResponseType.h" |
12 #include "url/gurl.h" | 14 #include "url/gurl.h" |
13 | 15 |
14 namespace net { | 16 namespace net { |
15 class URLRequest; | 17 class URLRequest; |
16 } | 18 } |
17 | 19 |
(...skipping 10 matching lines...) Expand all Loading... |
28 | 30 |
29 ~ServiceWorkerResponseInfo() override; | 31 ~ServiceWorkerResponseInfo() override; |
30 | 32 |
31 void GetExtraResponseInfo(ResourceResponseInfo* response_info) const; | 33 void GetExtraResponseInfo(ResourceResponseInfo* response_info) const; |
32 void OnPrepareToRestart(base::TimeTicks service_worker_start_time, | 34 void OnPrepareToRestart(base::TimeTicks service_worker_start_time, |
33 base::TimeTicks service_worker_ready_time); | 35 base::TimeTicks service_worker_ready_time); |
34 void OnStartCompleted( | 36 void OnStartCompleted( |
35 bool was_fetched_via_service_worker, | 37 bool was_fetched_via_service_worker, |
36 bool was_fetched_via_foreign_fetch, | 38 bool was_fetched_via_foreign_fetch, |
37 bool was_fallback_required, | 39 bool was_fallback_required, |
38 const GURL& original_url_via_service_worker, | 40 const std::vector<GURL>& url_list_via_service_worker, |
39 blink::WebServiceWorkerResponseType response_type_via_service_worker, | 41 blink::WebServiceWorkerResponseType response_type_via_service_worker, |
40 base::TimeTicks service_worker_start_time, | 42 base::TimeTicks service_worker_start_time, |
41 base::TimeTicks service_worker_ready_time, | 43 base::TimeTicks service_worker_ready_time, |
42 bool response_is_in_cache_storage, | 44 bool response_is_in_cache_storage, |
43 const std::string& response_cache_storage_cache_name, | 45 const std::string& response_cache_storage_cache_name, |
44 const ServiceWorkerHeaderList& cors_exposed_header_names); | 46 const ServiceWorkerHeaderList& cors_exposed_header_names); |
45 void ResetData(); | 47 void ResetData(); |
46 | 48 |
47 // Returns true if a service worker responded to the request. If the service | 49 // Returns true if a service worker responded to the request. If the service |
48 // worker received a fetch event and did not call respondWith(), or was | 50 // worker received a fetch event and did not call respondWith(), or was |
49 // bypassed due to absence of a fetch event handler, this function | 51 // bypassed due to absence of a fetch event handler, this function |
50 // typically returns false but returns true if "fallback to renderer" was | 52 // typically returns false but returns true if "fallback to renderer" was |
51 // required (however in this case the response is not an actual resource and | 53 // required (however in this case the response is not an actual resource and |
52 // the request will be reissued by the renderer). | 54 // the request will be reissued by the renderer). |
53 bool was_fetched_via_service_worker() const { | 55 bool was_fetched_via_service_worker() const { |
54 return was_fetched_via_service_worker_; | 56 return was_fetched_via_service_worker_; |
55 } | 57 } |
56 | 58 |
57 // Returns true if "fallback to renderer" was required. This happens when a | 59 // Returns true if "fallback to renderer" was required. This happens when a |
58 // request was directed to a service worker but it did not call respondWith() | 60 // request was directed to a service worker but it did not call respondWith() |
59 // or was bypassed due to absense of a fetch event handler, and the browser | 61 // or was bypassed due to absense of a fetch event handler, and the browser |
60 // could not directly fall back to network because the CORS algorithm must be | 62 // could not directly fall back to network because the CORS algorithm must be |
61 // run, which is implemented in the renderer. | 63 // run, which is implemented in the renderer. |
62 bool was_fallback_required() const { return was_fallback_required_; } | 64 bool was_fallback_required() const { return was_fallback_required_; } |
63 | 65 |
64 // Returns the URL of the Response object the service worker passed to | 66 // Returns the URL list of the Response object the service worker passed to |
65 // respondWith() to create this response. This URL is null if the response was | 67 // respondWith() to create this response. This is empty if the response was |
66 // programatically generated as in respondWith(new Response()). It is also | 68 // programatically generated as in respondWith(new Response()). It is also |
67 // null if a service worker did not respond to the request or did not call | 69 // empty if a service worker did not respond to the request or did not call |
68 // respondWith(). | 70 // respondWith(). |
69 const GURL& original_url_via_service_worker() const { | 71 const std::vector<GURL>& url_list_via_service_worker() const { |
70 return original_url_via_service_worker_; | 72 return url_list_via_service_worker_; |
71 } | 73 } |
72 blink::WebServiceWorkerResponseType response_type_via_service_worker() const { | 74 blink::WebServiceWorkerResponseType response_type_via_service_worker() const { |
73 return response_type_via_service_worker_; | 75 return response_type_via_service_worker_; |
74 } | 76 } |
75 base::TimeTicks service_worker_start_time() const { | 77 base::TimeTicks service_worker_start_time() const { |
76 return service_worker_start_time_; | 78 return service_worker_start_time_; |
77 } | 79 } |
78 base::TimeTicks service_worker_ready_time() const { | 80 base::TimeTicks service_worker_ready_time() const { |
79 return service_worker_ready_time_; | 81 return service_worker_ready_time_; |
80 } | 82 } |
81 bool response_is_in_cache_storage() const { | 83 bool response_is_in_cache_storage() const { |
82 return response_is_in_cache_storage_; | 84 return response_is_in_cache_storage_; |
83 } | 85 } |
84 const std::string& response_cache_storage_cache_name() const { | 86 const std::string& response_cache_storage_cache_name() const { |
85 return response_cache_storage_cache_name_; | 87 return response_cache_storage_cache_name_; |
86 } | 88 } |
87 | 89 |
88 private: | 90 private: |
89 ServiceWorkerResponseInfo(); | 91 ServiceWorkerResponseInfo(); |
90 | 92 |
91 bool was_fetched_via_service_worker_ = false; | 93 bool was_fetched_via_service_worker_ = false; |
92 bool was_fetched_via_foreign_fetch_ = false; | 94 bool was_fetched_via_foreign_fetch_ = false; |
93 bool was_fallback_required_ = false; | 95 bool was_fallback_required_ = false; |
94 GURL original_url_via_service_worker_; | 96 std::vector<GURL> url_list_via_service_worker_; |
95 blink::WebServiceWorkerResponseType response_type_via_service_worker_ = | 97 blink::WebServiceWorkerResponseType response_type_via_service_worker_ = |
96 blink::WebServiceWorkerResponseTypeDefault; | 98 blink::WebServiceWorkerResponseTypeDefault; |
97 base::TimeTicks service_worker_start_time_; | 99 base::TimeTicks service_worker_start_time_; |
98 base::TimeTicks service_worker_ready_time_; | 100 base::TimeTicks service_worker_ready_time_; |
99 bool response_is_in_cache_storage_ = false; | 101 bool response_is_in_cache_storage_ = false; |
100 std::string response_cache_storage_cache_name_; | 102 std::string response_cache_storage_cache_name_; |
101 ServiceWorkerHeaderList cors_exposed_header_names_; | 103 ServiceWorkerHeaderList cors_exposed_header_names_; |
102 }; | 104 }; |
103 | 105 |
104 } // namespace content | 106 } // namespace content |
105 | 107 |
106 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_RESPONSE_INFO_H_ | 108 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_RESPONSE_INFO_H_ |
OLD | NEW |