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

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

Issue 1410153009: DevTools: Make network events continuous on Timeline (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move events to a separate file Created 5 years, 1 month 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 /* 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 16 matching lines...) Expand all
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30 #include "config.h" 30 #include "config.h"
31 #include "core/fetch/ResourceLoader.h" 31 #include "core/fetch/ResourceLoader.h"
32 32
33 #include "core/fetch/CSSStyleSheetResource.h" 33 #include "core/fetch/CSSStyleSheetResource.h"
34 #include "core/fetch/Resource.h" 34 #include "core/fetch/Resource.h"
35 #include "core/fetch/ResourceFetcher.h" 35 #include "core/fetch/ResourceFetcher.h"
36 #include "core/fetch/ResourcePtr.h" 36 #include "core/fetch/ResourcePtr.h"
37 #include "core/fetch/TraceEventArguments.h"
37 #include "platform/Logging.h" 38 #include "platform/Logging.h"
38 #include "platform/SharedBuffer.h" 39 #include "platform/SharedBuffer.h"
39 #include "platform/ThreadedDataReceiver.h" 40 #include "platform/ThreadedDataReceiver.h"
41 #include "platform/TraceEvent.h"
40 #include "platform/exported/WrappedResourceRequest.h" 42 #include "platform/exported/WrappedResourceRequest.h"
41 #include "platform/exported/WrappedResourceResponse.h" 43 #include "platform/exported/WrappedResourceResponse.h"
42 #include "platform/network/ResourceError.h" 44 #include "platform/network/ResourceError.h"
43 #include "public/platform/Platform.h" 45 #include "public/platform/Platform.h"
44 #include "public/platform/WebData.h" 46 #include "public/platform/WebData.h"
45 #include "public/platform/WebThreadedDataReceiver.h" 47 #include "public/platform/WebThreadedDataReceiver.h"
46 #include "public/platform/WebURLError.h" 48 #include "public/platform/WebURLError.h"
47 #include "public/platform/WebURLRequest.h" 49 #include "public/platform/WebURLRequest.h"
48 #include "public/platform/WebURLResponse.h" 50 #include "public/platform/WebURLResponse.h"
49 #include "wtf/Assertions.h" 51 #include "wtf/Assertions.h"
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 // |rawHandle|'s ownership is transferred to the callee. 309 // |rawHandle|'s ownership is transferred to the callee.
308 OwnPtr<WebDataConsumerHandle> handle = adoptPtr(rawHandle); 310 OwnPtr<WebDataConsumerHandle> handle = adoptPtr(rawHandle);
309 311
310 bool isMultipartPayload = response.isMultipartPayload(); 312 bool isMultipartPayload = response.isMultipartPayload();
311 bool isValidStateTransition = (m_connectionState == ConnectionStateStarted | | m_connectionState == ConnectionStateReceivedResponse); 313 bool isValidStateTransition = (m_connectionState == ConnectionStateStarted | | m_connectionState == ConnectionStateReceivedResponse);
312 // In the case of multipart loads, calls to didReceiveData & didReceiveRespo nse can be interleaved. 314 // In the case of multipart loads, calls to didReceiveData & didReceiveRespo nse can be interleaved.
313 RELEASE_ASSERT(isMultipartPayload || isValidStateTransition); 315 RELEASE_ASSERT(isMultipartPayload || isValidStateTransition);
314 m_connectionState = ConnectionStateReceivedResponse; 316 m_connectionState = ConnectionStateReceivedResponse;
315 317
316 const ResourceResponse& resourceResponse = response.toResourceResponse(); 318 const ResourceResponse& resourceResponse = response.toResourceResponse();
319 TRACE_EVENT1("devtools.timeline", "ResourceReceiveResponse", "data", Inspect orReceiveResponseEvent::data(m_resource->identifier(), resourceResponse));
317 320
318 if (responseNeedsAccessControlCheck()) { 321 if (responseNeedsAccessControlCheck()) {
319 if (response.wasFetchedViaServiceWorker()) { 322 if (response.wasFetchedViaServiceWorker()) {
320 if (response.wasFallbackRequiredByServiceWorker()) { 323 if (response.wasFallbackRequiredByServiceWorker()) {
321 m_loader->cancel(); 324 m_loader->cancel();
322 m_loader.clear(); 325 m_loader.clear();
323 m_connectionState = ConnectionStateStarted; 326 m_connectionState = ConnectionStateStarted;
324 m_loader = adoptPtr(Platform::current()->createURLLoader()); 327 m_loader = adoptPtr(Platform::current()->createURLLoader());
325 ASSERT(m_loader); 328 ASSERT(m_loader);
326 ASSERT(!m_request.skipServiceWorker()); 329 ASSERT(!m_request.skipServiceWorker());
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 388
386 void ResourceLoader::didReceiveResponse(WebURLLoader* loader, const WebURLRespon se& response) 389 void ResourceLoader::didReceiveResponse(WebURLLoader* loader, const WebURLRespon se& response)
387 { 390 {
388 didReceiveResponse(loader, response, nullptr); 391 didReceiveResponse(loader, response, nullptr);
389 } 392 }
390 393
391 void ResourceLoader::didReceiveData(WebURLLoader*, const char* data, int length, int encodedDataLength) 394 void ResourceLoader::didReceiveData(WebURLLoader*, const char* data, int length, int encodedDataLength)
392 { 395 {
393 ASSERT(m_state != Terminated); 396 ASSERT(m_state != Terminated);
394 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con nectionState == ConnectionStateReceivingData); 397 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con nectionState == ConnectionStateReceivingData);
398 TRACE_EVENT1("devtools.timeline", "ResourceReceivedData", "data", InspectorR eceiveDataEvent::data(m_resource->identifier(), encodedDataLength));
395 m_connectionState = ConnectionStateReceivingData; 399 m_connectionState = ConnectionStateReceivingData;
396 400
397 // It is possible to receive data on uninitialized resources if it had an er ror status code, and we are running a nested message 401 // It is possible to receive data on uninitialized resources if it had an er ror status code, and we are running a nested message
398 // loop. When this occurs, ignoring the data is the correct action. 402 // loop. When this occurs, ignoring the data is the correct action.
399 if (m_resource->response().httpStatusCode() >= 400 && !m_resource->shouldIgn oreHTTPStatusCodeErrors()) 403 if (m_resource->response().httpStatusCode() >= 400 && !m_resource->shouldIgn oreHTTPStatusCodeErrors())
400 return; 404 return;
401 ASSERT(m_state == Initialized); 405 ASSERT(m_state == Initialized);
402 406
403 // FIXME: If we get a resource with more than 2B bytes, this code won't do t he right thing. 407 // FIXME: If we get a resource with more than 2B bytes, this code won't do t he right thing.
404 // However, with today's computers and networking speeds, this won't happen in practice. 408 // However, with today's computers and networking speeds, this won't happen in practice.
405 // Could be an issue with a giant local file. 409 // Could be an issue with a giant local file.
406 m_fetcher->didReceiveData(m_resource, data, length, encodedDataLength); 410 m_fetcher->didReceiveData(m_resource, data, length, encodedDataLength);
407 if (m_state == Terminated) 411 if (m_state == Terminated)
408 return; 412 return;
409 RELEASE_ASSERT(length >= 0); 413 RELEASE_ASSERT(length >= 0);
410 m_resource->appendData(data, length); 414 m_resource->appendData(data, length);
411 } 415 }
412 416
413 void ResourceLoader::didFinishLoading(WebURLLoader*, double finishTime, int64_t encodedDataLength) 417 void ResourceLoader::didFinishLoading(WebURLLoader*, double finishTime, int64_t encodedDataLength)
414 { 418 {
415 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con nectionState == ConnectionStateReceivingData); 419 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con nectionState == ConnectionStateReceivingData);
420 TRACE_EVENT1("devtools.timeline", "ResourceFinish", "data", InspectorResourc eFinishEvent::data(m_resource->identifier(), finishTime, false));
416 m_connectionState = ConnectionStateFinishedLoading; 421 m_connectionState = ConnectionStateFinishedLoading;
417 if (m_state != Initialized) 422 if (m_state != Initialized)
418 return; 423 return;
419 ASSERT(m_state != Terminated); 424 ASSERT(m_state != Terminated);
420 WTF_LOG(ResourceLoading, "Received '%s'.", m_resource->url().string().latin1 ().data()); 425 WTF_LOG(ResourceLoading, "Received '%s'.", m_resource->url().string().latin1 ().data());
421 426
422 ResourcePtr<Resource> protectResource(m_resource); 427 ResourcePtr<Resource> protectResource(m_resource);
423 m_state = Finishing; 428 m_state = Finishing;
424 m_resource->setLoadFinishTime(finishTime); 429 m_resource->setLoadFinishTime(finishTime);
425 didFinishLoadingOnePart(finishTime, encodedDataLength); 430 didFinishLoadingOnePart(finishTime, encodedDataLength);
426 if (m_state == Terminated) 431 if (m_state == Terminated)
427 return; 432 return;
428 m_resource->finish(); 433 m_resource->finish();
429 434
430 // If the load has been cancelled by a delegate in response to didFinishLoad (), do not release 435 // If the load has been cancelled by a delegate in response to didFinishLoad (), do not release
431 // the resources a second time, they have been released by cancel. 436 // the resources a second time, they have been released by cancel.
432 if (m_state == Terminated) 437 if (m_state == Terminated)
433 return; 438 return;
434 releaseResources(); 439 releaseResources();
435 } 440 }
436 441
437 void ResourceLoader::didFail(WebURLLoader*, const WebURLError& error) 442 void ResourceLoader::didFail(WebURLLoader*, const WebURLError& error)
438 { 443 {
444 TRACE_EVENT1("devtools.timeline", "ResourceFinish", "data", InspectorResourc eFinishEvent::data(m_resource->identifier(), 0, true));
439 m_connectionState = ConnectionStateFailed; 445 m_connectionState = ConnectionStateFailed;
440 ASSERT(m_state != Terminated); 446 ASSERT(m_state != Terminated);
441 WTF_LOG(ResourceLoading, "Failed to load '%s'.\n", m_resource->url().string( ).latin1().data()); 447 WTF_LOG(ResourceLoading, "Failed to load '%s'.\n", m_resource->url().string( ).latin1().data());
442 448
443 ResourcePtr<Resource> protectResource(m_resource); 449 ResourcePtr<Resource> protectResource(m_resource);
444 m_state = Finishing; 450 m_state = Finishing;
445 m_resource->setResourceError(error); 451 m_resource->setResourceError(error);
446 452
447 if (!m_notifiedLoadComplete) { 453 if (!m_notifiedLoadComplete) {
448 m_notifiedLoadComplete = true; 454 m_notifiedLoadComplete = true;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); 509 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength);
504 } 510 }
505 511
506 ResourceRequest& ResourceLoader::applyOptions(ResourceRequest& request) const 512 ResourceRequest& ResourceLoader::applyOptions(ResourceRequest& request) const
507 { 513 {
508 request.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredC redentials); 514 request.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredC redentials);
509 return request; 515 return request;
510 } 516 }
511 517
512 } 518 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698