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

Side by Side Diff: third_party/WebKit/Source/core/fetch/Resource.cpp

Issue 1889973002: Refactoring starting a resource load (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
OLDNEW
1 /* 1 /*
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
(...skipping 11 matching lines...) Expand all
22 */ 22 */
23 23
24 #include "core/fetch/Resource.h" 24 #include "core/fetch/Resource.h"
25 25
26 #include "core/fetch/CachedMetadata.h" 26 #include "core/fetch/CachedMetadata.h"
27 #include "core/fetch/CrossOriginAccessControl.h" 27 #include "core/fetch/CrossOriginAccessControl.h"
28 #include "core/fetch/FetchInitiatorTypeNames.h" 28 #include "core/fetch/FetchInitiatorTypeNames.h"
29 #include "core/fetch/MemoryCache.h" 29 #include "core/fetch/MemoryCache.h"
30 #include "core/fetch/ResourceClient.h" 30 #include "core/fetch/ResourceClient.h"
31 #include "core/fetch/ResourceClientOrObserverWalker.h" 31 #include "core/fetch/ResourceClientOrObserverWalker.h"
32 #include "core/fetch/ResourceFetcher.h"
33 #include "core/fetch/ResourceLoader.h" 32 #include "core/fetch/ResourceLoader.h"
34 #include "core/inspector/InspectorInstrumentation.h" 33 #include "core/inspector/InspectorInstrumentation.h"
35 #include "core/inspector/InstanceCounters.h" 34 #include "core/inspector/InstanceCounters.h"
36 #include "platform/Logging.h" 35 #include "platform/Logging.h"
37 #include "platform/SharedBuffer.h" 36 #include "platform/SharedBuffer.h"
38 #include "platform/TraceEvent.h" 37 #include "platform/TraceEvent.h"
39 #include "platform/network/HTTPParsers.h" 38 #include "platform/network/HTTPParsers.h"
40 #include "platform/weborigin/KURL.h" 39 #include "platform/weborigin/KURL.h"
41 #include "public/platform/Platform.h" 40 #include "public/platform/Platform.h"
42 #include "public/platform/WebProcessMemoryDump.h" 41 #include "public/platform/WebProcessMemoryDump.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 { 243 {
245 InspectorInstrumentation::removedResourceFromMemoryCache(this); 244 InspectorInstrumentation::removedResourceFromMemoryCache(this);
246 } 245 }
247 246
248 DEFINE_TRACE(Resource) 247 DEFINE_TRACE(Resource)
249 { 248 {
250 visitor->trace(m_loader); 249 visitor->trace(m_loader);
251 visitor->trace(m_cacheHandler); 250 visitor->trace(m_cacheHandler);
252 } 251 }
253 252
254 void Resource::load(ResourceFetcher* fetcher) 253 ResourceRequest& Resource::prepareRequestForLoadStart()
hiroshige 2016/04/21 08:27:40 I'm not sure whether it is good to split load() in
Nate Chapin 2016/05/18 23:56:04 I refactored a bit more to enable this to be just
255 { 254 {
256 // TOOD(japhet): Temporary, out of place hack to stop a top crasher.
257 // Make this more organic.
258 if (!fetcher->loadingTaskRunner())
hiroshige 2016/04/21 08:27:40 Is this check removed? (Or loadingTaskRunner() is
Nate Chapin 2016/05/18 23:56:04 Correct, loadingTaskRunner() being null and should
259 return;
260
261 RELEASE_ASSERT(!m_loader); 255 RELEASE_ASSERT(!m_loader);
262 ASSERT(stillNeedsLoad());
263 m_status = Pending; 256 m_status = Pending;
264 257
265 ResourceRequest& request(m_revalidatingRequest.isNull() ? m_resourceRequest : m_revalidatingRequest); 258 ResourceRequest& request(m_revalidatingRequest.isNull() ? m_resourceRequest : m_revalidatingRequest);
266 KURL url = request.url();
267 request.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredC redentials); 259 request.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredC redentials);
268 260 return request;
269 m_loader = ResourceLoader::create(fetcher, this);
270 m_loader->start(request);
271 // If the request reference is null (i.e., a synchronous revalidation will
272 // null the request), don't make the request non-null by setting the url.
273 if (!request.isNull())
274 request.setURL(url);
275 } 261 }
276 262
277 void Resource::checkNotify() 263 void Resource::checkNotify()
278 { 264 {
279 if (isLoading()) 265 if (isLoading())
280 return; 266 return;
281 267
282 ResourceClientWalker<ResourceClient> w(m_clients); 268 ResourceClientWalker<ResourceClient> w(m_clients);
283 while (ResourceClient* c = w.next()) 269 while (ResourceClient* c = w.next())
284 c->notifyFinished(this); 270 c->notifyFinished(this);
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 case Resource::Media: 1061 case Resource::Media:
1076 return "Media"; 1062 return "Media";
1077 case Resource::Manifest: 1063 case Resource::Manifest:
1078 return "Manifest"; 1064 return "Manifest";
1079 } 1065 }
1080 ASSERT_NOT_REACHED(); 1066 ASSERT_NOT_REACHED();
1081 return "Unknown"; 1067 return "Unknown";
1082 } 1068 }
1083 1069
1084 } // namespace blink 1070 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698