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

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

Issue 1428383002: Make ResourceFetcher::m_documentResources use WeakPtr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add TODOs Created 5 years 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 26 matching lines...) Expand all
37 #include "platform/Logging.h" 37 #include "platform/Logging.h"
38 #include "platform/SharedBuffer.h" 38 #include "platform/SharedBuffer.h"
39 #include "platform/TraceEvent.h" 39 #include "platform/TraceEvent.h"
40 #include "platform/weborigin/KURL.h" 40 #include "platform/weborigin/KURL.h"
41 #include "public/platform/Platform.h" 41 #include "public/platform/Platform.h"
42 #include "public/platform/WebProcessMemoryDump.h" 42 #include "public/platform/WebProcessMemoryDump.h"
43 #include "wtf/CurrentTime.h" 43 #include "wtf/CurrentTime.h"
44 #include "wtf/MathExtras.h" 44 #include "wtf/MathExtras.h"
45 #include "wtf/StdLibExtras.h" 45 #include "wtf/StdLibExtras.h"
46 #include "wtf/Vector.h" 46 #include "wtf/Vector.h"
47 #include "wtf/WeakPtr.h"
47 #include "wtf/text/CString.h" 48 #include "wtf/text/CString.h"
48 49
49 using namespace WTF; 50 using namespace WTF;
50 51
51 namespace blink { 52 namespace blink {
52 53
53 // These response headers are not copied from a revalidated response to the 54 // These response headers are not copied from a revalidated response to the
54 // cached response headers. For compatibility, this list is based on Chromium's 55 // cached response headers. For compatibility, this list is based on Chromium's
55 // net/http/http_response_headers.cc. 56 // net/http/http_response_headers.cc.
56 const char* const headersToIgnoreAfterRevalidation[] = { 57 const char* const headersToIgnoreAfterRevalidation[] = {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 141
141 String Resource::CacheHandler::encoding() const 142 String Resource::CacheHandler::encoding() const
142 { 143 {
143 return m_resource->encoding(); 144 return m_resource->encoding();
144 } 145 }
145 146
146 Resource::Resource(const ResourceRequest& request, Type type) 147 Resource::Resource(const ResourceRequest& request, Type type)
147 : m_resourceRequest(request) 148 : m_resourceRequest(request)
148 , m_responseTimestamp(currentTime()) 149 , m_responseTimestamp(currentTime())
149 , m_cancelTimer(this, &Resource::cancelTimerFired) 150 , m_cancelTimer(this, &Resource::cancelTimerFired)
151 #if !ENABLE(OILPAN)
152 , m_weakPtrFactory(this)
153 #endif
150 , m_loadFinishTime(0) 154 , m_loadFinishTime(0)
151 , m_identifier(0) 155 , m_identifier(0)
152 , m_encodedSize(0) 156 , m_encodedSize(0)
153 , m_decodedSize(0) 157 , m_decodedSize(0)
154 , m_handleCount(0) 158 , m_handleCount(0)
155 , m_preloadCount(0) 159 , m_preloadCount(0)
156 , m_protectorCount(0) 160 , m_protectorCount(0)
157 , m_cacheIdentifier(MemoryCache::defaultCacheIdentifier()) 161 , m_cacheIdentifier(MemoryCache::defaultCacheIdentifier())
158 , m_preloadResult(PreloadNotReferenced) 162 , m_preloadResult(PreloadNotReferenced)
159 , m_requestedFromNetworkingLayer(false) 163 , m_requestedFromNetworkingLayer(false)
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 } 513 }
510 514
511 void Resource::clearCachedMetadata(CachedMetadataHandler::CacheType cacheType) 515 void Resource::clearCachedMetadata(CachedMetadataHandler::CacheType cacheType)
512 { 516 {
513 m_cachedMetadata.clear(); 517 m_cachedMetadata.clear();
514 518
515 if (cacheType == CachedMetadataHandler::SendToPlatform) 519 if (cacheType == CachedMetadataHandler::SendToPlatform)
516 Platform::current()->cacheMetadata(m_response.url(), m_response.response Time(), 0, 0); 520 Platform::current()->cacheMetadata(m_response.url(), m_response.response Time(), 0, 0);
517 } 521 }
518 522
523 WeakPtrWillBeRawPtr<Resource> Resource::asWeakPtr()
524 {
525 #if ENABLE(OILPAN)
526 return this;
527 #else
528 return m_weakPtrFactory.createWeakPtr();
529 #endif
530 }
531
519 bool Resource::canDelete() const 532 bool Resource::canDelete() const
520 { 533 {
521 return !hasClients() && !m_loader && !m_preloadCount && hasRightHandleCountA partFromCache(0) 534 return !hasClients() && !m_loader && !m_preloadCount && hasRightHandleCountA partFromCache(0)
522 && !m_protectorCount; 535 && !m_protectorCount;
523 } 536 }
524 537
525 String Resource::reasonNotDeletable() const 538 String Resource::reasonNotDeletable() const
526 { 539 {
527 StringBuilder builder; 540 StringBuilder builder;
528 if (hasClients()) { 541 if (hasClients()) {
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 return "ImportResource"; 1172 return "ImportResource";
1160 case Resource::Media: 1173 case Resource::Media:
1161 return "Media"; 1174 return "Media";
1162 } 1175 }
1163 ASSERT_NOT_REACHED(); 1176 ASSERT_NOT_REACHED();
1164 return "Unknown"; 1177 return "Unknown";
1165 } 1178 }
1166 #endif // !LOG_DISABLED 1179 #endif // !LOG_DISABLED
1167 1180
1168 } // namespace blink 1181 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/Resource.h ('k') | third_party/WebKit/Source/core/fetch/ResourceFetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698