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

Side by Side Diff: Source/core/fetch/ResourceFetcher.cpp

Issue 133013006: Schedule GC of document resources when loading data URLs (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 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
« no previous file with comments | « Source/core/fetch/ResourceFetcher.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ 6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 287 }
288 288
289 void ResourceFetcher::preCacheDataURIImage(const FetchRequest& request) 289 void ResourceFetcher::preCacheDataURIImage(const FetchRequest& request)
290 { 290 {
291 const KURL& url = request.resourceRequest().url(); 291 const KURL& url = request.resourceRequest().url();
292 ASSERT(url.protocolIsData()); 292 ASSERT(url.protocolIsData());
293 293
294 if (memoryCache()->resourceForURL(url)) 294 if (memoryCache()->resourceForURL(url))
295 return; 295 return;
296 296
297 if (Resource* resource = resourceFromDataURIRequest(request.resourceRequest( ), request.options())) 297 if (Resource* resource = resourceFromDataURIRequest(request.resourceRequest( ), request.options())) {
298 memoryCache()->add(resource); 298 memoryCache()->add(resource);
299 scheduleDocumentResourcesGC();
300 }
299 } 301 }
300 302
301 ResourcePtr<FontResource> ResourceFetcher::fetchFont(FetchRequest& request) 303 ResourcePtr<FontResource> ResourceFetcher::fetchFont(FetchRequest& request)
302 { 304 {
303 return toFontResource(requestResource(Resource::Font, request)); 305 return toFontResource(requestResource(Resource::Font, request));
304 } 306 }
305 307
306 ResourcePtr<ShaderResource> ResourceFetcher::fetchShader(FetchRequest& request) 308 ResourcePtr<ShaderResource> ResourceFetcher::fetchShader(FetchRequest& request)
307 { 309 {
308 return toShaderResource(requestResource(Resource::Shader, request)); 310 return toShaderResource(requestResource(Resource::Shader, request));
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 if (it != m_resourceTimingInfoMap.end()) { 1003 if (it != m_resourceTimingInfoMap.end()) {
1002 RefPtr<ResourceTimingInfo> info = it->value; 1004 RefPtr<ResourceTimingInfo> info = it->value;
1003 m_resourceTimingInfoMap.remove(it); 1005 m_resourceTimingInfoMap.remove(it);
1004 reportResourceTiming(info.get(), resource, resource->loadFinishTime( ), document(), false); 1006 reportResourceTiming(info.get(), resource, resource->loadFinishTime( ), document(), false);
1005 } 1007 }
1006 } 1008 }
1007 1009
1008 if (frame()) 1010 if (frame())
1009 frame()->loader().loadDone(); 1011 frame()->loader().loadDone();
1010 performPostLoadActions(); 1012 performPostLoadActions();
1013 scheduleDocumentResourcesGC();
1014 }
1011 1015
1016 void ResourceFetcher::scheduleDocumentResourcesGC()
1017 {
1012 if (!m_garbageCollectDocumentResourcesTimer.isActive()) 1018 if (!m_garbageCollectDocumentResourcesTimer.isActive())
1013 m_garbageCollectDocumentResourcesTimer.startOneShot(0); 1019 m_garbageCollectDocumentResourcesTimer.startOneShot(0);
1014 } 1020 }
1015 1021
1016 // Garbage collecting m_documentResources is a workaround for the 1022 // Garbage collecting m_documentResources is a workaround for the
1017 // ResourcePtrs on the RHS being strong references. Ideally this 1023 // ResourcePtrs on the RHS being strong references. Ideally this
1018 // would be a weak map, however ResourcePtrs perform additional 1024 // would be a weak map, however ResourcePtrs perform additional
1019 // bookkeeping on Resources, so instead pseudo-GC them -- when the 1025 // bookkeeping on Resources, so instead pseudo-GC them -- when the
1020 // reference count reaches 1, m_documentResources is the only reference, so 1026 // reference count reaches 1, m_documentResources is the only reference, so
1021 // remove it from the map. 1027 // remove it from the map.
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 } 1347 }
1342 #endif 1348 #endif
1343 1349
1344 const ResourceLoaderOptions& ResourceFetcher::defaultResourceOptions() 1350 const ResourceLoaderOptions& ResourceFetcher::defaultResourceOptions()
1345 { 1351 {
1346 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, options, (SniffContent, BufferDat a, AllowStoredCredentials, ClientRequestedCredentials, AskClientForCrossOriginCr edentials, DoSecurityCheck, CheckContentSecurityPolicy, DocumentContext)); 1352 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, options, (SniffContent, BufferDat a, AllowStoredCredentials, ClientRequestedCredentials, AskClientForCrossOriginCr edentials, DoSecurityCheck, CheckContentSecurityPolicy, DocumentContext));
1347 return options; 1353 return options;
1348 } 1354 }
1349 1355
1350 } 1356 }
OLDNEW
« no previous file with comments | « Source/core/fetch/ResourceFetcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698