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

Side by Side Diff: content/browser/service_worker/service_worker_fetch_dispatcher.cc

Issue 2580793004: service worker: Add CHECKs for investigating null http info bug. (Closed)
Patch Set: Fix foreign fetch 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 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 #include "content/browser/service_worker/service_worker_fetch_dispatcher.h" 5 #include "content/browser/service_worker/service_worker_fetch_dispatcher.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 void Run(int request_id, 187 void Run(int request_id,
188 ServiceWorkerFetchEventResult fetch_result, 188 ServiceWorkerFetchEventResult fetch_result,
189 const ServiceWorkerResponse& response, 189 const ServiceWorkerResponse& response,
190 base::Time dispatch_event_time) { 190 base::Time dispatch_event_time) {
191 const bool handled = 191 const bool handled =
192 (fetch_result == SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE); 192 (fetch_result == SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE);
193 if (!version_->FinishRequest(request_id, handled, dispatch_event_time)) 193 if (!version_->FinishRequest(request_id, handled, dispatch_event_time))
194 NOTREACHED() << "Should only receive one reply per event"; 194 NOTREACHED() << "Should only receive one reply per event";
195 195
196 // |fetch_dispatcher| is null if the URLRequest was killed. 196 // |fetch_dispatcher| is null if the URLRequest was killed.
197 if (fetch_dispatcher_) 197 if (fetch_dispatcher_) {
198 // TODO(falken): Remove this CHECK once https://crbug.com/485900 is
199 // resolved.
200 CHECK(version_->GetMainScriptHttpResponseInfo());
198 fetch_dispatcher_->DidFinish(request_id, fetch_result, response); 201 fetch_dispatcher_->DidFinish(request_id, fetch_result, response);
202 }
199 } 203 }
200 204
201 private: 205 private:
202 base::WeakPtr<ServiceWorkerFetchDispatcher> fetch_dispatcher_; 206 base::WeakPtr<ServiceWorkerFetchDispatcher> fetch_dispatcher_;
203 // Owns |this|. 207 // Owns |this|.
204 ServiceWorkerVersion* version_; 208 ServiceWorkerVersion* version_;
205 209
206 DISALLOW_COPY_AND_ASSIGN(ResponseCallback); 210 DISALLOW_COPY_AND_ASSIGN(ResponseCallback);
207 }; 211 };
208 212
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 ServiceWorkerStatusCode status) { 291 ServiceWorkerStatusCode status) {
288 EndNetLogEventWithServiceWorkerStatus( 292 EndNetLogEventWithServiceWorkerStatus(
289 net_log_, net::NetLogEventType::SERVICE_WORKER_START_WORKER, status); 293 net_log_, net::NetLogEventType::SERVICE_WORKER_START_WORKER, status);
290 DidFail(status); 294 DidFail(status);
291 } 295 }
292 296
293 void ServiceWorkerFetchDispatcher::DispatchFetchEvent() { 297 void ServiceWorkerFetchDispatcher::DispatchFetchEvent() {
294 DCHECK_EQ(EmbeddedWorkerStatus::RUNNING, version_->running_status()) 298 DCHECK_EQ(EmbeddedWorkerStatus::RUNNING, version_->running_status())
295 << "Worker stopped too soon after it was started."; 299 << "Worker stopped too soon after it was started.";
296 300
301 // TODO(falken): Remove this CHECK once https://crbug.com/485900 is resolved.
302 CHECK(version_->GetMainScriptHttpResponseInfo());
303
297 DCHECK(!prepare_callback_.is_null()); 304 DCHECK(!prepare_callback_.is_null());
298 base::Closure prepare_callback = prepare_callback_; 305 base::Closure prepare_callback = prepare_callback_;
299 prepare_callback.Run(); 306 prepare_callback.Run();
300 307
301 net_log_.BeginEvent(net::NetLogEventType::SERVICE_WORKER_FETCH_EVENT); 308 net_log_.BeginEvent(net::NetLogEventType::SERVICE_WORKER_FETCH_EVENT);
302 int fetch_event_id; 309 int fetch_event_id;
303 int event_finish_id; 310 int event_finish_id;
304 if (timeout_) { 311 if (timeout_) {
305 fetch_event_id = version_->StartRequestWithCustomTimeout( 312 fetch_event_id = version_->StartRequestWithCustomTimeout(
306 GetEventType(), 313 GetEventType(),
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 } 473 }
467 474
468 ServiceWorkerMetrics::EventType ServiceWorkerFetchDispatcher::GetEventType() 475 ServiceWorkerMetrics::EventType ServiceWorkerFetchDispatcher::GetEventType()
469 const { 476 const {
470 if (request_->fetch_type == ServiceWorkerFetchType::FOREIGN_FETCH) 477 if (request_->fetch_type == ServiceWorkerFetchType::FOREIGN_FETCH)
471 return ServiceWorkerMetrics::EventType::FOREIGN_FETCH; 478 return ServiceWorkerMetrics::EventType::FOREIGN_FETCH;
472 return ResourceTypeToEventType(resource_type_); 479 return ResourceTypeToEventType(resource_type_);
473 } 480 }
474 481
475 } // namespace content 482 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698