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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
338 ResourceLoaderOptions preflightOptions = m_actualOptions; | 338 ResourceLoaderOptions preflightOptions = m_actualOptions; |
339 preflightOptions.allowCredentials = DoNotAllowStoredCredentials; | 339 preflightOptions.allowCredentials = DoNotAllowStoredCredentials; |
340 loadRequest(preflightRequest, preflightOptions); | 340 loadRequest(preflightRequest, preflightOptions); |
341 // |this| may be dead here in async mode. | 341 // |this| may be dead here in async mode. |
342 } | 342 } |
343 } | 343 } |
344 } | 344 } |
345 | 345 |
346 DocumentThreadableLoader::~DocumentThreadableLoader() | 346 DocumentThreadableLoader::~DocumentThreadableLoader() |
347 { | 347 { |
348 m_client = nullptr; | 348 DCHECK(!m_client); |
hiroshige
2016/07/19 06:56:13
optional: how about making this CHECK() for a whil
yhirano
2016/07/19 08:05:03
Done.
| |
349 | 349 |
350 // TODO(oilpan): Remove this once DocumentThreadableLoader is once again a R esourceOwner. | 350 // TODO(oilpan): Remove this once DocumentThreadableLoader is once again a R esourceOwner. |
351 clearResource(); | 351 clearResource(); |
352 } | 352 } |
353 | 353 |
354 void DocumentThreadableLoader::overrideTimeout(unsigned long timeoutMilliseconds ) | 354 void DocumentThreadableLoader::overrideTimeout(unsigned long timeoutMilliseconds ) |
355 { | 355 { |
356 ASSERT(m_async); | 356 ASSERT(m_async); |
357 | 357 |
358 // |m_requestStartedSeconds| == 0.0 indicates loading is already finished | 358 // |m_requestStartedSeconds| == 0.0 indicates loading is already finished |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
930 | 930 |
931 FetchRequest fetchRequest(request, m_options.initiator, resourceLoaderOption s); | 931 FetchRequest fetchRequest(request, m_options.initiator, resourceLoaderOption s); |
932 if (m_options.crossOriginRequestPolicy == AllowCrossOriginRequests) | 932 if (m_options.crossOriginRequestPolicy == AllowCrossOriginRequests) |
933 fetchRequest.setOriginRestriction(FetchRequest::NoOriginRestriction); | 933 fetchRequest.setOriginRestriction(FetchRequest::NoOriginRestriction); |
934 Resource* resource = RawResource::fetchSynchronously(fetchRequest, document( ).fetcher()); | 934 Resource* resource = RawResource::fetchSynchronously(fetchRequest, document( ).fetcher()); |
935 ResourceResponse response = resource ? resource->response() : ResourceRespon se(); | 935 ResourceResponse response = resource ? resource->response() : ResourceRespon se(); |
936 unsigned long identifier = resource ? resource->identifier() : std::numeric_ limits<unsigned long>::max(); | 936 unsigned long identifier = resource ? resource->identifier() : std::numeric_ limits<unsigned long>::max(); |
937 ResourceError error = resource ? resource->resourceError() : ResourceError() ; | 937 ResourceError error = resource ? resource->resourceError() : ResourceError() ; |
938 | 938 |
939 InspectorInstrumentation::documentThreadableLoaderStartedLoadingForClient(m_ document, identifier, m_client); | 939 InspectorInstrumentation::documentThreadableLoaderStartedLoadingForClient(m_ document, identifier, m_client); |
940 ThreadableLoaderClient* client = m_client; | |
hiroshige
2016/07/19 06:56:14
IIUC the changes of lines 940--961 are made in ord
yhirano
2016/07/19 08:05:03
Yes, as m_client will never be used after a comple
| |
940 | 941 |
941 if (!resource) { | 942 if (!resource) { |
942 m_client->didFail(error); | 943 m_client = nullptr; |
944 client->didFail(error); | |
943 return; | 945 return; |
944 } | 946 } |
945 | 947 |
946 // No exception for file:/// resources, see <rdar://problem/4962298>. | 948 // No exception for file:/// resources, see <rdar://problem/4962298>. |
947 // Also, if we have an HTTP response, then it wasn't a network error in fact . | 949 // Also, if we have an HTTP response, then it wasn't a network error in fact . |
948 if (!error.isNull() && !requestURL.isLocalFile() && response.httpStatusCode( ) <= 0) { | 950 if (!error.isNull() && !requestURL.isLocalFile() && response.httpStatusCode( ) <= 0) { |
949 m_client->didFail(error); | 951 m_client = nullptr; |
952 client->didFail(error); | |
950 return; | 953 return; |
951 } | 954 } |
952 | 955 |
953 // FIXME: A synchronous request does not tell us whether a redirect happened or not, so we guess by comparing the | 956 // FIXME: A synchronous request does not tell us whether a redirect happened or not, so we guess by comparing the |
954 // request and response URLs. This isn't a perfect test though, since a serv er can serve a redirect to the same URL that was | 957 // request and response URLs. This isn't a perfect test though, since a serv er can serve a redirect to the same URL that was |
955 // requested. Also comparing the request and response URLs as strings will f ail if the requestURL still has its credentials. | 958 // requested. Also comparing the request and response URLs as strings will f ail if the requestURL still has its credentials. |
956 if (requestURL != response.url() && !isAllowedRedirect(response.url())) { | 959 if (requestURL != response.url() && !isAllowedRedirect(response.url())) { |
957 m_client->didFailRedirectCheck(); | 960 m_client = nullptr; |
961 client->didFailRedirectCheck(); | |
958 return; | 962 return; |
959 } | 963 } |
960 | 964 |
961 handleResponse(identifier, response, nullptr); | 965 handleResponse(identifier, response, nullptr); |
962 | 966 |
963 // handleResponse() may detect an error. In such a case (check |m_client| | 967 // handleResponse() may detect an error. In such a case (check |m_client| |
964 // as it gets reset by clear() call), skip the rest. | 968 // as it gets reset by clear() call), skip the rest. |
965 // | 969 // |
966 // |this| is alive here since loadResourceSynchronously() keeps it alive | 970 // |this| is alive here since loadResourceSynchronously() keeps it alive |
967 // until the end of the function. | 971 // until the end of the function. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1000 return m_securityOrigin ? m_securityOrigin.get() : document().getSecurityOri gin(); | 1004 return m_securityOrigin ? m_securityOrigin.get() : document().getSecurityOri gin(); |
1001 } | 1005 } |
1002 | 1006 |
1003 Document& DocumentThreadableLoader::document() const | 1007 Document& DocumentThreadableLoader::document() const |
1004 { | 1008 { |
1005 ASSERT(m_document); | 1009 ASSERT(m_document); |
1006 return *m_document; | 1010 return *m_document; |
1007 } | 1011 } |
1008 | 1012 |
1009 } // namespace blink | 1013 } // namespace blink |
OLD | NEW |