| 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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 preflightOptions.allowCredentials = DoNotAllowStoredCredentials; | 346 preflightOptions.allowCredentials = DoNotAllowStoredCredentials; |
| 347 loadRequest(preflightRequest, preflightOptions); | 347 loadRequest(preflightRequest, preflightOptions); |
| 348 // |this| may be dead here in async mode. | 348 // |this| may be dead here in async mode. |
| 349 } | 349 } |
| 350 } | 350 } |
| 351 } | 351 } |
| 352 | 352 |
| 353 DocumentThreadableLoader::~DocumentThreadableLoader() | 353 DocumentThreadableLoader::~DocumentThreadableLoader() |
| 354 { | 354 { |
| 355 CHECK(!m_client); | 355 CHECK(!m_client); |
| 356 | 356 DCHECK(!m_resource); |
| 357 // TODO(oilpan): Remove this once DocumentThreadableLoader is once again a R
esourceOwner. | |
| 358 clearResource(); | |
| 359 } | 357 } |
| 360 | 358 |
| 361 void DocumentThreadableLoader::overrideTimeout(unsigned long timeoutMilliseconds
) | 359 void DocumentThreadableLoader::overrideTimeout(unsigned long timeoutMilliseconds
) |
| 362 { | 360 { |
| 363 ASSERT(m_async); | 361 ASSERT(m_async); |
| 364 | 362 |
| 365 // |m_requestStartedSeconds| == 0.0 indicates loading is already finished | 363 // |m_requestStartedSeconds| == 0.0 indicates loading is already finished |
| 366 // and |m_timeoutTimer| is already stopped, and thus we do nothing for such | 364 // and |m_timeoutTimer| is already stopped, and thus we do nothing for such |
| 367 // cases. See https://crbug.com/551663 for details. | 365 // cases. See https://crbug.com/551663 for details. |
| 368 if (m_requestStartedSeconds <= 0.0) | 366 if (m_requestStartedSeconds <= 0.0) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 | 411 |
| 414 void DocumentThreadableLoader::setDefersLoading(bool value) | 412 void DocumentThreadableLoader::setDefersLoading(bool value) |
| 415 { | 413 { |
| 416 if (resource()) | 414 if (resource()) |
| 417 resource()->setDefersLoading(value); | 415 resource()->setDefersLoading(value); |
| 418 } | 416 } |
| 419 | 417 |
| 420 void DocumentThreadableLoader::clear() | 418 void DocumentThreadableLoader::clear() |
| 421 { | 419 { |
| 422 m_client = nullptr; | 420 m_client = nullptr; |
| 423 | |
| 424 if (!m_async) | |
| 425 return; | |
| 426 | |
| 427 m_timeoutTimer.stop(); | 421 m_timeoutTimer.stop(); |
| 428 m_requestStartedSeconds = 0.0; | 422 m_requestStartedSeconds = 0.0; |
| 429 clearResource(); | 423 clearResource(); |
| 430 } | 424 } |
| 431 | 425 |
| 432 // In this method, we can clear |request| to tell content::WebURLLoaderImpl of | 426 // In this method, we can clear |request| to tell content::WebURLLoaderImpl of |
| 433 // Chromium not to follow the redirect. This works only when this method is | 427 // Chromium not to follow the redirect. This works only when this method is |
| 434 // called by RawResource::willSendRequest(). If called by | 428 // called by RawResource::willSendRequest(). If called by |
| 435 // RawResource::didAddClient(), clearing |request| won't be propagated | 429 // RawResource::didAddClient(), clearing |request| won't be propagated |
| 436 // to content::WebURLLoaderImpl. So, this loader must also get detached from | 430 // to content::WebURLLoaderImpl. So, this loader must also get detached from |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 // preflight and actual request. | 786 // preflight and actual request. |
| 793 m_timeoutTimer.stop(); | 787 m_timeoutTimer.stop(); |
| 794 ASSERT(!m_sameOriginRequest); | 788 ASSERT(!m_sameOriginRequest); |
| 795 ASSERT(m_options.crossOriginRequestPolicy == UseAccessControl); | 789 ASSERT(m_options.crossOriginRequestPolicy == UseAccessControl); |
| 796 loadActualRequest(); | 790 loadActualRequest(); |
| 797 // |this| may be dead here in async mode. | 791 // |this| may be dead here in async mode. |
| 798 return; | 792 return; |
| 799 } | 793 } |
| 800 | 794 |
| 801 ThreadableLoaderClient* client = m_client; | 795 ThreadableLoaderClient* client = m_client; |
| 802 m_client = nullptr; | 796 // Protect the resource in |didFinishLoading| in order not to release the |
| 803 // Don't clear the resource as the client may need to access the downloaded | 797 // downloaded file. |
| 804 // file which will be released when the resource is destoryed. | 798 Persistent<Resource> resource = m_resource; |
| 805 if (m_async) { | 799 clear(); |
| 806 m_timeoutTimer.stop(); | |
| 807 m_requestStartedSeconds = 0.0; | |
| 808 } | |
| 809 client->didFinishLoading(identifier, finishTime); | 800 client->didFinishLoading(identifier, finishTime); |
| 810 // |this| may be dead here in async mode. | 801 // |this| may be dead here in async mode. |
| 811 } | 802 } |
| 812 | 803 |
| 813 void DocumentThreadableLoader::didTimeout(Timer<DocumentThreadableLoader>* timer
) | 804 void DocumentThreadableLoader::didTimeout(Timer<DocumentThreadableLoader>* timer
) |
| 814 { | 805 { |
| 815 ASSERT_UNUSED(timer, timer == &m_timeoutTimer); | 806 ASSERT_UNUSED(timer, timer == &m_timeoutTimer); |
| 816 | 807 |
| 817 // Using values from net/base/net_error_list.h ERR_TIMED_OUT, | 808 // Using values from net/base/net_error_list.h ERR_TIMED_OUT, |
| 818 // Same as existing FIXME above - this error should be coming from FrameLoad
erClient to be identifiable. | 809 // Same as existing FIXME above - this error should be coming from FrameLoad
erClient to be identifiable. |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 return m_securityOrigin ? m_securityOrigin.get() : document().getSecurityOri
gin(); | 1006 return m_securityOrigin ? m_securityOrigin.get() : document().getSecurityOri
gin(); |
| 1016 } | 1007 } |
| 1017 | 1008 |
| 1018 Document& DocumentThreadableLoader::document() const | 1009 Document& DocumentThreadableLoader::document() const |
| 1019 { | 1010 { |
| 1020 ASSERT(m_document); | 1011 ASSERT(m_document); |
| 1021 return *m_document; | 1012 return *m_document; |
| 1022 } | 1013 } |
| 1023 | 1014 |
| 1024 } // namespace blink | 1015 } // namespace blink |
| OLD | NEW |