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

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

Issue 1982273002: Merge DocumentThreadableLoader's m_weakPtrFactory into that of RawResourceClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Loader_WeakPtrRawResourceClient
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 | « third_party/WebKit/Source/core/loader/DocumentThreadableLoader.h ('k') | 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 , m_securityOrigin(m_resourceLoaderOptions.securityOrigin) 142 , m_securityOrigin(m_resourceLoaderOptions.securityOrigin)
143 , m_sameOriginRequest(false) 143 , m_sameOriginRequest(false)
144 , m_crossOriginNonSimpleRequest(false) 144 , m_crossOriginNonSimpleRequest(false)
145 , m_isUsingDataConsumerHandle(false) 145 , m_isUsingDataConsumerHandle(false)
146 , m_async(blockingBehavior == LoadAsynchronously) 146 , m_async(blockingBehavior == LoadAsynchronously)
147 , m_requestContext(WebURLRequest::RequestContextUnspecified) 147 , m_requestContext(WebURLRequest::RequestContextUnspecified)
148 , m_timeoutTimer(this, &DocumentThreadableLoader::didTimeout) 148 , m_timeoutTimer(this, &DocumentThreadableLoader::didTimeout)
149 , m_requestStartedSeconds(0.0) 149 , m_requestStartedSeconds(0.0)
150 , m_corsRedirectLimit(kMaxCORSRedirects) 150 , m_corsRedirectLimit(kMaxCORSRedirects)
151 , m_redirectMode(WebURLRequest::FetchRedirectModeFollow) 151 , m_redirectMode(WebURLRequest::FetchRedirectModeFollow)
152 , m_weakFactory(this)
153 { 152 {
154 ASSERT(client); 153 ASSERT(client);
155 } 154 }
156 155
157 void DocumentThreadableLoader::start(const ResourceRequest& request) 156 void DocumentThreadableLoader::start(const ResourceRequest& request)
158 { 157 {
159 // Setting an outgoing referer is only supported in the async code path. 158 // Setting an outgoing referer is only supported in the async code path.
160 ASSERT(m_async || request.httpReferrer().isEmpty()); 159 ASSERT(m_async || request.httpReferrer().isEmpty());
161 160
162 m_sameOriginRequest = getSecurityOrigin()->canRequestNoSuborigin(request.url ()); 161 m_sameOriginRequest = getSecurityOrigin()->canRequestNoSuborigin(request.url ());
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 // |this| may be dead here. 431 // |this| may be dead here.
433 432
434 request = ResourceRequest(); 433 request = ResourceRequest();
435 434
436 return; 435 return;
437 } 436 }
438 437
439 if (m_redirectMode == WebURLRequest::FetchRedirectModeManual) { 438 if (m_redirectMode == WebURLRequest::FetchRedirectModeManual) {
440 // Keep |this| alive even if the client release a reference in 439 // Keep |this| alive even if the client release a reference in
441 // responseReceived(). 440 // responseReceived().
442 WeakPtr<DocumentThreadableLoader> self(m_weakFactory.createWeakPtr()); 441 WeakPtr<RawResourceClient> self(createWeakPtr());
443 442
444 // We use |m_redirectMode| to check the original redirect mode. 443 // We use |m_redirectMode| to check the original redirect mode.
445 // |request| is a new request for redirect. So we don't set the redirect 444 // |request| is a new request for redirect. So we don't set the redirect
446 // mode of it in WebURLLoaderImpl::Context::OnReceivedRedirect(). 445 // mode of it in WebURLLoaderImpl::Context::OnReceivedRedirect().
447 ASSERT(request.useStreamOnResponse()); 446 ASSERT(request.useStreamOnResponse());
448 // There is no need to read the body of redirect response because there 447 // There is no need to read the body of redirect response because there
449 // is no way to read the body of opaque-redirect filtered response's 448 // is no way to read the body of opaque-redirect filtered response's
450 // internal response. 449 // internal response.
451 // TODO(horo): If we support any API which expose the internal body, we 450 // TODO(horo): If we support any API which expose the internal body, we
452 // will have to read the body. And also HTTPCache changes will be needed 451 // will have to read the body. And also HTTPCache changes will be needed
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 resourceLoaderOptions.dataBufferingPolicy = BufferData; 874 resourceLoaderOptions.dataBufferingPolicy = BufferData;
876 875
877 if (m_options.timeoutMilliseconds > 0) 876 if (m_options.timeoutMilliseconds > 0)
878 m_timeoutTimer.startOneShot(m_options.timeoutMilliseconds / 1000.0, BLINK_FROM_HERE); 877 m_timeoutTimer.startOneShot(m_options.timeoutMilliseconds / 1000.0, BLINK_FROM_HERE);
879 878
880 FetchRequest newRequest(request, m_options.initiator, resourceLoaderOpti ons); 879 FetchRequest newRequest(request, m_options.initiator, resourceLoaderOpti ons);
881 if (m_options.crossOriginRequestPolicy == AllowCrossOriginRequests) 880 if (m_options.crossOriginRequestPolicy == AllowCrossOriginRequests)
882 newRequest.setOriginRestriction(FetchRequest::NoOriginRestriction); 881 newRequest.setOriginRestriction(FetchRequest::NoOriginRestriction);
883 ASSERT(!resource()); 882 ASSERT(!resource());
884 883
885 WeakPtr<DocumentThreadableLoader> self(m_weakFactory.createWeakPtr()); 884 WeakPtr<RawResourceClient> self(createWeakPtr());
886 885
887 if (request.requestContext() == WebURLRequest::RequestContextVideo || re quest.requestContext() == WebURLRequest::RequestContextAudio) 886 if (request.requestContext() == WebURLRequest::RequestContextVideo || re quest.requestContext() == WebURLRequest::RequestContextAudio)
888 setResource(RawResource::fetchMedia(newRequest, document().fetcher() )); 887 setResource(RawResource::fetchMedia(newRequest, document().fetcher() ));
889 else if (request.requestContext() == WebURLRequest::RequestContextManife st) 888 else if (request.requestContext() == WebURLRequest::RequestContextManife st)
890 setResource(RawResource::fetchManifest(newRequest, document().fetche r())); 889 setResource(RawResource::fetchManifest(newRequest, document().fetche r()));
891 else 890 else
892 setResource(RawResource::fetch(newRequest, document().fetcher())); 891 setResource(RawResource::fetch(newRequest, document().fetcher()));
893 892
894 // setResource() might call notifyFinished() synchronously, and thus 893 // setResource() might call notifyFinished() synchronously, and thus
895 // clear() might be called and |this| may be dead here. 894 // clear() might be called and |this| may be dead here.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 return m_securityOrigin ? m_securityOrigin.get() : document().getSecurityOri gin(); 990 return m_securityOrigin ? m_securityOrigin.get() : document().getSecurityOri gin();
992 } 991 }
993 992
994 Document& DocumentThreadableLoader::document() const 993 Document& DocumentThreadableLoader::document() const
995 { 994 {
996 ASSERT(m_document); 995 ASSERT(m_document);
997 return *m_document; 996 return *m_document;
998 } 997 }
999 998
1000 } // namespace blink 999 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/DocumentThreadableLoader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698