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

Side by Side Diff: sky/engine/platform/network/ResourceRequest.cpp

Issue 1239633002: Remove //sky/engine/platform/network (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: rebase Created 5 years, 5 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) 2003, 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) 2009, 2012 Google Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27 #include "sky/engine/platform/network/ResourceRequest.h"
28 #include "sky/engine/public/platform/WebURLRequest.h"
29
30 namespace blink {
31
32 double ResourceRequest::s_defaultTimeoutInterval = INT_MAX;
33
34 bool ResourceRequest::isEmpty() const
35 {
36 return m_url.isEmpty();
37 }
38
39 bool ResourceRequest::isNull() const
40 {
41 return m_url.isNull();
42 }
43
44 const KURL& ResourceRequest::url() const
45 {
46 return m_url;
47 }
48
49 void ResourceRequest::setURL(const KURL& url)
50 {
51 m_url = url;
52 }
53
54 void ResourceRequest::removeCredentials()
55 {
56 if (m_url.user().isEmpty() && m_url.pass().isEmpty())
57 return;
58
59 m_url.setUser(String());
60 m_url.setPass(String());
61 }
62
63 ResourceRequestCachePolicy ResourceRequest::cachePolicy() const
64 {
65 return m_cachePolicy;
66 }
67
68 void ResourceRequest::setCachePolicy(ResourceRequestCachePolicy cachePolicy)
69 {
70 m_cachePolicy = cachePolicy;
71 }
72
73 double ResourceRequest::timeoutInterval() const
74 {
75 return m_timeoutInterval;
76 }
77
78 void ResourceRequest::setTimeoutInterval(double timeoutInterval)
79 {
80 m_timeoutInterval = timeoutInterval;
81 }
82
83 const AtomicString& ResourceRequest::httpMethod() const
84 {
85 return m_httpMethod;
86 }
87
88 void ResourceRequest::setHTTPMethod(const AtomicString& httpMethod)
89 {
90 m_httpMethod = httpMethod;
91 }
92
93 const HTTPHeaderMap& ResourceRequest::httpHeaderFields() const
94 {
95 return m_httpHeaderFields;
96 }
97
98 const AtomicString& ResourceRequest::httpHeaderField(const AtomicString& name) c onst
99 {
100 return m_httpHeaderFields.get(name);
101 }
102
103 const AtomicString& ResourceRequest::httpHeaderField(const char* name) const
104 {
105 return m_httpHeaderFields.get(name);
106 }
107
108 void ResourceRequest::setHTTPHeaderField(const AtomicString& name, const AtomicS tring& value)
109 {
110 m_httpHeaderFields.set(name, value);
111 }
112
113 void ResourceRequest::setHTTPHeaderField(const char* name, const AtomicString& v alue)
114 {
115 setHTTPHeaderField(AtomicString(name), value);
116 }
117
118 void ResourceRequest::clearHTTPAuthorization()
119 {
120 m_httpHeaderFields.remove("Authorization");
121 }
122
123 void ResourceRequest::clearHTTPReferrer()
124 {
125 m_httpHeaderFields.remove("Referer");
126 m_referrerPolicy = ReferrerPolicyDefault;
127 }
128
129 void ResourceRequest::clearHTTPOrigin()
130 {
131 m_httpHeaderFields.remove("Origin");
132 }
133
134 void ResourceRequest::addHTTPOriginIfNeeded(const AtomicString& origin)
135 {
136 // FIXME(sky): Remove
137 }
138
139 FormData* ResourceRequest::httpBody() const
140 {
141 return m_httpBody.get();
142 }
143
144 void ResourceRequest::setHTTPBody(PassRefPtr<FormData> httpBody)
145 {
146 m_httpBody = httpBody;
147 }
148
149 bool ResourceRequest::allowStoredCredentials() const
150 {
151 return m_allowStoredCredentials;
152 }
153
154 void ResourceRequest::setAllowStoredCredentials(bool allowCredentials)
155 {
156 m_allowStoredCredentials = allowCredentials;
157 }
158
159 ResourceLoadPriority ResourceRequest::priority() const
160 {
161 return m_priority;
162 }
163
164 void ResourceRequest::setPriority(ResourceLoadPriority priority, int intraPriori tyValue)
165 {
166 m_priority = priority;
167 m_intraPriorityValue = intraPriorityValue;
168 }
169
170 void ResourceRequest::addHTTPHeaderField(const AtomicString& name, const AtomicS tring& value)
171 {
172 HTTPHeaderMap::AddResult result = m_httpHeaderFields.add(name, value);
173 if (!result.isNewEntry)
174 result.storedValue->value = result.storedValue->value + ',' + value;
175 }
176
177 void ResourceRequest::addHTTPHeaderFields(const HTTPHeaderMap& headerFields)
178 {
179 HTTPHeaderMap::const_iterator end = headerFields.end();
180 for (HTTPHeaderMap::const_iterator it = headerFields.begin(); it != end; ++i t)
181 addHTTPHeaderField(it->key, it->value);
182 }
183
184 void ResourceRequest::clearHTTPHeaderField(const AtomicString& name)
185 {
186 m_httpHeaderFields.remove(name);
187 }
188
189 bool equalIgnoringHeaderFields(const ResourceRequest& a, const ResourceRequest& b)
190 {
191 if (a.url() != b.url())
192 return false;
193
194 if (a.cachePolicy() != b.cachePolicy())
195 return false;
196
197 if (a.timeoutInterval() != b.timeoutInterval())
198 return false;
199
200 if (a.httpMethod() != b.httpMethod())
201 return false;
202
203 if (a.allowStoredCredentials() != b.allowStoredCredentials())
204 return false;
205
206 if (a.priority() != b.priority())
207 return false;
208
209 if (a.referrerPolicy() != b.referrerPolicy())
210 return false;
211
212 FormData* formDataA = a.httpBody();
213 FormData* formDataB = b.httpBody();
214
215 if (!formDataA)
216 return !formDataB;
217 if (!formDataB)
218 return !formDataA;
219
220 if (*formDataA != *formDataB)
221 return false;
222
223 return true;
224 }
225
226 bool ResourceRequest::compare(const ResourceRequest& a, const ResourceRequest& b )
227 {
228 if (!equalIgnoringHeaderFields(a, b))
229 return false;
230
231 if (a.httpHeaderFields() != b.httpHeaderFields())
232 return false;
233
234 return true;
235 }
236
237 bool ResourceRequest::isConditional() const
238 {
239 return (m_httpHeaderFields.contains("If-Match")
240 || m_httpHeaderFields.contains("If-Modified-Since")
241 || m_httpHeaderFields.contains("If-None-Match")
242 || m_httpHeaderFields.contains("If-Range")
243 || m_httpHeaderFields.contains("If-Unmodified-Since"));
244 }
245
246
247 static const AtomicString& cacheControlHeaderString()
248 {
249 DEFINE_STATIC_LOCAL(const AtomicString, cacheControlHeader, ("cache-control" , AtomicString::ConstructFromLiteral));
250 return cacheControlHeader;
251 }
252
253 static const AtomicString& pragmaHeaderString()
254 {
255 DEFINE_STATIC_LOCAL(const AtomicString, pragmaHeader, ("pragma", AtomicStrin g::ConstructFromLiteral));
256 return pragmaHeader;
257 }
258
259 const CacheControlHeader& ResourceRequest::cacheControlHeader() const
260 {
261 if (!m_cacheControlHeaderCache.parsed)
262 m_cacheControlHeaderCache = parseCacheControlDirectives(m_httpHeaderFiel ds.get(cacheControlHeaderString()), m_httpHeaderFields.get(pragmaHeaderString()) );
263 return m_cacheControlHeaderCache;
264 }
265
266 bool ResourceRequest::cacheControlContainsNoCache() const
267 {
268 return cacheControlHeader().containsNoCache;
269 }
270
271 bool ResourceRequest::cacheControlContainsNoStore() const
272 {
273 return cacheControlHeader().containsNoStore;
274 }
275
276 bool ResourceRequest::hasCacheValidatorFields() const
277 {
278 DEFINE_STATIC_LOCAL(const AtomicString, lastModifiedHeader, ("last-modified" , AtomicString::ConstructFromLiteral));
279 DEFINE_STATIC_LOCAL(const AtomicString, eTagHeader, ("etag", AtomicString::C onstructFromLiteral));
280 return !m_httpHeaderFields.get(lastModifiedHeader).isEmpty() || !m_httpHeade rFields.get(eTagHeader).isEmpty();
281 }
282
283 double ResourceRequest::defaultTimeoutInterval()
284 {
285 return s_defaultTimeoutInterval;
286 }
287
288 void ResourceRequest::setDefaultTimeoutInterval(double timeoutInterval)
289 {
290 s_defaultTimeoutInterval = timeoutInterval;
291 }
292
293 void ResourceRequest::initialize(const KURL& url, ResourceRequestCachePolicy cac hePolicy)
294 {
295 m_url = url;
296 m_cachePolicy = cachePolicy;
297 m_timeoutInterval = s_defaultTimeoutInterval;
298 m_httpMethod = "GET";
299 m_allowStoredCredentials = true;
300 m_reportUploadProgress = false;
301 m_reportRawHeaders = false;
302 m_downloadToFile = false;
303 m_priority = ResourceLoadPriorityLow;
304 m_intraPriorityValue = 0;
305 m_requestorID = 0;
306 m_requestorProcessID = 0;
307 m_requestContext = blink::WebURLRequest::RequestContextUnspecified;
308 m_frameType = blink::WebURLRequest::FrameTypeNone;
309 m_referrerPolicy = ReferrerPolicyDefault;
310 }
311
312 }
OLDNEW
« no previous file with comments | « sky/engine/platform/network/ResourceRequest.h ('k') | sky/engine/platform/network/ResourceResponse.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698