OLD | NEW |
---|---|
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, const TextPosition& initiatorPos ition, const String& resourceURL, const KURL& baseURL, Resource::Type resourceTy pe, |
46 const FetchRequest::ResourceWidth& resourceWidth, const ClientHintsPrefe rences& clientHintsPreferences) | |
Mike West
2015/05/05 15:22:36
Nit: This is somewhat strange line-breaking.
| |
45 : m_initiatorName(initiatorName) | 47 : m_initiatorName(initiatorName) |
46 , m_initiatorPosition(initiatorPosition) | 48 , m_initiatorPosition(initiatorPosition) |
47 , m_resourceURL(resourceURL.isolatedCopy()) | 49 , m_resourceURL(resourceURL.isolatedCopy()) |
48 , m_baseURL(baseURL.copy()) | 50 , m_baseURL(baseURL.copy()) |
49 , m_resourceType(resourceType) | 51 , m_resourceType(resourceType) |
50 , m_isCORSEnabled(false) | 52 , m_isCORSEnabled(false) |
51 , m_allowCredentials(DoNotAllowStoredCredentials) | 53 , m_allowCredentials(DoNotAllowStoredCredentials) |
52 , m_discoveryTime(monotonicallyIncreasingTime()) | 54 , m_discoveryTime(monotonicallyIncreasingTime()) |
53 , m_defer(FetchRequest::NoDefer) | 55 , m_defer(FetchRequest::NoDefer) |
54 , m_resourceWidth(resourceWidth) | 56 , m_resourceWidth(resourceWidth) |
57 , m_clientHintsPreferences(clientHintsPreferences) | |
55 { | 58 { |
56 } | 59 } |
57 | 60 |
58 KURL completeURL(Document*); | 61 KURL completeURL(Document*); |
59 | 62 |
60 String m_initiatorName; | 63 String m_initiatorName; |
61 TextPosition m_initiatorPosition; | 64 TextPosition m_initiatorPosition; |
62 String m_resourceURL; | 65 String m_resourceURL; |
63 KURL m_baseURL; | 66 KURL m_baseURL; |
64 String m_charset; | 67 String m_charset; |
65 Resource::Type m_resourceType; | 68 Resource::Type m_resourceType; |
66 bool m_isCORSEnabled; | 69 bool m_isCORSEnabled; |
67 StoredCredentials m_allowCredentials; | 70 StoredCredentials m_allowCredentials; |
68 double m_discoveryTime; | 71 double m_discoveryTime; |
69 FetchRequest::DeferOption m_defer; | 72 FetchRequest::DeferOption m_defer; |
70 FetchRequest::ResourceWidth m_resourceWidth; | 73 FetchRequest::ResourceWidth m_resourceWidth; |
74 ClientHintsPreferences m_clientHintsPreferences; | |
71 }; | 75 }; |
72 | 76 |
73 typedef Vector<OwnPtr<PreloadRequest>> PreloadRequestStream; | 77 typedef Vector<OwnPtr<PreloadRequest>> PreloadRequestStream; |
74 | 78 |
75 } | 79 } |
76 | 80 |
77 #endif | 81 #endif |
OLD | NEW |