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

Side by Side Diff: third_party/WebKit/Source/core/html/parser/PreloadRequest.h

Issue 2808663003: Explicitly tell the preload request where to take the referrer from (Closed)
Patch Set: comment Created 3 years, 8 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef PreloadRequest_h 5 #ifndef PreloadRequest_h
6 #define PreloadRequest_h 6 #define PreloadRequest_h
7 7
8 #include <memory> 8 #include <memory>
9 #include "core/CoreExport.h" 9 #include "core/CoreExport.h"
10 #include "platform/CrossOriginAttributeValue.h" 10 #include "platform/CrossOriginAttributeValue.h"
(...skipping 13 matching lines...) Expand all
24 class CORE_EXPORT PreloadRequest { 24 class CORE_EXPORT PreloadRequest {
25 USING_FAST_MALLOC(PreloadRequest); 25 USING_FAST_MALLOC(PreloadRequest);
26 26
27 public: 27 public:
28 enum RequestType { 28 enum RequestType {
29 kRequestTypePreload, 29 kRequestTypePreload,
30 kRequestTypePreconnect, 30 kRequestTypePreconnect,
31 kRequestTypeLinkRelPreload 31 kRequestTypeLinkRelPreload
32 }; 32 };
33 33
34 enum ReferrerSource { kDocumentIsReferrer, kBaseUrlIsReferrer };
35
34 // TODO(csharrison): Move the implementation to the cpp file when core/html 36 // TODO(csharrison): Move the implementation to the cpp file when core/html
35 // gets its own testing source set in html/BUILD.gn. 37 // gets its own testing source set in html/BUILD.gn.
36 static std::unique_ptr<PreloadRequest> CreateIfNeeded( 38 static std::unique_ptr<PreloadRequest> CreateIfNeeded(
37 const String& initiator_name, 39 const String& initiator_name,
38 const TextPosition& initiator_position, 40 const TextPosition& initiator_position,
39 const String& resource_url, 41 const String& resource_url,
40 const KURL& base_url, 42 const KURL& base_url,
41 Resource::Type resource_type, 43 Resource::Type resource_type,
42 const ReferrerPolicy referrer_policy, 44 const ReferrerPolicy referrer_policy,
45 ReferrerSource referrer_source,
43 const FetchRequest::ResourceWidth& resource_width = 46 const FetchRequest::ResourceWidth& resource_width =
44 FetchRequest::ResourceWidth(), 47 FetchRequest::ResourceWidth(),
45 const ClientHintsPreferences& client_hints_preferences = 48 const ClientHintsPreferences& client_hints_preferences =
46 ClientHintsPreferences(), 49 ClientHintsPreferences(),
47 RequestType request_type = kRequestTypePreload) { 50 RequestType request_type = kRequestTypePreload) {
48 // Never preload data URLs. We also disallow relative ref URLs which become 51 // Never preload data URLs. We also disallow relative ref URLs which become
49 // data URLs if the document's URL is a data URL. We don't want to create 52 // data URLs if the document's URL is a data URL. We don't want to create
50 // extra resource requests with data URLs to avoid copy / initialization 53 // extra resource requests with data URLs to avoid copy / initialization
51 // overhead, which can be significant for large URLs. 54 // overhead, which can be significant for large URLs.
52 if (resource_url.IsEmpty() || resource_url.StartsWith("#") || 55 if (resource_url.IsEmpty() || resource_url.StartsWith("#") ||
53 ProtocolIs(resource_url, "data")) { 56 ProtocolIs(resource_url, "data")) {
54 return nullptr; 57 return nullptr;
55 } 58 }
56 return WTF::WrapUnique(new PreloadRequest( 59 return WTF::WrapUnique(new PreloadRequest(
57 initiator_name, initiator_position, resource_url, base_url, 60 initiator_name, initiator_position, resource_url, base_url,
58 resource_type, resource_width, client_hints_preferences, request_type, 61 resource_type, resource_width, client_hints_preferences, request_type,
59 referrer_policy)); 62 referrer_policy, referrer_source));
60 } 63 }
61 64
62 bool IsSafeToSendToAnotherThread() const; 65 bool IsSafeToSendToAnotherThread() const;
63 66
64 Resource* Start(Document*); 67 Resource* Start(Document*);
65 68
66 double DiscoveryTime() const { return discovery_time_; } 69 double DiscoveryTime() const { return discovery_time_; }
67 void SetDefer(FetchRequest::DeferOption defer) { defer_ = defer; } 70 void SetDefer(FetchRequest::DeferOption defer) { defer_ = defer; }
68 void SetCharset(const String& charset) { charset_ = charset.IsolatedCopy(); } 71 void SetCharset(const String& charset) { charset_ = charset.IsolatedCopy(); }
69 void SetCrossOrigin(CrossOriginAttributeValue cross_origin) { 72 void SetCrossOrigin(CrossOriginAttributeValue cross_origin) {
(...skipping 28 matching lines...) Expand all
98 101
99 private: 102 private:
100 PreloadRequest(const String& initiator_name, 103 PreloadRequest(const String& initiator_name,
101 const TextPosition& initiator_position, 104 const TextPosition& initiator_position,
102 const String& resource_url, 105 const String& resource_url,
103 const KURL& base_url, 106 const KURL& base_url,
104 Resource::Type resource_type, 107 Resource::Type resource_type,
105 const FetchRequest::ResourceWidth& resource_width, 108 const FetchRequest::ResourceWidth& resource_width,
106 const ClientHintsPreferences& client_hints_preferences, 109 const ClientHintsPreferences& client_hints_preferences,
107 RequestType request_type, 110 RequestType request_type,
108 const ReferrerPolicy referrer_policy) 111 const ReferrerPolicy referrer_policy,
112 ReferrerSource referrer_source)
109 : initiator_name_(initiator_name), 113 : initiator_name_(initiator_name),
110 initiator_position_(initiator_position), 114 initiator_position_(initiator_position),
111 resource_url_(resource_url.IsolatedCopy()), 115 resource_url_(resource_url.IsolatedCopy()),
112 base_url_(base_url.Copy()), 116 base_url_(base_url.Copy()),
113 resource_type_(resource_type), 117 resource_type_(resource_type),
114 cross_origin_(kCrossOriginAttributeNotSet), 118 cross_origin_(kCrossOriginAttributeNotSet),
115 discovery_time_(MonotonicallyIncreasingTime()), 119 discovery_time_(MonotonicallyIncreasingTime()),
116 defer_(FetchRequest::kNoDefer), 120 defer_(FetchRequest::kNoDefer),
117 resource_width_(resource_width), 121 resource_width_(resource_width),
118 client_hints_preferences_(client_hints_preferences), 122 client_hints_preferences_(client_hints_preferences),
119 request_type_(request_type), 123 request_type_(request_type),
120 referrer_policy_(referrer_policy) {} 124 referrer_policy_(referrer_policy),
125 referrer_source_(referrer_source) {}
121 126
122 KURL CompleteURL(Document*); 127 KURL CompleteURL(Document*);
123 128
124 String initiator_name_; 129 String initiator_name_;
125 TextPosition initiator_position_; 130 TextPosition initiator_position_;
126 String resource_url_; 131 String resource_url_;
127 KURL base_url_; 132 KURL base_url_;
128 String charset_; 133 String charset_;
129 Resource::Type resource_type_; 134 Resource::Type resource_type_;
130 CrossOriginAttributeValue cross_origin_; 135 CrossOriginAttributeValue cross_origin_;
131 String nonce_; 136 String nonce_;
132 double discovery_time_; 137 double discovery_time_;
133 FetchRequest::DeferOption defer_; 138 FetchRequest::DeferOption defer_;
134 FetchRequest::ResourceWidth resource_width_; 139 FetchRequest::ResourceWidth resource_width_;
135 ClientHintsPreferences client_hints_preferences_; 140 ClientHintsPreferences client_hints_preferences_;
136 RequestType request_type_; 141 RequestType request_type_;
137 ReferrerPolicy referrer_policy_; 142 ReferrerPolicy referrer_policy_;
143 ReferrerSource referrer_source_;
138 IntegrityMetadataSet integrity_metadata_; 144 IntegrityMetadataSet integrity_metadata_;
139 }; 145 };
140 146
141 typedef Vector<std::unique_ptr<PreloadRequest>> PreloadRequestStream; 147 typedef Vector<std::unique_ptr<PreloadRequest>> PreloadRequestStream;
142 148
143 } // namespace blink 149 } // namespace blink
144 150
145 #endif 151 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698