Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: content/browser/service_worker/service_worker_response_info.h

Issue 2516353002: Introduce url_list to the Response scheme of CacheStorage. (Closed)
Patch Set: implicit conversion WebURL <-> GURL and WebVector <- vector Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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. For example, if the service worker
66 // programatically generated as in respondWith(new Response()). It is also 68 // calls respondWith(fetch('http://example.com/a')) and http://example.com/a
67 // null if a service worker did not respond to the request or did not call 69 // redirects to http://example.net/b which redirects to http://example.org/c,
68 // respondWith(). 70 // the URL list is the vector <"http://example.com/a", "http://example.net/b",
69 const GURL& original_url_via_service_worker() const { 71 // "http://example.org/c">. This is empty if the response was programatically
70 return original_url_via_service_worker_; 72 // generated as in respondWith(new Response()). It is also empty if a service
73 // worker did not respond to the request or did not call respondWith().
74 const std::vector<GURL>& url_list_via_service_worker() const {
75 return url_list_via_service_worker_;
71 } 76 }
72 blink::WebServiceWorkerResponseType response_type_via_service_worker() const { 77 blink::WebServiceWorkerResponseType response_type_via_service_worker() const {
73 return response_type_via_service_worker_; 78 return response_type_via_service_worker_;
74 } 79 }
75 base::TimeTicks service_worker_start_time() const { 80 base::TimeTicks service_worker_start_time() const {
76 return service_worker_start_time_; 81 return service_worker_start_time_;
77 } 82 }
78 base::TimeTicks service_worker_ready_time() const { 83 base::TimeTicks service_worker_ready_time() const {
79 return service_worker_ready_time_; 84 return service_worker_ready_time_;
80 } 85 }
81 bool response_is_in_cache_storage() const { 86 bool response_is_in_cache_storage() const {
82 return response_is_in_cache_storage_; 87 return response_is_in_cache_storage_;
83 } 88 }
84 const std::string& response_cache_storage_cache_name() const { 89 const std::string& response_cache_storage_cache_name() const {
85 return response_cache_storage_cache_name_; 90 return response_cache_storage_cache_name_;
86 } 91 }
87 92
88 private: 93 private:
89 ServiceWorkerResponseInfo(); 94 ServiceWorkerResponseInfo();
90 95
91 bool was_fetched_via_service_worker_ = false; 96 bool was_fetched_via_service_worker_ = false;
92 bool was_fetched_via_foreign_fetch_ = false; 97 bool was_fetched_via_foreign_fetch_ = false;
93 bool was_fallback_required_ = false; 98 bool was_fallback_required_ = false;
94 GURL original_url_via_service_worker_; 99 std::vector<GURL> url_list_via_service_worker_;
95 blink::WebServiceWorkerResponseType response_type_via_service_worker_ = 100 blink::WebServiceWorkerResponseType response_type_via_service_worker_ =
96 blink::WebServiceWorkerResponseTypeDefault; 101 blink::WebServiceWorkerResponseTypeDefault;
97 base::TimeTicks service_worker_start_time_; 102 base::TimeTicks service_worker_start_time_;
98 base::TimeTicks service_worker_ready_time_; 103 base::TimeTicks service_worker_ready_time_;
99 bool response_is_in_cache_storage_ = false; 104 bool response_is_in_cache_storage_ = false;
100 std::string response_cache_storage_cache_name_; 105 std::string response_cache_storage_cache_name_;
101 ServiceWorkerHeaderList cors_exposed_header_names_; 106 ServiceWorkerHeaderList cors_exposed_header_names_;
102 }; 107 };
103 108
104 } // namespace content 109 } // namespace content
105 110
106 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_RESPONSE_INFO_H_ 111 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_RESPONSE_INFO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698