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

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

Issue 1902683002: DocumentThreadableLoader: Add guards for sync notifyFinished() in setResource() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 if (!client)
863 return;
tyoshino (SeeGerritForStatus) 2016/04/19 06:27:44 add comment to note that we need to call clear() f
tyoshino (SeeGerritForStatus) 2016/04/19 06:29:00 oh, basically the same as what you've put in the d
hiroshige 2016/04/19 06:40:48 Done.
tyoshino (SeeGerritForStatus) 2016/04/19 08:31:32 Thanks. LGTM
855 client->didFail(ResourceError(errorDomainBlinkInternal, 0, requestUR L.getString(), "Failed to start loading.")); 864 client->didFail(ResourceError(errorDomainBlinkInternal, 0, requestUR L.getString(), "Failed to start loading."));
856 // |this| may be dead here. 865 // |this| may be dead here.
857 return; 866 return;
858 } 867 }
859 868
860 if (resource()->loader()) { 869 if (resource()->loader()) {
861 unsigned long identifier = resource()->identifier(); 870 unsigned long identifier = resource()->identifier();
862 InspectorInstrumentation::documentThreadableLoaderStartedLoadingForC lient(m_document, identifier, m_client); 871 InspectorInstrumentation::documentThreadableLoaderStartedLoadingForC lient(m_document, identifier, m_client);
863 } 872 }
864 return; 873 return;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 return m_securityOrigin ? m_securityOrigin.get() : document().getSecurityOri gin(); 945 return m_securityOrigin ? m_securityOrigin.get() : document().getSecurityOri gin();
937 } 946 }
938 947
939 Document& DocumentThreadableLoader::document() const 948 Document& DocumentThreadableLoader::document() const
940 { 949 {
941 ASSERT(m_document); 950 ASSERT(m_document);
942 return *m_document; 951 return *m_document;
943 } 952 }
944 953
945 } // namespace blink 954 } // 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