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

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

Issue 1378743002: Refactor the API for setting dynamic resource load priorities (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better names / cleanup Created 5 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 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 } 934 }
935 935
936 size_t Resource::overheadSize() const 936 size_t Resource::overheadSize() const
937 { 937 {
938 static const int kAverageClientsHashMapSize = 384; 938 static const int kAverageClientsHashMapSize = 384;
939 return sizeof(Resource) + m_response.memoryUsage() + kAverageClientsHashMapS ize + m_resourceRequest.url().string().length() * 2; 939 return sizeof(Resource) + m_response.memoryUsage() + kAverageClientsHashMapS ize + m_resourceRequest.url().string().length() * 2;
940 } 940 }
941 941
942 void Resource::didChangePriority(ResourceLoadPriority loadPriority, int intraPri orityValue) 942 void Resource::didChangePriority(ResourceLoadPriority loadPriority, int intraPri orityValue)
943 { 943 {
944 m_resourceRequest.setPriority(loadPriority, intraPriorityValue);
944 if (m_loader) 945 if (m_loader)
945 m_loader->didChangePriority(loadPriority, intraPriorityValue); 946 m_loader->didChangePriority(loadPriority, intraPriorityValue);
946 } 947 }
947 948
949 ResourcePriority Resource::priorityFromClients()
950 {
951 ResourcePriority priority;
952 ResourceClientWalker<ResourceClient> walker(m_clients);
953 while (ResourceClient* c = walker.next()) {
954 ResourcePriority nextPriority = c->computeResourcePriority();
955 if (nextPriority.visibility == ResourcePriority::NotVisible)
956 continue;
957 priority.visibility = ResourcePriority::Visible;
958 priority.intraPriorityValue += nextPriority.intraPriorityValue;
959 }
960 return priority;
961 }
962
948 Resource::ResourceCallback* Resource::ResourceCallback::callbackHandler() 963 Resource::ResourceCallback* Resource::ResourceCallback::callbackHandler()
949 { 964 {
950 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<ResourceCallback>, callbackHandle r, (adoptPtrWillBeNoop(new ResourceCallback))); 965 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<ResourceCallback>, callbackHandle r, (adoptPtrWillBeNoop(new ResourceCallback)));
951 return callbackHandler.get(); 966 return callbackHandler.get();
952 } 967 }
953 968
954 DEFINE_TRACE(Resource::ResourceCallback) 969 DEFINE_TRACE(Resource::ResourceCallback)
955 { 970 {
956 #if ENABLE(OILPAN) 971 #if ENABLE(OILPAN)
957 visitor->trace(m_resourcesWithPendingClients); 972 visitor->trace(m_resourcesWithPendingClients);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 return "ImportResource"; 1108 return "ImportResource";
1094 case Resource::Media: 1109 case Resource::Media:
1095 return "Media"; 1110 return "Media";
1096 } 1111 }
1097 ASSERT_NOT_REACHED(); 1112 ASSERT_NOT_REACHED();
1098 return "Unknown"; 1113 return "Unknown";
1099 } 1114 }
1100 #endif // !LOG_DISABLED 1115 #endif // !LOG_DISABLED
1101 1116
1102 } // namespace blink 1117 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/Resource.h ('k') | third_party/WebKit/Source/core/fetch/ResourceClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698