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

Side by Side Diff: Source/core/platform/network/ResourceHandle.cpp

Issue 16140020: Delete NetworkingContext and its subclasses. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/platform/network/ResourceHandle.h" 32 #include "core/platform/network/ResourceHandle.h"
33 33
34 #include "core/platform/chromium/support/WrappedResourceRequest.h" 34 #include "core/platform/chromium/support/WrappedResourceRequest.h"
35 #include "core/platform/chromium/support/WrappedResourceResponse.h" 35 #include "core/platform/chromium/support/WrappedResourceResponse.h"
36 #include "core/platform/network/NetworkingContext.h"
37 #include "core/platform/network/ResourceError.h" 36 #include "core/platform/network/ResourceError.h"
38 #include "core/platform/network/ResourceHandleClient.h" 37 #include "core/platform/network/ResourceHandleClient.h"
39 #include "core/platform/network/ResourceHandleInternal.h" 38 #include "core/platform/network/ResourceHandleInternal.h"
40 #include "core/platform/network/ResourceRequest.h" 39 #include "core/platform/network/ResourceRequest.h"
41 #include "core/platform/network/ResourceResponse.h" 40 #include "core/platform/network/ResourceResponse.h"
42 #include "public/platform/Platform.h" 41 #include "public/platform/Platform.h"
43 #include "public/platform/WebURLError.h" 42 #include "public/platform/WebURLError.h"
44 #include "public/platform/WebURLLoader.h" 43 #include "public/platform/WebURLLoader.h"
45 #include "public/platform/WebURLLoaderClient.h" 44 #include "public/platform/WebURLLoaderClient.h"
46 #include "public/platform/WebURLRequest.h" 45 #include "public/platform/WebURLRequest.h"
47 #include "public/platform/WebURLResponse.h" 46 #include "public/platform/WebURLResponse.h"
48 47
49 using namespace WebKit; 48 using namespace WebKit;
50 49
51 namespace WebCore { 50 namespace WebCore {
52 51
53 // ResourceHandleInternal ----------------------------------------------------- 52 // ResourceHandleInternal -----------------------------------------------------
54 ResourceHandleInternal::ResourceHandleInternal(NetworkingContext* context, const ResourceRequest& request, ResourceHandleClient* client) 53 ResourceHandleInternal::ResourceHandleInternal(const ResourceRequest& request, R esourceHandleClient* client)
55 : m_context(context) 54 : m_request(request)
56 , m_request(request)
57 , m_owner(0) 55 , m_owner(0)
58 , m_client(client) 56 , m_client(client)
59 , m_state(ConnectionStateNew) 57 , m_state(ConnectionStateNew)
60 { 58 {
61 } 59 }
62 60
63 void ResourceHandleInternal::start(StoredCredentials storedCredentials) 61 void ResourceHandleInternal::start(StoredCredentials storedCredentials)
64 { 62 {
65 if (m_state != ConnectionStateNew) 63 if (m_state != ConnectionStateNew)
66 CRASH(); 64 CRASH();
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 m_client->didFail(m_owner, error); 164 m_client->didFail(m_owner, error);
167 } 165 }
168 166
169 ResourceHandleInternal* ResourceHandleInternal::FromResourceHandle(ResourceHandl e* handle) 167 ResourceHandleInternal* ResourceHandleInternal::FromResourceHandle(ResourceHandl e* handle)
170 { 168 {
171 return handle->d.get(); 169 return handle->d.get();
172 } 170 }
173 171
174 // ResourceHandle ------------------------------------------------------------- 172 // ResourceHandle -------------------------------------------------------------
175 173
176 ResourceHandle::ResourceHandle(NetworkingContext* context, const ResourceRequest & request, ResourceHandleClient* client, bool defersLoading, bool shouldContentS niff) 174 ResourceHandle::ResourceHandle(const ResourceRequest& request, ResourceHandleCli ent* client, bool defersLoading, bool shouldContentSniff)
177 : d(adoptPtr(new ResourceHandleInternal(context, request, client))) 175 : d(adoptPtr(new ResourceHandleInternal(request, client)))
178 { 176 {
179 d->setOwner(this); 177 d->setOwner(this);
180 178
181 // FIXME: Figure out what to do with the bool params. 179 // FIXME: Figure out what to do with the bool params.
182 } 180 }
183 181
184 PassRefPtr<ResourceHandle> ResourceHandle::create(NetworkingContext* context, 182 PassRefPtr<ResourceHandle> ResourceHandle::create(const ResourceRequest& request ,
185 const ResourceRequest& request ,
186 ResourceHandleClient* client, 183 ResourceHandleClient* client,
187 bool defersLoading, 184 bool defersLoading,
188 bool shouldContentSniff, 185 bool shouldContentSniff,
189 StoredCredentials storedCreden tials) 186 StoredCredentials storedCreden tials)
190 { 187 {
191 RefPtr<ResourceHandle> newHandle = adoptRef(new ResourceHandle( 188 RefPtr<ResourceHandle> newHandle = adoptRef(new ResourceHandle(request, clie nt, defersLoading, shouldContentSniff));
192 context, request, client, defersLoading, shouldContentSniff));
193 189
194 if (newHandle->start(storedCredentials)) 190 newHandle->start(storedCredentials);
195 return newHandle.release(); 191 return newHandle.release();
196
197 return 0;
198 } 192 }
199 193
200 ResourceRequest& ResourceHandle::firstRequest() 194 ResourceRequest& ResourceHandle::firstRequest()
201 { 195 {
202 return d->request(); 196 return d->request();
203 } 197 }
204 198
205 NetworkingContext* ResourceHandle::context() const
206 {
207 return d->context();
208 }
209
210 ResourceHandleClient* ResourceHandle::client() const 199 ResourceHandleClient* ResourceHandle::client() const
211 { 200 {
212 return d->client(); 201 return d->client();
213 } 202 }
214 203
215 void ResourceHandle::setClient(ResourceHandleClient* client) 204 void ResourceHandle::setClient(ResourceHandleClient* client)
216 { 205 {
217 d->setClient(client); 206 d->setClient(client);
218 } 207 }
219 208
220 void ResourceHandle::setDefersLoading(bool value) 209 void ResourceHandle::setDefersLoading(bool value)
221 { 210 {
222 d->setDefersLoading(value); 211 d->setDefersLoading(value);
223 } 212 }
224 213
225 bool ResourceHandle::start(StoredCredentials storedCredentials) 214 void ResourceHandle::start(StoredCredentials storedCredentials)
226 { 215 {
227 if (!d->context())
228 return false;
abarth-chromium 2013/06/03 21:11:53 This probably allows data URLs in SVG in <img> to
pdr. 2013/06/03 21:34:42 Not quite, but very close.
229
230 d->start(storedCredentials); 216 d->start(storedCredentials);
231 return true;
232 } 217 }
233 218
234 void ResourceHandle::cancel() 219 void ResourceHandle::cancel()
235 { 220 {
236 d->cancel(); 221 d->cancel();
237 } 222 }
238 223
239 ResourceHandle::~ResourceHandle() 224 ResourceHandle::~ResourceHandle()
240 { 225 {
241 d->setOwner(0); 226 d->setOwner(0);
242 } 227 }
243 228
244 // static 229 // static
245 void ResourceHandle::loadResourceSynchronously(NetworkingContext* context, 230 void ResourceHandle::loadResourceSynchronously(const ResourceRequest& request,
246 const ResourceRequest& request,
247 StoredCredentials storedCredentia ls, 231 StoredCredentials storedCredentia ls,
248 ResourceError& error, 232 ResourceError& error,
249 ResourceResponse& response, 233 ResourceResponse& response,
250 Vector<char>& data) 234 Vector<char>& data)
251 { 235 {
252 OwnPtr<WebURLLoader> loader = adoptPtr(Platform::current()->createURLLoader( )); 236 OwnPtr<WebURLLoader> loader = adoptPtr(Platform::current()->createURLLoader( ));
253 ASSERT(loader); 237 ASSERT(loader);
254 238
255 WrappedResourceRequest requestIn(request); 239 WrappedResourceRequest requestIn(request);
256 requestIn.setAllowStoredCredentials(storedCredentials == AllowStoredCredenti als); 240 requestIn.setAllowStoredCredentials(storedCredentials == AllowStoredCredenti als);
(...skipping 13 matching lines...) Expand all
270 d->didChangePriority(static_cast<WebURLRequest::Priority>(newPriority)); 254 d->didChangePriority(static_cast<WebURLRequest::Priority>(newPriority));
271 } 255 }
272 256
273 // static 257 // static
274 void ResourceHandle::cacheMetadata(const ResourceResponse& response, const Vecto r<char>& data) 258 void ResourceHandle::cacheMetadata(const ResourceResponse& response, const Vecto r<char>& data)
275 { 259 {
276 WebKit::Platform::current()->cacheMetadata(response.url(), response.response Time(), data.data(), data.size()); 260 WebKit::Platform::current()->cacheMetadata(response.url(), response.response Time(), data.data(), data.size());
277 } 261 }
278 262
279 } // namespace WebCore 263 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/platform/network/ResourceHandle.h ('k') | Source/core/platform/network/ResourceHandleInternal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698