Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. |
| 3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com) | 3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com) |
| 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 | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. 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 17 matching lines...) Expand all Loading... | |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 #include "config.h" | 30 #include "config.h" |
| 31 #include "core/loader/ResourceLoader.h" | 31 #include "core/loader/ResourceLoader.h" |
| 32 | 32 |
| 33 #include "core/inspector/InspectorInstrumentation.h" | 33 #include "core/inspector/InspectorInstrumentation.h" |
| 34 #include "core/loader/DocumentLoader.h" | 34 #include "core/loader/DocumentLoader.h" |
| 35 #include "core/loader/FrameLoader.h" | 35 #include "core/loader/FrameLoader.h" |
| 36 #include "core/loader/FrameLoaderClient.h" | 36 #include "core/loader/FrameLoaderClient.h" |
| 37 #include "core/loader/UniqueIdentifier.h" | 37 #include "core/loader/UniqueIdentifier.h" |
| 38 #include "core/loader/appcache/ApplicationCacheHost.h" | |
| 39 #include "core/loader/cache/CachedResourceLoader.h" | 38 #include "core/loader/cache/CachedResourceLoader.h" |
| 40 #include "core/page/Frame.h" | 39 #include "core/page/Frame.h" |
| 41 #include "core/page/Page.h" | 40 #include "core/page/Page.h" |
| 42 #include "core/platform/Logging.h" | 41 #include "core/platform/Logging.h" |
| 43 #include "core/platform/network/ResourceError.h" | 42 #include "core/platform/network/ResourceError.h" |
| 44 #include "core/platform/network/ResourceHandle.h" | 43 #include "core/platform/network/ResourceHandle.h" |
| 45 #include "weborigin/SecurityOrigin.h" | |
| 46 | 44 |
| 47 namespace WebCore { | 45 namespace WebCore { |
| 48 | 46 |
| 49 ResourceLoader::RequestCountTracker::RequestCountTracker(CachedResourceLoader* c achedResourceLoader, CachedResource* resource) | 47 ResourceLoader::RequestCountTracker::RequestCountTracker(CachedResourceLoader* c achedResourceLoader, CachedResource* resource) |
| 50 : m_cachedResourceLoader(cachedResourceLoader) | 48 : m_cachedResourceLoader(cachedResourceLoader) |
| 51 , m_resource(resource) | 49 , m_resource(resource) |
| 52 { | 50 { |
| 53 m_cachedResourceLoader->incrementRequestCount(m_resource); | 51 m_cachedResourceLoader->incrementRequestCount(m_resource); |
| 54 } | 52 } |
| 55 | 53 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 } | 120 } |
| 123 | 121 |
| 124 m_deferredRequest = ResourceRequest(); | 122 m_deferredRequest = ResourceRequest(); |
| 125 } | 123 } |
| 126 | 124 |
| 127 bool ResourceLoader::init(const ResourceRequest& r) | 125 bool ResourceLoader::init(const ResourceRequest& r) |
| 128 { | 126 { |
| 129 ASSERT(!m_handle); | 127 ASSERT(!m_handle); |
| 130 ASSERT(m_request.isNull()); | 128 ASSERT(m_request.isNull()); |
| 131 ASSERT(m_deferredRequest.isNull()); | 129 ASSERT(m_deferredRequest.isNull()); |
| 132 ASSERT(!m_documentLoader->isSubstituteLoadPending(this)); | |
| 133 | 130 |
| 134 ResourceRequest clientRequest(r); | 131 ResourceRequest clientRequest(r); |
| 135 | 132 |
| 136 m_identifier = createUniqueIdentifier(); | 133 m_identifier = createUniqueIdentifier(); |
| 137 willSendRequest(0, clientRequest, ResourceResponse()); | 134 willSendRequest(0, clientRequest, ResourceResponse()); |
| 138 if (clientRequest.isNull()) { | 135 if (clientRequest.isNull()) { |
| 139 cancel(); | 136 cancel(); |
| 140 return false; | 137 return false; |
| 141 } | 138 } |
| 142 ASSERT(m_state != Terminated); | 139 ASSERT(m_state != Terminated); |
| 143 | 140 |
| 144 m_originalRequest = m_request = clientRequest; | 141 m_originalRequest = m_request = clientRequest; |
| 145 m_state = Initialized; | 142 m_state = Initialized; |
| 146 m_documentLoader->addResourceLoader(this); | 143 m_documentLoader->addResourceLoader(this); |
| 147 return true; | 144 return true; |
| 148 } | 145 } |
| 149 | 146 |
| 150 void ResourceLoader::start() | 147 void ResourceLoader::start() |
| 151 { | 148 { |
| 152 ASSERT(!m_handle); | 149 ASSERT(!m_handle); |
| 153 ASSERT(!m_request.isNull()); | 150 ASSERT(!m_request.isNull()); |
| 154 ASSERT(m_deferredRequest.isNull()); | 151 ASSERT(m_deferredRequest.isNull()); |
| 155 | 152 |
| 156 if (m_documentLoader->scheduleArchiveLoad(this, m_request)) | |
| 157 return; | |
| 158 | |
| 159 m_documentLoader->applicationCacheHost()->willStartLoadingResource(m_request ); | |
|
Nate Chapin
2013/05/22 23:28:46
This is the last reference to ApplicationCacheHost
| |
| 160 | |
| 161 if (m_defersLoading) { | 153 if (m_defersLoading) { |
| 162 m_deferredRequest = m_request; | 154 m_deferredRequest = m_request; |
| 163 return; | 155 return; |
| 164 } | 156 } |
| 165 | 157 |
| 166 if (m_state != Terminated) | 158 if (m_state != Terminated) |
| 167 m_handle = ResourceHandle::create(m_frame->loader()->networkingContext() , m_request, this, m_defersLoading, m_options.sniffContent == SniffContent, m_op tions.allowCredentials); | 159 m_handle = ResourceHandle::create(m_frame->loader()->networkingContext() , m_request, this, m_defersLoading, m_options.sniffContent == SniffContent, m_op tions.allowCredentials); |
| 168 } | 160 } |
| 169 | 161 |
| 170 void ResourceLoader::setDefersLoading(bool defers) | 162 void ResourceLoader::setDefersLoading(bool defers) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 // This function calls out to clients at several points that might do | 233 // This function calls out to clients at several points that might do |
| 242 // something that causes the last reference to this object to go away. | 234 // something that causes the last reference to this object to go away. |
| 243 RefPtr<ResourceLoader> protector(this); | 235 RefPtr<ResourceLoader> protector(this); |
| 244 | 236 |
| 245 LOG(ResourceLoading, "Cancelled load of '%s'.\n", m_resource->url().string() .latin1().data()); | 237 LOG(ResourceLoading, "Cancelled load of '%s'.\n", m_resource->url().string() .latin1().data()); |
| 246 m_state = Finishing; | 238 m_state = Finishing; |
| 247 m_resource->setResourceError(nonNullError); | 239 m_resource->setResourceError(nonNullError); |
| 248 if (m_resource->resourceToRevalidate()) | 240 if (m_resource->resourceToRevalidate()) |
| 249 m_resource->revalidationFailed(); | 241 m_resource->revalidationFailed(); |
| 250 | 242 |
| 251 m_documentLoader->cancelPendingSubstituteLoad(this); | |
| 252 if (m_handle) { | 243 if (m_handle) { |
| 253 m_handle->cancel(); | 244 m_handle->cancel(); |
| 254 m_handle = 0; | 245 m_handle = 0; |
| 255 } | 246 } |
| 256 | 247 |
| 257 if (m_options.sendLoadCallbacks == SendCallbacks && m_identifier && !m_notif iedLoadComplete) | 248 if (m_options.sendLoadCallbacks == SendCallbacks && m_identifier && !m_notif iedLoadComplete) |
| 258 frameLoader()->notifier()->didFailToLoad(this, nonNullError); | 249 frameLoader()->notifier()->didFailToLoad(this, nonNullError); |
| 259 | 250 |
| 260 m_resource->error(CachedResource::LoadError); | 251 m_resource->error(CachedResource::LoadError); |
| 261 if (m_state != Terminated) | 252 if (m_state != Terminated) |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 459 info.addMember(m_request, "request"); | 450 info.addMember(m_request, "request"); |
| 460 info.addMember(m_originalRequest, "originalRequest"); | 451 info.addMember(m_originalRequest, "originalRequest"); |
| 461 info.addMember(m_deferredRequest, "deferredRequest"); | 452 info.addMember(m_deferredRequest, "deferredRequest"); |
| 462 info.addMember(m_options, "options"); | 453 info.addMember(m_options, "options"); |
| 463 info.addMember(m_resource, "resource"); | 454 info.addMember(m_resource, "resource"); |
| 464 info.addMember(m_documentLoader, "documentLoader"); | 455 info.addMember(m_documentLoader, "documentLoader"); |
| 465 info.addMember(m_requestCountTracker, "requestCountTracker"); | 456 info.addMember(m_requestCountTracker, "requestCountTracker"); |
| 466 } | 457 } |
| 467 | 458 |
| 468 } | 459 } |
| OLD | NEW |