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

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

Issue 2390583002: [WIP] WebFonts cache-aware timeout adaption (Closed)
Patch Set: Created 4 years, 2 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 m_preloadCount(0), 305 m_preloadCount(0),
306 m_preloadDiscoveryTime(0.0), 306 m_preloadDiscoveryTime(0.0),
307 m_cacheIdentifier(MemoryCache::defaultCacheIdentifier()), 307 m_cacheIdentifier(MemoryCache::defaultCacheIdentifier()),
308 m_preloadResult(PreloadNotReferenced), 308 m_preloadResult(PreloadNotReferenced),
309 m_type(type), 309 m_type(type),
310 m_status(NotStarted), 310 m_status(NotStarted),
311 m_needsSynchronousCacheHit(false), 311 m_needsSynchronousCacheHit(false),
312 m_linkPreload(false), 312 m_linkPreload(false),
313 m_isRevalidating(false), 313 m_isRevalidating(false),
314 m_isAlive(false), 314 m_isAlive(false),
315 m_isAddClientProhibited(false),
315 m_options(options), 316 m_options(options),
316 m_responseTimestamp(currentTime()), 317 m_responseTimestamp(currentTime()),
317 m_cancelTimer(this, &Resource::cancelTimerFired), 318 m_cancelTimer(this, &Resource::cancelTimerFired),
318 m_resourceRequest(request) { 319 m_resourceRequest(request) {
319 DCHECK_EQ( 320 DCHECK_EQ(
320 m_type, 321 m_type,
321 unsigned( 322 unsigned(
322 type)); // m_type is a bitfield, so this tests careless updates of th e enum. 323 type)); // m_type is a bitfield, so this tests careless updates of th e enum.
323 InstanceCounters::incrementCounter(InstanceCounters::ResourceCounter); 324 InstanceCounters::incrementCounter(InstanceCounters::ResourceCounter);
324 325
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 } 680 }
680 } 681 }
681 if (!hasClientsOrObservers()) { 682 if (!hasClientsOrObservers()) {
682 m_isAlive = true; 683 m_isAlive = true;
683 memoryCache()->makeLive(this); 684 memoryCache()->makeLive(this);
684 } 685 }
685 } 686 }
686 687
687 void Resource::addClient(ResourceClient* client, 688 void Resource::addClient(ResourceClient* client,
688 PreloadReferencePolicy policy) { 689 PreloadReferencePolicy policy) {
690 DCHECK(!m_isAddClientProhibited);
691
689 willAddClientOrObserver(policy); 692 willAddClientOrObserver(policy);
690 693
691 if (m_isRevalidating) { 694 if (m_isRevalidating) {
692 m_clients.add(client); 695 m_clients.add(client);
693 return; 696 return;
694 } 697 }
695 698
696 // If we have existing data to send to the new client and the resource type su pprts it, send it asynchronously. 699 // If we have existing data to send to the new client and the resource type su pprts it, send it asynchronously.
697 if (!m_response.isNull() && 700 if (!m_response.isNull() &&
698 !shouldSendCachedDataSynchronouslyForType(getType()) && 701 !shouldSendCachedDataSynchronouslyForType(getType()) &&
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 case Resource::LinkPrefetch: 1070 case Resource::LinkPrefetch:
1068 case Resource::TextTrack: 1071 case Resource::TextTrack:
1069 case Resource::Media: 1072 case Resource::Media:
1070 case Resource::Manifest: 1073 case Resource::Manifest:
1071 return false; 1074 return false;
1072 } 1075 }
1073 NOTREACHED(); 1076 NOTREACHED();
1074 return false; 1077 return false;
1075 } 1078 }
1076 1079
1080 void Resource::willReloadAfterDiskCacheMiss() {
1081 m_resourceRequest.deactivateCacheAwareLoading();
yhirano 2016/10/04 05:27:10 DCHECK(!m_isAddClientProhibited);
Shao-Chuan Lee 2016/10/04 09:08:04 Done.
1082
1083 m_isAddClientProhibited = true;
kouhei (in TOK) 2016/10/03 08:11:47 AutoReset https://cs.chromium.org/chromium/src/thi
Shao-Chuan Lee 2016/10/04 01:39:46 I made this a bit-field like other fields in Resou
hiroshige 2016/10/05 08:27:10 Probably we can make a normal bool and use AutoRes
Shao-Chuan Lee 2016/10/07 08:10:06 Now we have ProhibitAddRemoveClientInScope.
kouhei (in TOK) 2016/10/20 10:43:07 You are right. You may want to introduce your own
1084 ResourceClientWalker<ResourceClient> w(m_clients);
1085 while (ResourceClient* c = w.next()) {
1086 c->willReloadAfterDiskCacheMiss(this);
1087 }
1088 m_isAddClientProhibited = false;
1089 }
1090
1077 } // namespace blink 1091 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698