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

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

Issue 2572373003: Loading: pass minimum information to Resource::resourceTypeToString() (Closed)
Patch Set: review #9 #11 Created 4 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 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
7 rights reserved. 7 rights reserved.
8 8
9 This library is free software; you can redistribute it and/or 9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public 10 modify it under the terms of the GNU Library General Public
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "public/platform/WebCachePolicy.h" 45 #include "public/platform/WebCachePolicy.h"
46 #include "public/platform/WebScheduler.h" 46 #include "public/platform/WebScheduler.h"
47 #include "public/platform/WebSecurityOrigin.h" 47 #include "public/platform/WebSecurityOrigin.h"
48 #include "wtf/CurrentTime.h" 48 #include "wtf/CurrentTime.h"
49 #include "wtf/MathExtras.h" 49 #include "wtf/MathExtras.h"
50 #include "wtf/StdLibExtras.h" 50 #include "wtf/StdLibExtras.h"
51 #include "wtf/Vector.h" 51 #include "wtf/Vector.h"
52 #include "wtf/text/CString.h" 52 #include "wtf/text/CString.h"
53 #include "wtf/text/StringBuilder.h" 53 #include "wtf/text/StringBuilder.h"
54 #include <algorithm> 54 #include <algorithm>
55 #include <cassert>
55 #include <memory> 56 #include <memory>
56 #include <stdint.h> 57 #include <stdint.h>
57 58
58 namespace blink { 59 namespace blink {
59 60
60 // These response headers are not copied from a revalidated response to the 61 // These response headers are not copied from a revalidated response to the
61 // cached response headers. For compatibility, this list is based on Chromium's 62 // cached response headers. For compatibility, this list is based on Chromium's
62 // net/http/http_response_headers.cc. 63 // net/http/http_response_headers.cc.
63 const char* const headersToIgnoreAfterRevalidation[] = { 64 const char* const headersToIgnoreAfterRevalidation[] = {
64 "allow", 65 "allow",
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 WebMemoryAllocatorDump* overheadDump = 920 WebMemoryAllocatorDump* overheadDump =
920 memoryDump->createMemoryAllocatorDump(overheadName); 921 memoryDump->createMemoryAllocatorDump(overheadName);
921 overheadDump->addScalar("size", "bytes", overheadSize()); 922 overheadDump->addScalar("size", "bytes", overheadSize());
922 memoryDump->addSuballocation( 923 memoryDump->addSuballocation(
923 overheadDump->guid(), String(WTF::Partitions::kAllocatedObjectPoolName)); 924 overheadDump->guid(), String(WTF::Partitions::kAllocatedObjectPoolName));
924 } 925 }
925 926
926 String Resource::getMemoryDumpName() const { 927 String Resource::getMemoryDumpName() const {
927 return String::format( 928 return String::format(
928 "web_cache/%s_resources/%ld", 929 "web_cache/%s_resources/%ld",
929 resourceTypeToString(getType(), options().initiatorInfo), m_identifier); 930 resourceTypeToString(getType(), options().initiatorInfo.name),
931 m_identifier);
930 } 932 }
931 933
932 void Resource::setCachePolicyBypassingCache() { 934 void Resource::setCachePolicyBypassingCache() {
933 m_resourceRequest.setCachePolicy(WebCachePolicy::BypassingCache); 935 m_resourceRequest.setCachePolicy(WebCachePolicy::BypassingCache);
934 } 936 }
935 937
936 void Resource::setLoFiStateOff() { 938 void Resource::setLoFiStateOff() {
937 m_resourceRequest.setLoFiState(WebURLRequest::LoFiOff); 939 m_resourceRequest.setLoFiState(WebURLRequest::LoFiOff);
938 } 940 }
939 941
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 m_resourceRequest.url().getString().length() * 2; 1023 m_resourceRequest.url().getString().length() * 2;
1022 } 1024 }
1023 1025
1024 void Resource::didChangePriority(ResourceLoadPriority loadPriority, 1026 void Resource::didChangePriority(ResourceLoadPriority loadPriority,
1025 int intraPriorityValue) { 1027 int intraPriorityValue) {
1026 m_resourceRequest.setPriority(loadPriority, intraPriorityValue); 1028 m_resourceRequest.setPriority(loadPriority, intraPriorityValue);
1027 if (m_loader) 1029 if (m_loader)
1028 m_loader->didChangePriority(loadPriority, intraPriorityValue); 1030 m_loader->didChangePriority(loadPriority, intraPriorityValue);
1029 } 1031 }
1030 1032
1031 static const char* initatorTypeNameToString( 1033 // TODO(toyoshim): Consider to generate automatically. https://crbug.com/675515.
1034 static const char* initiatorTypeNameToString(
1032 const AtomicString& initiatorTypeName) { 1035 const AtomicString& initiatorTypeName) {
1033 if (initiatorTypeName == FetchInitiatorTypeNames::css) 1036 if (initiatorTypeName == FetchInitiatorTypeNames::css)
1034 return "CSS resource"; 1037 return "CSS resource";
1035 if (initiatorTypeName == FetchInitiatorTypeNames::document) 1038 if (initiatorTypeName == FetchInitiatorTypeNames::document)
1036 return "Document"; 1039 return "Document";
1037 if (initiatorTypeName == FetchInitiatorTypeNames::icon) 1040 if (initiatorTypeName == FetchInitiatorTypeNames::icon)
1038 return "Icon"; 1041 return "Icon";
1039 if (initiatorTypeName == FetchInitiatorTypeNames::internal) 1042 if (initiatorTypeName == FetchInitiatorTypeNames::internal)
1040 return "Internal resource"; 1043 return "Internal resource";
1041 if (initiatorTypeName == FetchInitiatorTypeNames::link) 1044 if (initiatorTypeName == FetchInitiatorTypeNames::link)
1042 return "Link element resource"; 1045 return "Link element resource";
1043 if (initiatorTypeName == FetchInitiatorTypeNames::processinginstruction) 1046 if (initiatorTypeName == FetchInitiatorTypeNames::processinginstruction)
1044 return "Processing instruction"; 1047 return "Processing instruction";
1045 if (initiatorTypeName == FetchInitiatorTypeNames::texttrack) 1048 if (initiatorTypeName == FetchInitiatorTypeNames::texttrack)
1046 return "Text track"; 1049 return "Text track";
1047 if (initiatorTypeName == FetchInitiatorTypeNames::xml) 1050 if (initiatorTypeName == FetchInitiatorTypeNames::xml)
1048 return "XML resource"; 1051 return "XML resource";
1049 if (initiatorTypeName == FetchInitiatorTypeNames::xmlhttprequest) 1052 if (initiatorTypeName == FetchInitiatorTypeNames::xmlhttprequest)
1050 return "XMLHttpRequest"; 1053 return "XMLHttpRequest";
1051 1054
1055 static_assert(
1056 FetchInitiatorTypeNames::FetchInitiatorTypeNamesCount == 12,
1057 "New FetchInitiatorTypeNames should be handled correctly here.");
1058
1052 return "Resource"; 1059 return "Resource";
1053 } 1060 }
1054 1061
1055 const char* Resource::resourceTypeToString( 1062 const char* Resource::resourceTypeToString(
1056 Type type, 1063 Type type,
1057 const FetchInitiatorInfo& initiatorInfo) { 1064 const AtomicString& fetchInitiatorName) {
1058 switch (type) { 1065 switch (type) {
1059 case Resource::MainResource: 1066 case Resource::MainResource:
1060 return "Main resource"; 1067 return "Main resource";
1061 case Resource::Image: 1068 case Resource::Image:
1062 return "Image"; 1069 return "Image";
1063 case Resource::CSSStyleSheet: 1070 case Resource::CSSStyleSheet:
1064 return "CSS stylesheet"; 1071 return "CSS stylesheet";
1065 case Resource::Script: 1072 case Resource::Script:
1066 return "Script"; 1073 return "Script";
1067 case Resource::Font: 1074 case Resource::Font:
1068 return "Font"; 1075 return "Font";
1069 case Resource::Raw: 1076 case Resource::Raw:
1070 return initatorTypeNameToString(initiatorInfo.name); 1077 return initiatorTypeNameToString(fetchInitiatorName);
1071 case Resource::SVGDocument: 1078 case Resource::SVGDocument:
1072 return "SVG document"; 1079 return "SVG document";
1073 case Resource::XSLStyleSheet: 1080 case Resource::XSLStyleSheet:
1074 return "XSL stylesheet"; 1081 return "XSL stylesheet";
1075 case Resource::LinkPrefetch: 1082 case Resource::LinkPrefetch:
1076 return "Link prefetch resource"; 1083 return "Link prefetch resource";
1077 case Resource::TextTrack: 1084 case Resource::TextTrack:
1078 return "Text track"; 1085 return "Text track";
1079 case Resource::ImportResource: 1086 case Resource::ImportResource:
1080 return "Imported resource"; 1087 return "Imported resource";
1081 case Resource::Media: 1088 case Resource::Media:
1082 return "Media"; 1089 return "Media";
1083 case Resource::Manifest: 1090 case Resource::Manifest:
1084 return "Manifest"; 1091 return "Manifest";
1085 case Resource::Mock: 1092 case Resource::Mock:
1086 return "Mock"; 1093 return "Mock";
1087 } 1094 }
1088 NOTREACHED(); 1095 NOTREACHED();
1089 return initatorTypeNameToString(initiatorInfo.name); 1096 return initiatorTypeNameToString(fetchInitiatorName);
1090 } 1097 }
1091 1098
1092 bool Resource::shouldBlockLoadEvent() const { 1099 bool Resource::shouldBlockLoadEvent() const {
1093 return !m_linkPreload && isLoadEventBlockingResourceType(); 1100 return !m_linkPreload && isLoadEventBlockingResourceType();
1094 } 1101 }
1095 1102
1096 bool Resource::isLoadEventBlockingResourceType() const { 1103 bool Resource::isLoadEventBlockingResourceType() const {
1097 switch (m_type) { 1104 switch (m_type) {
1098 case Resource::MainResource: 1105 case Resource::MainResource:
1099 case Resource::Image: 1106 case Resource::Image:
(...skipping 10 matching lines...) Expand all
1110 case Resource::Media: 1117 case Resource::Media:
1111 case Resource::Manifest: 1118 case Resource::Manifest:
1112 case Resource::Mock: 1119 case Resource::Mock:
1113 return false; 1120 return false;
1114 } 1121 }
1115 NOTREACHED(); 1122 NOTREACHED();
1116 return false; 1123 return false;
1117 } 1124 }
1118 1125
1119 } // namespace blink 1126 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/Resource.h ('k') | third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698