Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Intel Corporation. All rights reserved. | |
|
jamesr
2013/04/17 17:51:05
are we doing this?
abarth-chromium
2013/04/18 05:34:09
In general, yes.
| |
| 3 * | 4 * |
| 4 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 6 * met: | 7 * met: |
| 7 * | 8 * |
| 8 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 11 * * Redistributions in binary form must reproduce the above |
| 11 * copyright notice, this list of conditions and the following disclaimer | 12 * copyright notice, this list of conditions and the following disclaimer |
| 12 * in the documentation and/or other materials provided with the | 13 * in the documentation and/or other materials provided with the |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 | 52 |
| 52 namespace WebCore { | 53 namespace WebCore { |
| 53 | 54 |
| 54 // ResourceHandleInternal ----------------------------------------------------- | 55 // ResourceHandleInternal ----------------------------------------------------- |
| 55 ResourceHandleInternal::ResourceHandleInternal(NetworkingContext* context, const ResourceRequest& request, ResourceHandleClient* client) | 56 ResourceHandleInternal::ResourceHandleInternal(NetworkingContext* context, const ResourceRequest& request, ResourceHandleClient* client) |
| 56 : m_context(context) | 57 : m_context(context) |
| 57 , m_request(request) | 58 , m_request(request) |
| 58 , m_owner(0) | 59 , m_owner(0) |
| 59 , m_client(client) | 60 , m_client(client) |
| 60 , m_state(ConnectionStateNew) | 61 , m_state(ConnectionStateNew) |
| 62 , m_timer(this, &ResourceHandleInternal::timerFired) | |
| 61 { | 63 { |
| 62 } | 64 } |
| 63 | 65 |
| 64 void ResourceHandleInternal::start() | 66 void ResourceHandleInternal::start() |
| 65 { | 67 { |
| 66 if (m_state != ConnectionStateNew) | 68 if (m_state != ConnectionStateNew) |
| 67 CRASH(); | 69 CRASH(); |
| 68 m_state = ConnectionStateStarted; | 70 m_state = ConnectionStateStarted; |
| 69 | 71 |
| 70 m_loader = adoptPtr(Platform::current()->createURLLoader()); | 72 m_loader = adoptPtr(Platform::current()->createURLLoader()); |
| 71 ASSERT(m_loader); | 73 ASSERT(m_loader); |
| 72 | 74 |
| 73 WrappedResourceRequest wrappedRequest(m_request); | 75 WrappedResourceRequest wrappedRequest(m_request); |
| 74 wrappedRequest.setAllowStoredCredentials(allowStoredCredentials()); | 76 wrappedRequest.setAllowStoredCredentials(allowStoredCredentials()); |
| 75 m_loader->loadAsynchronously(wrappedRequest, this); | 77 m_loader->loadAsynchronously(wrappedRequest, this); |
| 78 | |
| 79 if (m_request.timeoutInterval() > 0) | |
| 80 m_timer.startOneShot(m_request.timeoutInterval()); | |
| 76 } | 81 } |
| 77 | 82 |
| 78 void ResourceHandleInternal::cancel() | 83 void ResourceHandleInternal::cancel() |
| 79 { | 84 { |
| 80 m_state = ConnectionStateCanceled; | 85 m_state = ConnectionStateCanceled; |
| 81 m_loader->cancel(); | 86 m_loader->cancel(); |
| 82 | 87 |
| 83 // Do not make any further calls to the client. | 88 // Do not make any further calls to the client. |
| 84 m_client = 0; | 89 m_client = 0; |
| 85 } | 90 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 ASSERT(m_client); | 175 ASSERT(m_client); |
| 171 m_state = ConnectionStateFailed; | 176 m_state = ConnectionStateFailed; |
| 172 m_client->didFail(m_owner, error); | 177 m_client->didFail(m_owner, error); |
| 173 } | 178 } |
| 174 | 179 |
| 175 ResourceHandleInternal* ResourceHandleInternal::FromResourceHandle(ResourceHandl e* handle) | 180 ResourceHandleInternal* ResourceHandleInternal::FromResourceHandle(ResourceHandl e* handle) |
| 176 { | 181 { |
| 177 return handle->d.get(); | 182 return handle->d.get(); |
| 178 } | 183 } |
| 179 | 184 |
| 185 void ResourceHandleInternal::timerFired(Timer<ResourceHandleInternal>*) | |
| 186 { | |
| 187 // Use the same value as in NSURLError.h | |
| 188 static const int timeoutError = -1001; | |
|
darin (slow to review)
2013/04/16 19:03:45
Hmm, the network layer can also generate net::ERR_
Dominik Röttsches
2013/04/17 08:26:52
Yes, the way I read the spec, the ontimeout event
| |
| 189 static const char* const errorDomain = "WebKitNetworkError"; | |
| 190 | |
| 191 m_state = ConnectionStateCanceled; | |
| 192 m_loader->cancel(); | |
| 193 if (m_client) { | |
| 194 ResourceError error(errorDomain, timeoutError, m_request.url().string(), String()); | |
| 195 error.setIsTimeout(true); | |
| 196 m_client->didFail(m_owner, error); | |
| 197 } | |
| 198 } | |
| 199 | |
| 180 // ResourceHandle ------------------------------------------------------------- | 200 // ResourceHandle ------------------------------------------------------------- |
| 181 | 201 |
| 182 ResourceHandle::ResourceHandle(NetworkingContext* context, const ResourceRequest & request, ResourceHandleClient* client, bool defersLoading, bool shouldContentS niff) | 202 ResourceHandle::ResourceHandle(NetworkingContext* context, const ResourceRequest & request, ResourceHandleClient* client, bool defersLoading, bool shouldContentS niff) |
| 183 : d(adoptPtr(new ResourceHandleInternal(context, request, client))) | 203 : d(adoptPtr(new ResourceHandleInternal(context, request, client))) |
| 184 { | 204 { |
| 185 d->setOwner(this); | 205 d->setOwner(this); |
| 186 | 206 |
| 187 // FIXME: Figure out what to do with the bool params. | 207 // FIXME: Figure out what to do with the bool params. |
| 188 } | 208 } |
| 189 | 209 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 d->didChangePriority(static_cast<WebURLRequest::Priority>(newPriority)); | 295 d->didChangePriority(static_cast<WebURLRequest::Priority>(newPriority)); |
| 276 } | 296 } |
| 277 | 297 |
| 278 // static | 298 // static |
| 279 void ResourceHandle::cacheMetadata(const ResourceResponse& response, const Vecto r<char>& data) | 299 void ResourceHandle::cacheMetadata(const ResourceResponse& response, const Vecto r<char>& data) |
| 280 { | 300 { |
| 281 WebKit::Platform::current()->cacheMetadata(response.url(), response.response Time(), data.data(), data.size()); | 301 WebKit::Platform::current()->cacheMetadata(response.url(), response.response Time(), data.data(), data.size()); |
| 282 } | 302 } |
| 283 | 303 |
| 284 } // namespace WebCore | 304 } // namespace WebCore |
| OLD | NEW |