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

Side by Side Diff: Source/modules/fetch/FetchManager.cpp

Issue 1259393002: DevTools: add support for logging fetch requests when XHR logging is enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: review comments addressed Created 5 years, 4 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 #include "config.h" 5 #include "config.h"
6 #include "modules/fetch/FetchManager.h" 6 #include "modules/fetch/FetchManager.h"
7 7
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "bindings/core/v8/ScriptState.h" 10 #include "bindings/core/v8/ScriptState.h"
11 #include "bindings/core/v8/V8ThrowException.h" 11 #include "bindings/core/v8/V8ThrowException.h"
12 #include "core/dom/DOMArrayBuffer.h" 12 #include "core/dom/DOMArrayBuffer.h"
13 #include "core/dom/Document.h" 13 #include "core/dom/Document.h"
14 #include "core/dom/ExceptionCode.h" 14 #include "core/dom/ExceptionCode.h"
15 #include "core/fetch/FetchUtils.h" 15 #include "core/fetch/FetchUtils.h"
16 #include "core/fileapi/Blob.h" 16 #include "core/fileapi/Blob.h"
17 #include "core/frame/Frame.h" 17 #include "core/frame/Frame.h"
18 #include "core/frame/csp/ContentSecurityPolicy.h" 18 #include "core/frame/csp/ContentSecurityPolicy.h"
19 #include "core/inspector/ConsoleMessage.h" 19 #include "core/inspector/ConsoleMessage.h"
20 #include "core/inspector/InspectorInstrumentation.h"
20 #include "core/loader/ThreadableLoader.h" 21 #include "core/loader/ThreadableLoader.h"
21 #include "core/loader/ThreadableLoaderClient.h" 22 #include "core/loader/ThreadableLoaderClient.h"
22 #include "core/page/ChromeClient.h" 23 #include "core/page/ChromeClient.h"
23 #include "core/page/Page.h" 24 #include "core/page/Page.h"
24 #include "modules/fetch/Body.h" 25 #include "modules/fetch/Body.h"
25 #include "modules/fetch/BodyStreamBuffer.h" 26 #include "modules/fetch/BodyStreamBuffer.h"
26 #include "modules/fetch/DataConsumerHandleUtil.h" 27 #include "modules/fetch/DataConsumerHandleUtil.h"
27 #include "modules/fetch/FetchRequestData.h" 28 #include "modules/fetch/FetchRequestData.h"
28 #include "modules/fetch/Response.h" 29 #include "modules/fetch/Response.h"
29 #include "modules/fetch/ResponseInit.h" 30 #include "modules/fetch/ResponseInit.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 150
150 void FetchManager::Loader::didFinishLoading(unsigned long, double) 151 void FetchManager::Loader::didFinishLoading(unsigned long, double)
151 { 152 {
152 ASSERT(!m_failed); 153 ASSERT(!m_failed);
153 m_finished = true; 154 m_finished = true;
154 155
155 if (document() && document()->frame() && document()->frame()->page() 156 if (document() && document()->frame() && document()->frame()->page()
156 && m_responseHttpStatusCode >= 200 && m_responseHttpStatusCode < 300) { 157 && m_responseHttpStatusCode >= 200 && m_responseHttpStatusCode < 300) {
157 document()->frame()->page()->chromeClient().ajaxSucceeded(document()->fr ame()); 158 document()->frame()->page()->chromeClient().ajaxSucceeded(document()->fr ame());
158 } 159 }
159 160 InspectorInstrumentation::didFinishFetch(executionContext(), this, m_request ->method(), m_request->url().string());
160 notifyFinished(); 161 notifyFinished();
161 } 162 }
162 163
163 void FetchManager::Loader::didFail(const ResourceError& error) 164 void FetchManager::Loader::didFail(const ResourceError& error)
164 { 165 {
165 if (error.isCancellation() || error.isTimeout() || error.domain() != errorDo mainBlinkInternal) 166 if (error.isCancellation() || error.isTimeout() || error.domain() != errorDo mainBlinkInternal)
166 failed(String()); 167 failed(String());
167 else 168 else
168 failed("Fetch API cannot load " + error.failingURL() + ". " + error.loca lizedDescription()); 169 failed("Fetch API cannot load " + error.failingURL() + ". " + error.loca lizedDescription());
169 } 170 }
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 threadableLoaderOptions.crossOriginRequestPolicy = DenyCrossOriginReques ts; 375 threadableLoaderOptions.crossOriginRequestPolicy = DenyCrossOriginReques ts;
375 break; 376 break;
376 case WebURLRequest::FetchRequestModeNoCORS: 377 case WebURLRequest::FetchRequestModeNoCORS:
377 threadableLoaderOptions.crossOriginRequestPolicy = AllowCrossOriginReque sts; 378 threadableLoaderOptions.crossOriginRequestPolicy = AllowCrossOriginReque sts;
378 break; 379 break;
379 case WebURLRequest::FetchRequestModeCORS: 380 case WebURLRequest::FetchRequestModeCORS:
380 case WebURLRequest::FetchRequestModeCORSWithForcedPreflight: 381 case WebURLRequest::FetchRequestModeCORSWithForcedPreflight:
381 threadableLoaderOptions.crossOriginRequestPolicy = UseAccessControl; 382 threadableLoaderOptions.crossOriginRequestPolicy = UseAccessControl;
382 break; 383 break;
383 } 384 }
385 InspectorInstrumentation::willStartFetch(executionContext(), this);
384 m_loader = ThreadableLoader::create(*executionContext(), this, request, thre adableLoaderOptions, resourceLoaderOptions); 386 m_loader = ThreadableLoader::create(*executionContext(), this, request, thre adableLoaderOptions, resourceLoaderOptions);
385 if (!m_loader) 387 if (!m_loader) {
388 InspectorInstrumentation::didFailFetch(executionContext(), this);
386 performNetworkError("Can't create ThreadableLoader"); 389 performNetworkError("Can't create ThreadableLoader");
dgozman 2015/07/31 06:50:38 This method calls |failed| which in turn calls |di
390 }
387 } 391 }
388 392
389 void FetchManager::Loader::failed(const String& message) 393 void FetchManager::Loader::failed(const String& message)
390 { 394 {
391 if (m_failed || m_finished) 395 if (m_failed || m_finished)
392 return; 396 return;
393 m_failed = true; 397 m_failed = true;
394 if (!message.isEmpty()) 398 if (!message.isEmpty())
395 executionContext()->addConsoleMessage(ConsoleMessage::create(JSMessageSo urce, ErrorMessageLevel, message)); 399 executionContext()->addConsoleMessage(ConsoleMessage::create(JSMessageSo urce, ErrorMessageLevel, message));
396 if (m_resolver) { 400 if (m_resolver) {
397 if (!m_resolver->executionContext() || m_resolver->executionContext()->a ctiveDOMObjectsAreStopped()) 401 if (!m_resolver->executionContext() || m_resolver->executionContext()->a ctiveDOMObjectsAreStopped())
398 return; 402 return;
399 ScriptState* state = m_resolver->scriptState(); 403 ScriptState* state = m_resolver->scriptState();
400 ScriptState::Scope scope(state); 404 ScriptState::Scope scope(state);
401 m_resolver->reject(V8ThrowException::createTypeError(state->isolate(), " Failed to fetch")); 405 m_resolver->reject(V8ThrowException::createTypeError(state->isolate(), " Failed to fetch"));
402 } 406 }
407 InspectorInstrumentation::didFailFetch(executionContext(), this);
403 notifyFinished(); 408 notifyFinished();
404 } 409 }
405 410
406 void FetchManager::Loader::notifyFinished() 411 void FetchManager::Loader::notifyFinished()
407 { 412 {
408 if (m_fetchManager) 413 if (m_fetchManager)
409 m_fetchManager->onLoaderFinished(this); 414 m_fetchManager->onLoaderFinished(this);
410 } 415 }
411 416
412 FetchManager::FetchManager(ExecutionContext* executionContext) 417 FetchManager::FetchManager(ExecutionContext* executionContext)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 459
455 DEFINE_TRACE(FetchManager) 460 DEFINE_TRACE(FetchManager)
456 { 461 {
457 #if ENABLE(OILPAN) 462 #if ENABLE(OILPAN)
458 visitor->trace(m_executionContext); 463 visitor->trace(m_executionContext);
459 visitor->trace(m_loaders); 464 visitor->trace(m_loaders);
460 #endif 465 #endif
461 } 466 }
462 467
463 } // namespace blink 468 } // namespace blink
OLDNEW
« Source/core/inspector/InspectorResourceAgent.cpp ('K') | « Source/devtools/protocol.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698