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

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

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

Powered by Google App Engine
This is Rietveld 408576698