Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 | 94 |
| 95 Resource::Resource(const ResourceRequest& request, Type type) | 95 Resource::Resource(const ResourceRequest& request, Type type) |
| 96 : m_resourceRequest(request) | 96 : m_resourceRequest(request) |
| 97 , m_responseTimestamp(currentTime()) | 97 , m_responseTimestamp(currentTime()) |
| 98 , m_cancelTimer(this, &Resource::cancelTimerFired) | 98 , m_cancelTimer(this, &Resource::cancelTimerFired) |
| 99 , m_loadFinishTime(0) | 99 , m_loadFinishTime(0) |
| 100 , m_identifier(0) | 100 , m_identifier(0) |
| 101 , m_encodedSize(0) | 101 , m_encodedSize(0) |
| 102 , m_decodedSize(0) | 102 , m_decodedSize(0) |
| 103 , m_handleCount(0) | 103 , m_handleCount(0) |
| 104 , m_preloadCount(0) | |
| 105 , m_protectorCount(0) | 104 , m_protectorCount(0) |
| 106 , m_preloadResult(PreloadNotReferenced) | |
| 107 , m_requestedFromNetworkingLayer(false) | 105 , m_requestedFromNetworkingLayer(false) |
| 108 , m_loading(false) | 106 , m_loading(false) |
| 109 , m_switchingClientsToRevalidatedResource(false) | 107 , m_switchingClientsToRevalidatedResource(false) |
| 110 , m_type(type) | 108 , m_type(type) |
| 111 , m_status(Pending) | 109 , m_status(Pending) |
| 112 , m_wasPurged(false) | 110 , m_wasPurged(false) |
| 113 , m_needsSynchronousCacheHit(false) | 111 , m_needsSynchronousCacheHit(false) |
| 114 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK | 112 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK |
| 115 , m_deleted(false) | 113 , m_deleted(false) |
| 116 #endif | 114 #endif |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 m_options.dataBufferingPolicy = dataBufferingPolicy; | 231 m_options.dataBufferingPolicy = dataBufferingPolicy; |
| 234 m_data.clear(); | 232 m_data.clear(); |
| 235 setEncodedSize(0); | 233 setEncodedSize(0); |
| 236 } | 234 } |
| 237 | 235 |
| 238 void Resource::error(Resource::Status status) | 236 void Resource::error(Resource::Status status) |
| 239 { | 237 { |
| 240 if (m_resourceToRevalidate) | 238 if (m_resourceToRevalidate) |
| 241 revalidationFailed(); | 239 revalidationFailed(); |
| 242 | 240 |
| 243 if (!m_error.isNull() && (m_error.isCancellation() || !isPreloaded())) | 241 if (!m_error.isNull()) |
|
esprehn
2014/11/11 17:52:06
Why don't you need the isCancellation check now?
abarth-chromium
2014/11/11 17:54:15
!isPreloaded() is always true.
| |
| 244 memoryCache()->remove(this); | 242 memoryCache()->remove(this); |
| 245 | 243 |
| 246 setStatus(status); | 244 setStatus(status); |
| 247 ASSERT(errorOccurred()); | 245 ASSERT(errorOccurred()); |
| 248 m_data.clear(); | 246 m_data.clear(); |
| 249 | 247 |
| 250 setLoading(false); | 248 setLoading(false); |
| 251 checkNotify(); | 249 checkNotify(); |
| 252 } | 250 } |
| 253 | 251 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 if (!m_resourceToRevalidate) | 368 if (!m_resourceToRevalidate) |
| 371 return; | 369 return; |
| 372 if (response.httpStatusCode() == 304) | 370 if (response.httpStatusCode() == 304) |
| 373 revalidationSucceeded(response); | 371 revalidationSucceeded(response); |
| 374 else | 372 else |
| 375 revalidationFailed(); | 373 revalidationFailed(); |
| 376 } | 374 } |
| 377 | 375 |
| 378 bool Resource::canDelete() const | 376 bool Resource::canDelete() const |
| 379 { | 377 { |
| 380 return !hasClients() && !m_loader && !m_preloadCount && hasRightHandleCountA partFromCache(0) | 378 return !hasClients() && !m_loader && hasRightHandleCountApartFromCache(0) |
| 381 && !m_protectorCount && !m_resourceToRevalidate && !m_proxyResource; | 379 && !m_protectorCount && !m_resourceToRevalidate && !m_proxyResource; |
| 382 } | 380 } |
| 383 | 381 |
| 384 bool Resource::hasOneHandle() const | 382 bool Resource::hasOneHandle() const |
| 385 { | 383 { |
| 386 return hasRightHandleCountApartFromCache(1); | 384 return hasRightHandleCountApartFromCache(1); |
| 387 } | 385 } |
| 388 | 386 |
| 389 void Resource::clearLoader() | 387 void Resource::clearLoader() |
| 390 { | 388 { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 415 return true; | 413 return true; |
| 416 if (type == Resource::Font) | 414 if (type == Resource::Font) |
| 417 return true; | 415 return true; |
| 418 return false; | 416 return false; |
| 419 } | 417 } |
| 420 | 418 |
| 421 bool Resource::addClientToSet(ResourceClient* client) | 419 bool Resource::addClientToSet(ResourceClient* client) |
| 422 { | 420 { |
| 423 ASSERT(!isPurgeable()); | 421 ASSERT(!isPurgeable()); |
| 424 | 422 |
| 425 if (m_preloadResult == PreloadNotReferenced) { | |
| 426 if (isLoaded()) | |
| 427 m_preloadResult = PreloadReferencedWhileComplete; | |
| 428 else if (m_requestedFromNetworkingLayer) | |
| 429 m_preloadResult = PreloadReferencedWhileLoading; | |
| 430 else | |
| 431 m_preloadResult = PreloadReferenced; | |
| 432 } | |
| 433 if (!hasClients()) | 423 if (!hasClients()) |
| 434 memoryCache()->makeLive(this); | 424 memoryCache()->makeLive(this); |
| 435 | 425 |
| 436 // If we have existing data to send to the new client and the resource type supprts it, send it asynchronously. | 426 // If we have existing data to send to the new client and the resource type supprts it, send it asynchronously. |
| 437 if (!m_response.isNull() && !m_proxyResource && !shouldSendCachedDataSynchro nouslyForType(type()) && !m_needsSynchronousCacheHit) { | 427 if (!m_response.isNull() && !m_proxyResource && !shouldSendCachedDataSynchro nouslyForType(type()) && !m_needsSynchronousCacheHit) { |
| 438 m_clientsAwaitingCallback.add(client); | 428 m_clientsAwaitingCallback.add(client); |
| 439 ResourceCallback::callbackHandler()->schedule(this); | 429 ResourceCallback::callbackHandler()->schedule(this); |
| 440 return false; | 430 return false; |
| 441 } | 431 } |
| 442 | 432 |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 911 return "ImportResource"; | 901 return "ImportResource"; |
| 912 case Resource::Media: | 902 case Resource::Media: |
| 913 return "Media"; | 903 return "Media"; |
| 914 } | 904 } |
| 915 ASSERT_NOT_REACHED(); | 905 ASSERT_NOT_REACHED(); |
| 916 return "Unknown"; | 906 return "Unknown"; |
| 917 } | 907 } |
| 918 #endif // !LOG_DISABLED | 908 #endif // !LOG_DISABLED |
| 919 | 909 |
| 920 } | 910 } |
| OLD | NEW |