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

Side by Side Diff: Source/core/inspector/InspectorResourceAgent.cpp

Issue 209343005: Move 'response' check in responseReceived() to the backend. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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
« no previous file with comments | « no previous file | Source/devtools/front_end/NetworkManager.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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 } 329 }
330 330
331 m_frontend->requestWillBeSent(requestId, frameId, m_pageAgent->loaderId(load er), urlWithoutFragment(loader->url()).string(), buildObjectForResourceRequest(r equest), currentTime(), initiatorObject, buildObjectForResourceResponse(redirect Response, loader)); 331 m_frontend->requestWillBeSent(requestId, frameId, m_pageAgent->loaderId(load er), urlWithoutFragment(loader->url()).string(), buildObjectForResourceRequest(r equest), currentTime(), initiatorObject, buildObjectForResourceResponse(redirect Response, loader));
332 } 332 }
333 333
334 void InspectorResourceAgent::markResourceAsCached(unsigned long identifier) 334 void InspectorResourceAgent::markResourceAsCached(unsigned long identifier)
335 { 335 {
336 m_frontend->requestServedFromCache(IdentifiersFactory::requestId(identifier) ); 336 m_frontend->requestServedFromCache(IdentifiersFactory::requestId(identifier) );
337 } 337 }
338 338
339 bool isResponseEmpty(PassRefPtr<TypeBuilder::Network::Response> response)
340 {
341 if (!response)
342 return true;
343
344 RefPtr<JSONValue> status = response->get("status");
345 RefPtr<JSONValue> mimeType = response->get("mimeType");
346 RefPtr<JSONObject> headers = response->getObject("headers");
347
348 return !status && !mimeType && (!headers || !headers->size());
349 }
350
339 void InspectorResourceAgent::didReceiveResourceResponse(LocalFrame* frame, unsig ned long identifier, DocumentLoader* loader, const ResourceResponse& response, R esourceLoader* resourceLoader) 351 void InspectorResourceAgent::didReceiveResourceResponse(LocalFrame* frame, unsig ned long identifier, DocumentLoader* loader, const ResourceResponse& response, R esourceLoader* resourceLoader)
340 { 352 {
341 if (!loader) 353 if (!loader)
342 return; 354 return;
343 355
344 String requestId = IdentifiersFactory::requestId(identifier); 356 String requestId = IdentifiersFactory::requestId(identifier);
345 RefPtr<TypeBuilder::Network::Response> resourceResponse = buildObjectForReso urceResponse(response, loader); 357 RefPtr<TypeBuilder::Network::Response> resourceResponse = buildObjectForReso urceResponse(response, loader);
346 358
347 bool isNotModified = response.httpStatusCode() == 304; 359 bool isNotModified = response.httpStatusCode() == 304;
348 360
(...skipping 13 matching lines...) Expand all
362 InspectorPageAgent::ResourceType type = cachedResource ? InspectorPageAgent: :cachedResourceType(*cachedResource) : InspectorPageAgent::OtherResource; 374 InspectorPageAgent::ResourceType type = cachedResource ? InspectorPageAgent: :cachedResourceType(*cachedResource) : InspectorPageAgent::OtherResource;
363 // Workaround for worker scripts that use RawResources for loading. 375 // Workaround for worker scripts that use RawResources for loading.
364 if (m_resourcesData->resourceType(requestId) == InspectorPageAgent::ScriptRe source) 376 if (m_resourcesData->resourceType(requestId) == InspectorPageAgent::ScriptRe source)
365 type = InspectorPageAgent::ScriptResource; 377 type = InspectorPageAgent::ScriptResource;
366 // Workaround for background: url() in inline style. 378 // Workaround for background: url() in inline style.
367 if (equalIgnoringFragmentIdentifier(response.url(), loader->url()) && !loade r->isCommitted()) 379 if (equalIgnoringFragmentIdentifier(response.url(), loader->url()) && !loade r->isCommitted())
368 type = InspectorPageAgent::DocumentResource; 380 type = InspectorPageAgent::DocumentResource;
369 381
370 m_resourcesData->responseReceived(requestId, m_pageAgent->frameId(loader->fr ame()), response); 382 m_resourcesData->responseReceived(requestId, m_pageAgent->frameId(loader->fr ame()), response);
371 m_resourcesData->setResourceType(requestId, type); 383 m_resourcesData->setResourceType(requestId, type);
372 m_frontend->responseReceived(requestId, m_pageAgent->frameId(loader->frame() ), m_pageAgent->loaderId(loader), currentTime(), InspectorPageAgent::resourceTyp eJson(type), resourceResponse); 384
385 if (!isResponseEmpty(resourceResponse))
386 m_frontend->responseReceived(requestId, m_pageAgent->frameId(loader->fra me()), m_pageAgent->loaderId(loader), currentTime(), InspectorPageAgent::resourc eTypeJson(type), resourceResponse);
373 // If we revalidated the resource and got Not modified, send content length following didReceiveResponse 387 // If we revalidated the resource and got Not modified, send content length following didReceiveResponse
374 // as there will be no calls to didReceiveData from the network stack. 388 // as there will be no calls to didReceiveData from the network stack.
375 if (isNotModified && cachedResource && cachedResource->encodedSize()) 389 if (isNotModified && cachedResource && cachedResource->encodedSize())
376 didReceiveData(frame, identifier, 0, cachedResource->encodedSize(), 0); 390 didReceiveData(frame, identifier, 0, cachedResource->encodedSize(), 0);
377 } 391 }
378 392
379 static bool isErrorStatusCode(int statusCode) 393 static bool isErrorStatusCode(int statusCode)
380 { 394 {
381 return statusCode >= 400; 395 return statusCode >= 400;
382 } 396 }
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 : InspectorBaseAgent<InspectorResourceAgent>("Network") 824 : InspectorBaseAgent<InspectorResourceAgent>("Network")
811 , m_pageAgent(pageAgent) 825 , m_pageAgent(pageAgent)
812 , m_client(client) 826 , m_client(client)
813 , m_frontend(0) 827 , m_frontend(0)
814 , m_resourcesData(adoptPtr(new NetworkResourcesData())) 828 , m_resourcesData(adoptPtr(new NetworkResourcesData()))
815 , m_isRecalculatingStyle(false) 829 , m_isRecalculatingStyle(false)
816 { 830 {
817 } 831 }
818 832
819 } // namespace WebCore 833 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/NetworkManager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698