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

Side by Side Diff: Source/core/xml/XMLHttpRequest.cpp

Issue 342703002: Move XMLHttpRequest use counter to count requests from workers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 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 | no next file » | 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) 2004, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> 3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org>
4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> 4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org>
5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. 5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved.
6 * Copyright (C) 2012 Intel Corporation 6 * Copyright (C) 2012 Intel Corporation
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 return; 566 return;
567 } 567 }
568 568
569 if (!ContentSecurityPolicy::shouldBypassMainWorld(executionContext()) && !ex ecutionContext()->contentSecurityPolicy()->allowConnectToSource(url)) { 569 if (!ContentSecurityPolicy::shouldBypassMainWorld(executionContext()) && !ex ecutionContext()->contentSecurityPolicy()->allowConnectToSource(url)) {
570 // We can safely expose the URL to JavaScript, as these checks happen sy nchronously before redirection. JavaScript receives no new information. 570 // We can safely expose the URL to JavaScript, as these checks happen sy nchronously before redirection. JavaScript receives no new information.
571 exceptionState.throwSecurityError("Refused to connect to '" + url.elided String() + "' because it violates the document's Content Security Policy."); 571 exceptionState.throwSecurityError("Refused to connect to '" + url.elided String() + "' because it violates the document's Content Security Policy.");
572 return; 572 return;
573 } 573 }
574 574
575 if (!async && executionContext()->isDocument()) { 575 if (!async && executionContext()->isDocument()) {
576 // Use count for XHR synchronous requests.
577 UseCounter::count(document(), UseCounter::XMLHttpRequestSynchronous);
578
579 if (document()->settings() && !document()->settings()->syncXHRInDocument sEnabled()) { 576 if (document()->settings() && !document()->settings()->syncXHRInDocument sEnabled()) {
580 exceptionState.throwDOMException(InvalidAccessError, "Synchronous re quests are disabled for this page."); 577 exceptionState.throwDOMException(InvalidAccessError, "Synchronous re quests are disabled for this page.");
581 return; 578 return;
582 } 579 }
583 580
584 // Newer functionality is not available to synchronous requests in windo w contexts, as a spec-mandated 581 // Newer functionality is not available to synchronous requests in windo w contexts, as a spec-mandated
585 // attempt to discourage synchronous XHR use. responseType is one such p iece of functionality. 582 // attempt to discourage synchronous XHR use. responseType is one such p iece of functionality.
586 if (m_responseTypeCode != ResponseTypeDefault) { 583 if (m_responseTypeCode != ResponseTypeDefault) {
587 exceptionState.throwDOMException(InvalidAccessError, "Synchronous re quests from a document must not set a response type."); 584 exceptionState.throwDOMException(InvalidAccessError, "Synchronous re quests from a document must not set a response type.");
588 return; 585 return;
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 // FIXME: Maybe create() can return null for other reasons too? 885 // FIXME: Maybe create() can return null for other reasons too?
889 ASSERT(!m_loader); 886 ASSERT(!m_loader);
890 m_loader = ThreadableLoader::create(executionContext, this, request, opt ions, resourceLoaderOptions); 887 m_loader = ThreadableLoader::create(executionContext, this, request, opt ions, resourceLoaderOptions);
891 if (m_loader) { 888 if (m_loader) {
892 // Neither this object nor the JavaScript wrapper should be deleted while 889 // Neither this object nor the JavaScript wrapper should be deleted while
893 // a request is in progress because we need to keep the listeners al ive, 890 // a request is in progress because we need to keep the listeners al ive,
894 // and they are referenced by the JavaScript wrapper. 891 // and they are referenced by the JavaScript wrapper.
895 setPendingActivity(this); 892 setPendingActivity(this);
896 } 893 }
897 } else { 894 } else {
895 // Use count for XHR synchronous requests.
896 UseCounter::count(&executionContext, UseCounter::XMLHttpRequestSynchrono us);
898 ThreadableLoader::loadResourceSynchronously(executionContext, request, * this, options, resourceLoaderOptions); 897 ThreadableLoader::loadResourceSynchronously(executionContext, request, * this, options, resourceLoaderOptions);
899 } 898 }
900 899
901 if (!m_exceptionCode && m_error) 900 if (!m_exceptionCode && m_error)
902 m_exceptionCode = NetworkError; 901 m_exceptionCode = NetworkError;
903 if (m_exceptionCode) 902 if (m_exceptionCode)
904 exceptionState.throwDOMException(m_exceptionCode, "Failed to load '" + m _url.elidedString() + "'."); 903 exceptionState.throwDOMException(m_exceptionCode, "Failed to load '" + m _url.elidedString() + "'.");
905 } 904 }
906 905
907 void XMLHttpRequest::abort() 906 void XMLHttpRequest::abort()
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 { 1461 {
1463 visitor->trace(m_responseBlob); 1462 visitor->trace(m_responseBlob);
1464 visitor->trace(m_responseStream); 1463 visitor->trace(m_responseStream);
1465 visitor->trace(m_responseDocument); 1464 visitor->trace(m_responseDocument);
1466 visitor->trace(m_progressEventThrottle); 1465 visitor->trace(m_progressEventThrottle);
1467 visitor->trace(m_upload); 1466 visitor->trace(m_upload);
1468 XMLHttpRequestEventTarget::trace(visitor); 1467 XMLHttpRequestEventTarget::trace(visitor);
1469 } 1468 }
1470 1469
1471 } // namespace WebCore 1470 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698