| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2013, Intel Corporation | 3 * Copyright (C) 2013, Intel Corporation |
| 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 are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // Max number of CORS redirects handled in DocumentThreadableLoader. | 99 // Max number of CORS redirects handled in DocumentThreadableLoader. |
| 100 // Same number as net/url_request/url_request.cc, and | 100 // Same number as net/url_request/url_request.cc, and |
| 101 // same number as https://fetch.spec.whatwg.org/#concept-http-fetch, Step 4. | 101 // same number as https://fetch.spec.whatwg.org/#concept-http-fetch, Step 4. |
| 102 // FIXME: currently the number of redirects is counted and limited here and in | 102 // FIXME: currently the number of redirects is counted and limited here and in |
| 103 // net/url_request/url_request.cc separately. | 103 // net/url_request/url_request.cc separately. |
| 104 static const int kMaxCORSRedirects = 20; | 104 static const int kMaxCORSRedirects = 20; |
| 105 | 105 |
| 106 void DocumentThreadableLoader::loadResourceSynchronously(Document& document, con
st ResourceRequest& request, ThreadableLoaderClient& client, const ThreadableLoa
derOptions& options, const ResourceLoaderOptions& resourceLoaderOptions) | 106 void DocumentThreadableLoader::loadResourceSynchronously(Document& document, con
st ResourceRequest& request, ThreadableLoaderClient& client, const ThreadableLoa
derOptions& options, const ResourceLoaderOptions& resourceLoaderOptions) |
| 107 { | 107 { |
| 108 // The loader will be deleted as soon as this function exits. | 108 // The loader will be deleted as soon as this function exits. |
| 109 RefPtr<DocumentThreadableLoader> loader = adoptRef(new DocumentThreadableLoa
der(document, &client, LoadSynchronously, options, resourceLoaderOptions)); | 109 OwnPtr<DocumentThreadableLoader> loader = adoptPtr(new DocumentThreadableLoa
der(document, &client, LoadSynchronously, options, resourceLoaderOptions)); |
| 110 loader->start(request); | 110 loader->start(request); |
| 111 ASSERT(loader->hasOneRef()); | |
| 112 } | 111 } |
| 113 | 112 |
| 114 PassRefPtr<DocumentThreadableLoader> DocumentThreadableLoader::create(Document&
document, ThreadableLoaderClient* client, const ThreadableLoaderOptions& options
, const ResourceLoaderOptions& resourceLoaderOptions) | 113 PassOwnPtr<DocumentThreadableLoader> DocumentThreadableLoader::create(Document&
document, ThreadableLoaderClient* client, const ThreadableLoaderOptions& options
, const ResourceLoaderOptions& resourceLoaderOptions) |
| 115 { | 114 { |
| 116 return adoptRef(new DocumentThreadableLoader(document, client, LoadAsynchron
ously, options, resourceLoaderOptions)); | 115 return adoptPtr(new DocumentThreadableLoader(document, client, LoadAsynchron
ously, options, resourceLoaderOptions)); |
| 117 } | 116 } |
| 118 | 117 |
| 119 DocumentThreadableLoader::DocumentThreadableLoader(Document& document, Threadabl
eLoaderClient* client, BlockingBehavior blockingBehavior, const ThreadableLoader
Options& options, const ResourceLoaderOptions& resourceLoaderOptions) | 118 DocumentThreadableLoader::DocumentThreadableLoader(Document& document, Threadabl
eLoaderClient* client, BlockingBehavior blockingBehavior, const ThreadableLoader
Options& options, const ResourceLoaderOptions& resourceLoaderOptions) |
| 120 : m_client(client) | 119 : m_client(client) |
| 121 , m_document(&document) | 120 , m_document(&document) |
| 122 , m_options(options) | 121 , m_options(options) |
| 123 , m_resourceLoaderOptions(resourceLoaderOptions) | 122 , m_resourceLoaderOptions(resourceLoaderOptions) |
| 124 , m_forceDoNotAllowStoredCredentials(false) | 123 , m_forceDoNotAllowStoredCredentials(false) |
| 125 , m_securityOrigin(m_resourceLoaderOptions.securityOrigin) | 124 , m_securityOrigin(m_resourceLoaderOptions.securityOrigin) |
| 126 , m_sameOriginRequest(false) | 125 , m_sameOriginRequest(false) |
| 127 , m_crossOriginNonSimpleRequest(false) | 126 , m_crossOriginNonSimpleRequest(false) |
| 128 , m_isUsingDataConsumerHandle(false) | 127 , m_isUsingDataConsumerHandle(false) |
| 129 , m_async(blockingBehavior == LoadAsynchronously) | 128 , m_async(blockingBehavior == LoadAsynchronously) |
| 130 , m_requestContext(WebURLRequest::RequestContextUnspecified) | 129 , m_requestContext(WebURLRequest::RequestContextUnspecified) |
| 131 , m_timeoutTimer(this, &DocumentThreadableLoader::didTimeout) | 130 , m_timeoutTimer(this, &DocumentThreadableLoader::didTimeout) |
| 132 , m_requestStartedSeconds(0.0) | 131 , m_requestStartedSeconds(0.0) |
| 133 , m_corsRedirectLimit(kMaxCORSRedirects) | 132 , m_corsRedirectLimit(kMaxCORSRedirects) |
| 134 , m_redirectMode(WebURLRequest::FetchRedirectModeFollow) | 133 , m_redirectMode(WebURLRequest::FetchRedirectModeFollow) |
| 134 , m_weakFactory(this) |
| 135 { | 135 { |
| 136 ASSERT(client); | 136 ASSERT(client); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void DocumentThreadableLoader::start(const ResourceRequest& request) | 139 void DocumentThreadableLoader::start(const ResourceRequest& request) |
| 140 { | 140 { |
| 141 // Setting an outgoing referer is only supported in the async code path. | 141 // Setting an outgoing referer is only supported in the async code path. |
| 142 ASSERT(m_async || request.httpReferrer().isEmpty()); | 142 ASSERT(m_async || request.httpReferrer().isEmpty()); |
| 143 | 143 |
| 144 m_sameOriginRequest = securityOrigin()->canRequestNoSuborigin(request.url())
; | 144 m_sameOriginRequest = securityOrigin()->canRequestNoSuborigin(request.url())
; |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 // |this| may be dead here. | 389 // |this| may be dead here. |
| 390 | 390 |
| 391 request = ResourceRequest(); | 391 request = ResourceRequest(); |
| 392 | 392 |
| 393 return; | 393 return; |
| 394 } | 394 } |
| 395 | 395 |
| 396 if (m_redirectMode == WebURLRequest::FetchRedirectModeManual) { | 396 if (m_redirectMode == WebURLRequest::FetchRedirectModeManual) { |
| 397 // Keep |this| alive even if the client release a reference in | 397 // Keep |this| alive even if the client release a reference in |
| 398 // responseReceived(). | 398 // responseReceived(). |
| 399 RefPtr<DocumentThreadableLoader> protect(this); | 399 WeakPtr<DocumentThreadableLoader> self(m_weakFactory.createWeakPtr()); |
| 400 | 400 |
| 401 // We use |m_redirectMode| to check the original redirect mode. | 401 // We use |m_redirectMode| to check the original redirect mode. |
| 402 // |request| is a new request for redirect. So we don't set the redirect | 402 // |request| is a new request for redirect. So we don't set the redirect |
| 403 // mode of it in WebURLLoaderImpl::Context::OnReceivedRedirect(). | 403 // mode of it in WebURLLoaderImpl::Context::OnReceivedRedirect(). |
| 404 ASSERT(request.useStreamOnResponse()); | 404 ASSERT(request.useStreamOnResponse()); |
| 405 // There is no need to read the body of redirect response because there | 405 // There is no need to read the body of redirect response because there |
| 406 // is no way to read the body of opaque-redirect filtered response's | 406 // is no way to read the body of opaque-redirect filtered response's |
| 407 // internal response. | 407 // internal response. |
| 408 // TODO(horo): If we support any API which expose the internal body, we | 408 // TODO(horo): If we support any API which expose the internal body, we |
| 409 // will have to read the body. And also HTTPCache changes will be needed | 409 // will have to read the body. And also HTTPCache changes will be needed |
| 410 // because it doesn't store the body of redirect responses. | 410 // because it doesn't store the body of redirect responses. |
| 411 responseReceived(resource, redirectResponse, adoptPtr(new EmptyDataHandl
e())); | 411 responseReceived(resource, redirectResponse, adoptPtr(new EmptyDataHandl
e())); |
| 412 | 412 |
| 413 if (!self) { |
| 414 request = ResourceRequest(); |
| 415 return; |
| 416 } |
| 417 |
| 413 if (m_client) { | 418 if (m_client) { |
| 414 ASSERT(m_actualRequest.isNull()); | 419 ASSERT(m_actualRequest.isNull()); |
| 415 notifyFinished(resource); | 420 notifyFinished(resource); |
| 416 } | 421 } |
| 417 | 422 |
| 418 request = ResourceRequest(); | 423 request = ResourceRequest(); |
| 419 | 424 |
| 420 return; | 425 return; |
| 421 } | 426 } |
| 422 | 427 |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 return m_securityOrigin ? m_securityOrigin.get() : document().securityOrigin
(); | 924 return m_securityOrigin ? m_securityOrigin.get() : document().securityOrigin
(); |
| 920 } | 925 } |
| 921 | 926 |
| 922 Document& DocumentThreadableLoader::document() const | 927 Document& DocumentThreadableLoader::document() const |
| 923 { | 928 { |
| 924 ASSERT(m_document); | 929 ASSERT(m_document); |
| 925 return *m_document; | 930 return *m_document; |
| 926 } | 931 } |
| 927 | 932 |
| 928 } // namespace blink | 933 } // namespace blink |
| OLD | NEW |