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

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

Issue 1867293004: Set service worker response info data for foreign fetch intercepted fetches. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ff-check-origin
Patch Set: address comment Created 4 years, 8 months 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 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_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTROLLEE_REQUEST_HANDLER _H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTROLLEE_REQUEST_HANDLER _H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTROLLEE_REQUEST_HANDLER _H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTROLLEE_REQUEST_HANDLER _H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 RequestContextFrameType frame_type, 50 RequestContextFrameType frame_type,
51 scoped_refptr<ResourceRequestBody> body); 51 scoped_refptr<ResourceRequestBody> body);
52 ~ServiceWorkerControlleeRequestHandler() override; 52 ~ServiceWorkerControlleeRequestHandler() override;
53 53
54 // Called via custom URLRequestJobFactory. 54 // Called via custom URLRequestJobFactory.
55 net::URLRequestJob* MaybeCreateJob( 55 net::URLRequestJob* MaybeCreateJob(
56 net::URLRequest* request, 56 net::URLRequest* request,
57 net::NetworkDelegate* network_delegate, 57 net::NetworkDelegate* network_delegate,
58 ResourceContext* resource_context) override; 58 ResourceContext* resource_context) override;
59 59
60 void GetExtraResponseInfo(ResourceResponseInfo* response_info) const override;
61
62 private: 60 private:
63 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTest, 61 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTest,
64 ActivateWaitingVersion); 62 ActivateWaitingVersion);
65 typedef ServiceWorkerControlleeRequestHandler self; 63 typedef ServiceWorkerControlleeRequestHandler self;
66 64
67 // For main resource case. 65 // For main resource case.
68 void PrepareForMainResource(const net::URLRequest* request); 66 void PrepareForMainResource(const net::URLRequest* request);
69 void DidLookupRegistrationForMainResource( 67 void DidLookupRegistrationForMainResource(
70 ServiceWorkerStatusCode status, 68 ServiceWorkerStatusCode status,
71 const scoped_refptr<ServiceWorkerRegistration>& registration); 69 const scoped_refptr<ServiceWorkerRegistration>& registration);
(...skipping 10 matching lines...) Expand all
82 const scoped_refptr<ServiceWorkerRegistration>& registration, 80 const scoped_refptr<ServiceWorkerRegistration>& registration,
83 const scoped_refptr<ServiceWorkerVersion>& version); 81 const scoped_refptr<ServiceWorkerVersion>& version);
84 82
85 // For sub resource case. 83 // For sub resource case.
86 void PrepareForSubResource(); 84 void PrepareForSubResource();
87 85
88 // ServiceWorkerURLRequestJob::Delegate implementation: 86 // ServiceWorkerURLRequestJob::Delegate implementation:
89 87
90 // Called just before the request is restarted. Makes sure the next request 88 // Called just before the request is restarted. Makes sure the next request
91 // goes over the network. 89 // goes over the network.
92 void OnPrepareToRestart(base::TimeTicks service_worker_start_time, 90 void OnPrepareToRestart() override;
93 base::TimeTicks service_worker_ready_time) override;
94
95 // Called when the request's start phase completes. Caches response info for
96 // GetExtraResponseInfo.
97 void OnStartCompleted(
98 bool was_fetched_via_service_worker,
99 bool was_fallback_required,
100 const GURL& original_url_via_service_worker,
101 blink::WebServiceWorkerResponseType response_type_via_service_worker,
102 base::TimeTicks worker_start_time,
103 base::TimeTicks service_worker_ready_time,
104 bool response_is_in_cache_storage,
105 const std::string& response_cache_storage_cache_name) override;
106 91
107 ServiceWorkerVersion* GetServiceWorkerVersion( 92 ServiceWorkerVersion* GetServiceWorkerVersion(
108 ServiceWorkerMetrics::URLRequestJobResult* result) override; 93 ServiceWorkerMetrics::URLRequestJobResult* result) override;
109 bool RequestStillValid( 94 bool RequestStillValid(
110 ServiceWorkerMetrics::URLRequestJobResult* result) override; 95 ServiceWorkerMetrics::URLRequestJobResult* result) override;
111 void MainResourceLoadFailed() override; 96 void MainResourceLoadFailed() override;
112 97
113 // Sets |job_| to nullptr, and clears all extra response info associated with 98 // Sets |job_| to nullptr, and clears all extra response info associated with
114 // that job, except for timing information. 99 // that job, except for timing information.
115 void ClearJob(); 100 void ClearJob();
116 101
117 bool is_main_resource_load_; 102 bool is_main_resource_load_;
118 base::WeakPtr<ServiceWorkerURLRequestJob> job_; 103 base::WeakPtr<ServiceWorkerURLRequestJob> job_;
119 FetchRequestMode request_mode_; 104 FetchRequestMode request_mode_;
120 FetchCredentialsMode credentials_mode_; 105 FetchCredentialsMode credentials_mode_;
121 FetchRedirectMode redirect_mode_; 106 FetchRedirectMode redirect_mode_;
122 RequestContextType request_context_type_; 107 RequestContextType request_context_type_;
123 RequestContextFrameType frame_type_; 108 RequestContextFrameType frame_type_;
124 scoped_refptr<ResourceRequestBody> body_; 109 scoped_refptr<ResourceRequestBody> body_;
125 ResourceContext* resource_context_; 110 ResourceContext* resource_context_;
126 GURL stripped_url_; 111 GURL stripped_url_;
127 bool force_update_started_; 112 bool force_update_started_;
128 113
129 // True if the next time this request is started, the response should be 114 // True if the next time this request is started, the response should be
130 // delivered from the network, bypassing the ServiceWorker. Cleared after the 115 // delivered from the network, bypassing the ServiceWorker. Cleared after the
131 // next intercept opportunity, for main frame requests. 116 // next intercept opportunity, for main frame requests.
132 bool use_network_; 117 bool use_network_;
133 118
134 // Cached metadata for GetExtraResponseInfo.
135 bool was_fetched_via_service_worker_;
136 bool was_fallback_required_;
137 GURL original_url_via_service_worker_;
138 blink::WebServiceWorkerResponseType response_type_via_service_worker_;
139 base::TimeTicks service_worker_start_time_;
140 base::TimeTicks service_worker_ready_time_;
141 bool response_is_in_cache_storage_ = false;
142 std::string response_cache_storage_cache_name_;
143
144 base::WeakPtrFactory<ServiceWorkerControlleeRequestHandler> weak_factory_; 119 base::WeakPtrFactory<ServiceWorkerControlleeRequestHandler> weak_factory_;
145 120
146 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerControlleeRequestHandler); 121 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerControlleeRequestHandler);
147 }; 122 };
148 123
149 } // namespace content 124 } // namespace content
150 125
151 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTROLLEE_REQUEST_HAND LER_H_ 126 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTROLLEE_REQUEST_HAND LER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698