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

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

Issue 1807323002: [WeakMemoryCache 1a] Make Reference from Inspector to Resource weak, remove removedFromMemoryCache() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 , m_decodedSize(0) 220 , m_decodedSize(0)
221 , m_overheadSize(calculateOverheadSize()) 221 , m_overheadSize(calculateOverheadSize())
222 , m_preloadCount(0) 222 , m_preloadCount(0)
223 , m_cacheIdentifier(MemoryCache::defaultCacheIdentifier()) 223 , m_cacheIdentifier(MemoryCache::defaultCacheIdentifier())
224 , m_preloadResult(PreloadNotReferenced) 224 , m_preloadResult(PreloadNotReferenced)
225 , m_type(type) 225 , m_type(type)
226 , m_status(NotStarted) 226 , m_status(NotStarted)
227 , m_needsSynchronousCacheHit(false) 227 , m_needsSynchronousCacheHit(false)
228 , m_linkPreload(false) 228 , m_linkPreload(false)
229 { 229 {
230 ThreadState::current()->registerPreFinalizer(this);
231
230 ASSERT(m_type == unsigned(type)); // m_type is a bitfield, so this tests car eless updates of the enum. 232 ASSERT(m_type == unsigned(type)); // m_type is a bitfield, so this tests car eless updates of the enum.
231 InstanceCounters::incrementCounter(InstanceCounters::ResourceCounter); 233 InstanceCounters::incrementCounter(InstanceCounters::ResourceCounter);
232 234
233 // Currently we support the metadata caching only for HTTP family. 235 // Currently we support the metadata caching only for HTTP family.
234 if (m_resourceRequest.url().protocolIsInHTTPFamily()) 236 if (m_resourceRequest.url().protocolIsInHTTPFamily())
235 m_cacheHandler = CacheHandler::create(this); 237 m_cacheHandler = CacheHandler::create(this);
236 } 238 }
237 239
238 Resource::~Resource() 240 Resource::~Resource()
239 { 241 {
240 InstanceCounters::decrementCounter(InstanceCounters::ResourceCounter); 242 InstanceCounters::decrementCounter(InstanceCounters::ResourceCounter);
241 } 243 }
242 244
243 void Resource::removedFromMemoryCache() 245 void Resource::willDestroyResource()
244 { 246 {
245 InspectorInstrumentation::removedResourceFromMemoryCache(this); 247 InspectorInstrumentation::willDestroyResource(this);
dgozman 2016/04/26 23:58:50 Can we have a weak callback in WeakMember instead?
hiroshige 2016/04/28 08:06:33 using global collection in InspectorInstrumentatio
dgozman 2016/04/28 15:17:26 Nevermind. Go ahead with this patch, I will post a
248 willDestroyResourceInternal();
246 } 249 }
247 250
248 DEFINE_TRACE(Resource) 251 DEFINE_TRACE(Resource)
249 { 252 {
250 visitor->trace(m_loader); 253 visitor->trace(m_loader);
251 visitor->trace(m_cacheHandler); 254 visitor->trace(m_cacheHandler);
252 } 255 }
253 256
254 void Resource::load(ResourceFetcher* fetcher) 257 void Resource::load(ResourceFetcher* fetcher)
255 { 258 {
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 case Resource::Media: 1078 case Resource::Media:
1076 return "Media"; 1079 return "Media";
1077 case Resource::Manifest: 1080 case Resource::Manifest:
1078 return "Manifest"; 1081 return "Manifest";
1079 } 1082 }
1080 ASSERT_NOT_REACHED(); 1083 ASSERT_NOT_REACHED();
1081 return "Unknown"; 1084 return "Unknown";
1082 } 1085 }
1083 1086
1084 } // namespace blink 1087 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698