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

Side by Side Diff: third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp

Issue 1954833003: DocumentThreadableLoader: Add guards for sync notifyFinished() in setResource() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 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) 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 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 resourceLoaderOptions.dataBufferingPolicy = BufferData; 835 resourceLoaderOptions.dataBufferingPolicy = BufferData;
836 836
837 if (m_options.timeoutMilliseconds > 0) 837 if (m_options.timeoutMilliseconds > 0)
838 m_timeoutTimer.startOneShot(m_options.timeoutMilliseconds / 1000.0, BLINK_FROM_HERE); 838 m_timeoutTimer.startOneShot(m_options.timeoutMilliseconds / 1000.0, BLINK_FROM_HERE);
839 839
840 FetchRequest newRequest(request, m_options.initiator, resourceLoaderOpti ons); 840 FetchRequest newRequest(request, m_options.initiator, resourceLoaderOpti ons);
841 if (m_options.crossOriginRequestPolicy == AllowCrossOriginRequests) 841 if (m_options.crossOriginRequestPolicy == AllowCrossOriginRequests)
842 newRequest.setOriginRestriction(FetchRequest::NoOriginRestriction); 842 newRequest.setOriginRestriction(FetchRequest::NoOriginRestriction);
843 ASSERT(!resource()); 843 ASSERT(!resource());
844 844
845 WeakPtr<DocumentThreadableLoader> self(m_weakFactory.createWeakPtr());
846
845 if (request.requestContext() == WebURLRequest::RequestContextVideo || re quest.requestContext() == WebURLRequest::RequestContextAudio) 847 if (request.requestContext() == WebURLRequest::RequestContextVideo || re quest.requestContext() == WebURLRequest::RequestContextAudio)
846 setResource(RawResource::fetchMedia(newRequest, document().fetcher() )); 848 setResource(RawResource::fetchMedia(newRequest, document().fetcher() ));
847 else if (request.requestContext() == WebURLRequest::RequestContextManife st) 849 else if (request.requestContext() == WebURLRequest::RequestContextManife st)
848 setResource(RawResource::fetchManifest(newRequest, document().fetche r())); 850 setResource(RawResource::fetchManifest(newRequest, document().fetche r()));
849 else 851 else
850 setResource(RawResource::fetch(newRequest, document().fetcher())); 852 setResource(RawResource::fetch(newRequest, document().fetcher()));
851 853
854 // setResource() might call notifyFinished() synchronously, and thus
855 // clear() might be called and |this| may be dead here.
856 if (!self)
857 return;
858
852 if (!resource()) { 859 if (!resource()) {
853 ThreadableLoaderClient* client = m_client; 860 ThreadableLoaderClient* client = m_client;
854 clear(); 861 clear();
862 // setResource() might call notifyFinished() and thus clear()
863 // synchronously, and in such cases ThreadableLoaderClient is
864 // already notified and |client| is null.
865 if (!client)
866 return;
855 client->didFail(ResourceError(errorDomainBlinkInternal, 0, requestUR L.getString(), "Failed to start loading.")); 867 client->didFail(ResourceError(errorDomainBlinkInternal, 0, requestUR L.getString(), "Failed to start loading."));
856 // |this| may be dead here. 868 // |this| may be dead here.
857 return; 869 return;
858 } 870 }
859 871
860 if (resource()->loader()) { 872 if (resource()->loader()) {
861 unsigned long identifier = resource()->identifier(); 873 unsigned long identifier = resource()->identifier();
862 InspectorInstrumentation::documentThreadableLoaderStartedLoadingForC lient(m_document, identifier, m_client); 874 InspectorInstrumentation::documentThreadableLoaderStartedLoadingForC lient(m_document, identifier, m_client);
863 } 875 }
864 return; 876 return;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 return m_securityOrigin ? m_securityOrigin.get() : document().getSecurityOri gin(); 948 return m_securityOrigin ? m_securityOrigin.get() : document().getSecurityOri gin();
937 } 949 }
938 950
939 Document& DocumentThreadableLoader::document() const 951 Document& DocumentThreadableLoader::document() const
940 { 952 {
941 ASSERT(m_document); 953 ASSERT(m_document);
942 return *m_document; 954 return *m_document;
943 } 955 }
944 956
945 } // namespace blink 957 } // namespace blink
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