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

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

Issue 1152043005: Add <link rel=preconnect> support to the HTMLPreloadScanner (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added HTTP family test Created 5 years, 6 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/html/parser/HTMLResourcePreloader.cpp ('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 // 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 "core/fetch/ClientHintsPreferences.h" 8 #include "core/fetch/ClientHintsPreferences.h"
9 #include "core/fetch/FetchRequest.h" 9 #include "core/fetch/FetchRequest.h"
10 #include "core/fetch/Resource.h" 10 #include "core/fetch/Resource.h"
11 #include "wtf/text/TextPosition.h" 11 #include "wtf/text/TextPosition.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 class Document; 15 class Document;
16 16
17 class PreloadRequest { 17 class PreloadRequest {
18 public: 18 public:
19 static PassOwnPtr<PreloadRequest> create(const String& initiatorName, const TextPosition& initiatorPosition, const String& resourceURL, const KURL& baseURL, Resource::Type resourceType, const FetchRequest::ResourceWidth& resourceWidth = FetchRequest::ResourceWidth(), const ClientHintsPreferences& clientHintsPrefere nces = ClientHintsPreferences()) 19 enum RequestType { RequestTypePreload, RequestTypePreconnect };
20
21 static PassOwnPtr<PreloadRequest> create(const String& initiatorName, const TextPosition& initiatorPosition, const String& resourceURL, const KURL& baseURL, Resource::Type resourceType, const FetchRequest::ResourceWidth& resourceWidth = FetchRequest::ResourceWidth(), const ClientHintsPreferences& clientHintsPrefere nces = ClientHintsPreferences(), RequestType requestType = RequestTypePreload)
20 { 22 {
21 return adoptPtr(new PreloadRequest(initiatorName, initiatorPosition, res ourceURL, baseURL, resourceType, resourceWidth, clientHintsPreferences)); 23 return adoptPtr(new PreloadRequest(initiatorName, initiatorPosition, res ourceURL, baseURL, resourceType, resourceWidth, clientHintsPreferences, requestT ype));
22 } 24 }
23 25
24 bool isSafeToSendToAnotherThread() const; 26 bool isSafeToSendToAnotherThread() const;
25 27
26 FetchRequest resourceRequest(Document*); 28 FetchRequest resourceRequest(Document*);
27 29
28 const String& charset() const { return m_charset; } 30 const String& charset() const { return m_charset; }
29 double discoveryTime() const { return m_discoveryTime; } 31 double discoveryTime() const { return m_discoveryTime; }
30 void setDefer(FetchRequest::DeferOption defer) { m_defer = defer; } 32 void setDefer(FetchRequest::DeferOption defer) { m_defer = defer; }
31 void setCharset(const String& charset) { m_charset = charset.isolatedCopy(); } 33 void setCharset(const String& charset) { m_charset = charset.isolatedCopy(); }
32 void setCrossOriginEnabled(StoredCredentials allowCredentials) 34 void setCrossOriginEnabled(StoredCredentials allowCredentials)
33 { 35 {
34 m_isCORSEnabled = true; 36 m_isCORSEnabled = true;
35 m_allowCredentials = allowCredentials; 37 m_allowCredentials = allowCredentials;
36 } 38 }
37 39
38 Resource::Type resourceType() const { return m_resourceType; } 40 Resource::Type resourceType() const { return m_resourceType; }
39 41
40 const String& resourceURL() const { return m_resourceURL; } 42 const String& resourceURL() const { return m_resourceURL; }
41 float resourceWidth() const { return m_resourceWidth.isSet ? m_resourceWidth .width : 0; } 43 float resourceWidth() const { return m_resourceWidth.isSet ? m_resourceWidth .width : 0; }
42 const String& baseURL() const { return m_baseURL.string(); } 44 const KURL& baseURL() const { return m_baseURL; }
45 bool isPreconnect() const { return m_requestType == RequestTypePreconnect; }
46 bool isCORS() const { return m_isCORSEnabled; }
47 bool isAllowCredentials() const { return m_allowCredentials == AllowStoredCr edentials; }
43 48
44 private: 49 private:
45 PreloadRequest(const String& initiatorName, 50 PreloadRequest(const String& initiatorName,
46 const TextPosition& initiatorPosition, 51 const TextPosition& initiatorPosition,
47 const String& resourceURL, 52 const String& resourceURL,
48 const KURL& baseURL, 53 const KURL& baseURL,
49 Resource::Type resourceType, 54 Resource::Type resourceType,
50 const FetchRequest::ResourceWidth& resourceWidth, 55 const FetchRequest::ResourceWidth& resourceWidth,
51 const ClientHintsPreferences& clientHintsPreferences) 56 const ClientHintsPreferences& clientHintsPreferences,
57 RequestType requestType)
52 : m_initiatorName(initiatorName) 58 : m_initiatorName(initiatorName)
53 , m_initiatorPosition(initiatorPosition) 59 , m_initiatorPosition(initiatorPosition)
54 , m_resourceURL(resourceURL.isolatedCopy()) 60 , m_resourceURL(resourceURL.isolatedCopy())
55 , m_baseURL(baseURL.copy()) 61 , m_baseURL(baseURL.copy())
56 , m_resourceType(resourceType) 62 , m_resourceType(resourceType)
57 , m_isCORSEnabled(false) 63 , m_isCORSEnabled(false)
58 , m_allowCredentials(DoNotAllowStoredCredentials) 64 , m_allowCredentials(DoNotAllowStoredCredentials)
59 , m_discoveryTime(monotonicallyIncreasingTime()) 65 , m_discoveryTime(monotonicallyIncreasingTime())
60 , m_defer(FetchRequest::NoDefer) 66 , m_defer(FetchRequest::NoDefer)
61 , m_resourceWidth(resourceWidth) 67 , m_resourceWidth(resourceWidth)
62 , m_clientHintsPreferences(clientHintsPreferences) 68 , m_clientHintsPreferences(clientHintsPreferences)
69 , m_requestType(requestType)
63 { 70 {
64 } 71 }
65 72
66 KURL completeURL(Document*); 73 KURL completeURL(Document*);
67 74
68 String m_initiatorName; 75 String m_initiatorName;
69 TextPosition m_initiatorPosition; 76 TextPosition m_initiatorPosition;
70 String m_resourceURL; 77 String m_resourceURL;
71 KURL m_baseURL; 78 KURL m_baseURL;
72 String m_charset; 79 String m_charset;
73 Resource::Type m_resourceType; 80 Resource::Type m_resourceType;
74 bool m_isCORSEnabled; 81 bool m_isCORSEnabled;
75 StoredCredentials m_allowCredentials; 82 StoredCredentials m_allowCredentials;
76 double m_discoveryTime; 83 double m_discoveryTime;
77 FetchRequest::DeferOption m_defer; 84 FetchRequest::DeferOption m_defer;
78 FetchRequest::ResourceWidth m_resourceWidth; 85 FetchRequest::ResourceWidth m_resourceWidth;
79 ClientHintsPreferences m_clientHintsPreferences; 86 ClientHintsPreferences m_clientHintsPreferences;
87 RequestType m_requestType;
80 }; 88 };
81 89
82 typedef Vector<OwnPtr<PreloadRequest>> PreloadRequestStream; 90 typedef Vector<OwnPtr<PreloadRequest>> PreloadRequestStream;
83 91
84 } 92 }
85 93
86 #endif 94 #endif
OLDNEW
« no previous file with comments | « Source/core/html/parser/HTMLResourcePreloader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698