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

Side by Side Diff: third_party/WebKit/Source/core/fetch/FetchRequest.h

Issue 2584423002: Loading: move core/fetch to platform/loader/fetch (Closed)
Patch Set: another try Created 3 years, 10 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
(Empty)
1 /*
2 * Copyright (C) 2012 Google, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #ifndef FetchRequest_h
27 #define FetchRequest_h
28
29 #include "core/CoreExport.h"
30 #include "core/fetch/ClientHintsPreferences.h"
31 #include "core/fetch/FetchInitiatorInfo.h"
32 #include "core/fetch/IntegrityMetadata.h"
33 #include "core/fetch/ResourceLoaderOptions.h"
34 #include "platform/CrossOriginAttributeValue.h"
35 #include "platform/network/ResourceRequest.h"
36 #include "wtf/Allocator.h"
37 #include "wtf/text/AtomicString.h"
38
39 namespace blink {
40 class SecurityOrigin;
41
42 // A FetchRequest is a "parameter object" for ResourceFetcher::requestResource
43 // to avoid the method having too many arguments.
44 class CORE_EXPORT FetchRequest {
45 STACK_ALLOCATED();
46
47 public:
48 enum DeferOption { NoDefer, LazyLoad, IdleLoad };
49 enum OriginRestriction {
50 UseDefaultOriginRestrictionForType,
51 RestrictToSameOrigin,
52 NoOriginRestriction
53 };
54 enum PlaceholderImageRequestType {
55 DisallowPlaceholder = 0, // The requested image must not be a placeholder.
56 AllowPlaceholder, // The image is allowed to be a placeholder.
57 };
58 // TODO(toyoshim): Consider to define an enum for preload options, and use it
59 // instead of bool in this class, FrameFetchContext, and so on. If it is
60 // reasonable, we try merging m_forPreload and m_linkPreload into one enum
61 // type. See https://crbug.com/675883.
62
63 struct ResourceWidth {
64 DISALLOW_NEW();
65 float width;
66 bool isSet;
67
68 ResourceWidth() : width(0), isSet(false) {}
69 };
70
71 FetchRequest(const ResourceRequest&,
72 const AtomicString& initiator,
73 const String& charset = String());
74 FetchRequest(const ResourceRequest&,
75 const AtomicString& initiator,
76 const ResourceLoaderOptions&);
77 FetchRequest(const ResourceRequest&, const FetchInitiatorInfo&);
78 ~FetchRequest();
79
80 ResourceRequest& mutableResourceRequest() { return m_resourceRequest; }
81 const ResourceRequest& resourceRequest() const { return m_resourceRequest; }
82 const KURL& url() const { return m_resourceRequest.url(); }
83
84 const String& charset() const { return m_charset; }
85 void setCharset(const String& charset) { m_charset = charset; }
86
87 const ResourceLoaderOptions& options() const { return m_options; }
88
89 DeferOption defer() const { return m_defer; }
90 void setDefer(DeferOption defer) { m_defer = defer; }
91
92 ResourceWidth getResourceWidth() const { return m_resourceWidth; }
93 void setResourceWidth(ResourceWidth);
94
95 ClientHintsPreferences& clientHintsPreferences() {
96 return m_clientHintPreferences;
97 }
98
99 bool forPreload() const { return m_forPreload; }
100 void setForPreload(bool forPreload, double discoveryTime = 0);
101
102 double preloadDiscoveryTime() { return m_preloadDiscoveryTime; }
103
104 bool isLinkPreload() { return m_linkPreload; }
105 void setLinkPreload(bool isLinkPreload) { m_linkPreload = isLinkPreload; }
106
107 void setContentSecurityCheck(
108 ContentSecurityPolicyDisposition contentSecurityPolicyOption) {
109 m_options.contentSecurityPolicyOption = contentSecurityPolicyOption;
110 }
111 void setCrossOriginAccessControl(SecurityOrigin*, CrossOriginAttributeValue);
112 OriginRestriction getOriginRestriction() const { return m_originRestriction; }
113 void setOriginRestriction(OriginRestriction restriction) {
114 m_originRestriction = restriction;
115 }
116 const IntegrityMetadataSet integrityMetadata() const {
117 return m_options.integrityMetadata;
118 }
119 void setIntegrityMetadata(const IntegrityMetadataSet& metadata) {
120 m_options.integrityMetadata = metadata;
121 }
122
123 String contentSecurityPolicyNonce() const {
124 return m_options.contentSecurityPolicyNonce;
125 }
126 void setContentSecurityPolicyNonce(const String& nonce) {
127 m_options.contentSecurityPolicyNonce = nonce;
128 }
129
130 void setParserDisposition(ParserDisposition parserDisposition) {
131 m_options.parserDisposition = parserDisposition;
132 }
133
134 void setCacheAwareLoadingEnabled(
135 CacheAwareLoadingEnabled cacheAwareLoadingEnabled) {
136 m_options.cacheAwareLoadingEnabled = cacheAwareLoadingEnabled;
137 }
138
139 void makeSynchronous();
140
141 PlaceholderImageRequestType placeholderImageRequestType() const {
142 return m_placeholderImageRequestType;
143 }
144
145 // Configures the request to load an image placeholder if the request is
146 // eligible (e.g. the url's protocol is HTTP, etc.). If this request is
147 // non-eligible, this method doesn't modify the ResourceRequest. Calling this
148 // method sets m_placeholderImageRequestType to the appropriate value.
149 void setAllowImagePlaceholder();
150
151 private:
152 ResourceRequest m_resourceRequest;
153 String m_charset;
154 ResourceLoaderOptions m_options;
155 bool m_forPreload;
156 bool m_linkPreload;
157 double m_preloadDiscoveryTime;
158 DeferOption m_defer;
159 OriginRestriction m_originRestriction;
160 ResourceWidth m_resourceWidth;
161 ClientHintsPreferences m_clientHintPreferences;
162 PlaceholderImageRequestType m_placeholderImageRequestType;
163 };
164
165 } // namespace blink
166
167 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/FetchInitiatorTypeNames.in ('k') | third_party/WebKit/Source/core/fetch/FetchRequest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698