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

Side by Side Diff: Source/core/fetch/ResourceLoader.cpp

Issue 138843009: Notify when resource with error code >= 400 is finished. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/devtools/front_end/NetworkPanel.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved.
3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com) 3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 { 79 {
80 } 80 }
81 81
82 ResourceLoader::~ResourceLoader() 82 ResourceLoader::~ResourceLoader()
83 { 83 {
84 ASSERT(m_state == Terminated); 84 ASSERT(m_state == Terminated);
85 } 85 }
86 86
87 void ResourceLoader::releaseResources() 87 void ResourceLoader::releaseResources()
88 { 88 {
89 ASSERT(m_notifiedLoadComplete);
89 ASSERT(m_state != Terminated); 90 ASSERT(m_state != Terminated);
90 m_requestCountTracker.clear(); 91 m_requestCountTracker.clear();
91 m_host->didLoadResource(m_resource); 92 m_host->didLoadResource(m_resource);
92 if (m_state == Terminated) 93 if (m_state == Terminated)
93 return; 94 return;
94 m_resource->clearLoader(); 95 m_resource->clearLoader();
95 m_host->willTerminateResourceLoader(this); 96 m_host->willTerminateResourceLoader(this);
96 97
97 ASSERT(m_state != Terminated); 98 ASSERT(m_state != Terminated);
98 99
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 if (m_state == Initialized) 241 if (m_state == Initialized)
241 m_state = Finishing; 242 m_state = Finishing;
242 m_resource->setResourceError(nonNullError); 243 m_resource->setResourceError(nonNullError);
243 244
244 if (m_loader) { 245 if (m_loader) {
245 m_connectionState = ConnectionStateCanceled; 246 m_connectionState = ConnectionStateCanceled;
246 m_loader->cancel(); 247 m_loader->cancel();
247 m_loader.clear(); 248 m_loader.clear();
248 } 249 }
249 250
250 m_host->didFailLoading(m_resource, nonNullError); 251 if (!m_notifiedLoadComplete) {
252 m_notifiedLoadComplete = true;
253 m_host->didFailLoading(m_resource, nonNullError);
254 }
251 255
252 if (m_state == Finishing) 256 if (m_state == Finishing)
253 m_resource->error(Resource::LoadError); 257 m_resource->error(Resource::LoadError);
254 if (m_state != Terminated) 258 if (m_state != Terminated)
255 releaseResources(); 259 releaseResources();
256 } 260 }
257 261
258 void ResourceLoader::willSendRequest(blink::WebURLLoader*, blink::WebURLRequest& passedRequest, const blink::WebURLResponse& passedRedirectResponse) 262 void ResourceLoader::willSendRequest(blink::WebURLLoader*, blink::WebURLRequest& passedRequest, const blink::WebURLResponse& passedRedirectResponse)
259 { 263 {
260 RefPtr<ResourceLoader> protect(this); 264 RefPtr<ResourceLoader> protect(this);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 } 349 }
346 } else if (isMultipartPayload) { 350 } else if (isMultipartPayload) {
347 // Since a subresource loader does not load multipart sections progressi vely, data was delivered to the loader all at once. 351 // Since a subresource loader does not load multipart sections progressi vely, data was delivered to the loader all at once.
348 // After the first multipart section is complete, signal to delegates th at this load is "finished" 352 // After the first multipart section is complete, signal to delegates th at this load is "finished"
349 m_host->subresourceLoaderFinishedLoadingOnePart(this); 353 m_host->subresourceLoaderFinishedLoadingOnePart(this);
350 didFinishLoadingOnePart(0); 354 didFinishLoadingOnePart(0);
351 } 355 }
352 356
353 if (m_resource->response().httpStatusCode() < 400 || m_resource->shouldIgnor eHTTPStatusCodeErrors()) 357 if (m_resource->response().httpStatusCode() < 400 || m_resource->shouldIgnor eHTTPStatusCodeErrors())
354 return; 358 return;
359
355 m_state = Finishing; 360 m_state = Finishing;
356 m_resource->error(Resource::LoadError); 361 m_resource->error(Resource::LoadError);
362 if (!m_notifiedLoadComplete) {
Nate Chapin 2014/01/31 17:25:52 I'm not sure this is safe. Specifically, if m_reso
eustas 2014/02/03 12:56:06 Done.
363 m_notifiedLoadComplete = true;
364 m_host->didFinishLoading(m_resource, monotonicallyIncreasingTime());
365 }
357 cancel(); 366 cancel();
358 } 367 }
359 368
360 void ResourceLoader::didReceiveData(blink::WebURLLoader*, const char* data, int length, int encodedDataLength) 369 void ResourceLoader::didReceiveData(blink::WebURLLoader*, const char* data, int length, int encodedDataLength)
361 { 370 {
362 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con nectionState == ConnectionStateReceivingData); 371 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con nectionState == ConnectionStateReceivingData);
363 m_connectionState = ConnectionStateReceivingData; 372 m_connectionState = ConnectionStateReceivingData;
364 373
365 // It is possible to receive data on uninitialized resources if it had an er ror status code, and we are running a nested message 374 // It is possible to receive data on uninitialized resources if it had an er ror status code, and we are running a nested message
366 // loop. When this occurs, ignoring the data is the correct action. 375 // loop. When this occurs, ignoring the data is the correct action.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 didReceiveResponse(0, responseOut); 465 didReceiveResponse(0, responseOut);
457 if (m_state == Terminated) 466 if (m_state == Terminated)
458 return; 467 return;
459 RefPtr<ResourceLoadInfo> resourceLoadInfo = responseOut.toResourceResponse() .resourceLoadInfo(); 468 RefPtr<ResourceLoadInfo> resourceLoadInfo = responseOut.toResourceResponse() .resourceLoadInfo();
460 m_host->didReceiveData(m_resource, dataOut.data(), dataOut.size(), resourceL oadInfo ? resourceLoadInfo->encodedDataLength : -1); 469 m_host->didReceiveData(m_resource, dataOut.data(), dataOut.size(), resourceL oadInfo ? resourceLoadInfo->encodedDataLength : -1);
461 m_resource->setResourceBuffer(dataOut); 470 m_resource->setResourceBuffer(dataOut);
462 didFinishLoading(0, monotonicallyIncreasingTime()); 471 didFinishLoading(0, monotonicallyIncreasingTime());
463 } 472 }
464 473
465 } 474 }
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/NetworkPanel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698