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 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 } else { | 893 } else { |
894 handleSuccessfulFinish(resource->identifier(), resource->loadFinishTime()); | 894 handleSuccessfulFinish(resource->identifier(), resource->loadFinishTime()); |
895 } | 895 } |
896 } | 896 } |
897 | 897 |
898 void DocumentThreadableLoader::handleSuccessfulFinish(unsigned long identifier, | 898 void DocumentThreadableLoader::handleSuccessfulFinish(unsigned long identifier, |
899 double finishTime) { | 899 double finishTime) { |
900 DCHECK(m_fallbackRequestForServiceWorker.isNull()); | 900 DCHECK(m_fallbackRequestForServiceWorker.isNull()); |
901 | 901 |
902 if (!m_actualRequest.isNull()) { | 902 if (!m_actualRequest.isNull()) { |
903 // FIXME: Timeout should be applied to whole fetch, not for each of | |
904 // preflight and actual request. | |
905 m_timeoutTimer.stop(); | |
906 DCHECK(!m_sameOriginRequest); | 903 DCHECK(!m_sameOriginRequest); |
907 DCHECK_EQ(m_options.crossOriginRequestPolicy, UseAccessControl); | 904 DCHECK_EQ(m_options.crossOriginRequestPolicy, UseAccessControl); |
908 loadActualRequest(); | 905 loadActualRequest(); |
909 return; | 906 return; |
910 } | 907 } |
911 | 908 |
912 ThreadableLoaderClient* client = m_client; | 909 ThreadableLoaderClient* client = m_client; |
913 // Protect the resource in |didFinishLoading| in order not to release the | 910 // Protect the resource in |didFinishLoading| in order not to release the |
914 // downloaded file. | 911 // downloaded file. |
915 Persistent<Resource> protect = resource(); | 912 Persistent<Resource> protect = resource(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 clear(); | 978 clear(); |
982 client->didFail(error); | 979 client->didFail(error); |
983 } | 980 } |
984 | 981 |
985 void DocumentThreadableLoader::loadRequestAsync( | 982 void DocumentThreadableLoader::loadRequestAsync( |
986 const ResourceRequest& request, | 983 const ResourceRequest& request, |
987 ResourceLoaderOptions resourceLoaderOptions) { | 984 ResourceLoaderOptions resourceLoaderOptions) { |
988 if (!m_actualRequest.isNull()) | 985 if (!m_actualRequest.isNull()) |
989 resourceLoaderOptions.dataBufferingPolicy = BufferData; | 986 resourceLoaderOptions.dataBufferingPolicy = BufferData; |
990 | 987 |
991 if (m_options.timeoutMilliseconds > 0) { | 988 // The timer can be active if this is the actual request of a |
| 989 // CORS-with-preflight request. |
| 990 if (m_options.timeoutMilliseconds > 0 && !m_timeoutTimer.isActive()) { |
992 m_timeoutTimer.startOneShot(m_options.timeoutMilliseconds / 1000.0, | 991 m_timeoutTimer.startOneShot(m_options.timeoutMilliseconds / 1000.0, |
993 BLINK_FROM_HERE); | 992 BLINK_FROM_HERE); |
994 } | 993 } |
995 | 994 |
996 FetchRequest newRequest(request, m_options.initiator, resourceLoaderOptions); | 995 FetchRequest newRequest(request, m_options.initiator, resourceLoaderOptions); |
997 if (m_options.crossOriginRequestPolicy == AllowCrossOriginRequests) | 996 if (m_options.crossOriginRequestPolicy == AllowCrossOriginRequests) |
998 newRequest.setOriginRestriction(FetchRequest::NoOriginRestriction); | 997 newRequest.setOriginRestriction(FetchRequest::NoOriginRestriction); |
999 DCHECK(!resource()); | 998 DCHECK(!resource()); |
1000 | 999 |
1001 ResourceFetcher* fetcher = m_loadingContext->getResourceFetcher(); | 1000 ResourceFetcher* fetcher = m_loadingContext->getResourceFetcher(); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1145 } | 1144 } |
1146 | 1145 |
1147 DEFINE_TRACE(DocumentThreadableLoader) { | 1146 DEFINE_TRACE(DocumentThreadableLoader) { |
1148 visitor->trace(m_resource); | 1147 visitor->trace(m_resource); |
1149 visitor->trace(m_loadingContext); | 1148 visitor->trace(m_loadingContext); |
1150 ThreadableLoader::trace(visitor); | 1149 ThreadableLoader::trace(visitor); |
1151 RawResourceClient::trace(visitor); | 1150 RawResourceClient::trace(visitor); |
1152 } | 1151 } |
1153 | 1152 |
1154 } // namespace blink | 1153 } // namespace blink |
OLD | NEW |