| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010, 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2010, 2011, 2012 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 } | 164 } |
| 165 | 165 |
| 166 AssociatedURLLoader::ClientAdapter::ClientAdapter(AssociatedURLLoader* loader, W
ebURLLoaderClient* client, const WebURLLoaderOptions& options) | 166 AssociatedURLLoader::ClientAdapter::ClientAdapter(AssociatedURLLoader* loader, W
ebURLLoaderClient* client, const WebURLLoaderOptions& options) |
| 167 : m_loader(loader) | 167 : m_loader(loader) |
| 168 , m_client(client) | 168 , m_client(client) |
| 169 , m_options(options) | 169 , m_options(options) |
| 170 , m_errorTimer(this, &ClientAdapter::notifyError) | 170 , m_errorTimer(this, &ClientAdapter::notifyError) |
| 171 , m_enableErrorNotifications(false) | 171 , m_enableErrorNotifications(false) |
| 172 , m_didFail(false) | 172 , m_didFail(false) |
| 173 { | 173 { |
| 174 ASSERT(m_loader); | 174 DCHECK(m_loader); |
| 175 ASSERT(m_client); | 175 DCHECK(m_client); |
| 176 } | 176 } |
| 177 | 177 |
| 178 void AssociatedURLLoader::ClientAdapter::willFollowRedirect(ResourceRequest& new
Request, const ResourceResponse& redirectResponse) | 178 void AssociatedURLLoader::ClientAdapter::willFollowRedirect(ResourceRequest& new
Request, const ResourceResponse& redirectResponse) |
| 179 { | 179 { |
| 180 if (!m_client) | 180 if (!m_client) |
| 181 return; | 181 return; |
| 182 | 182 |
| 183 WrappedResourceRequest wrappedNewRequest(newRequest); | 183 WrappedResourceRequest wrappedNewRequest(newRequest); |
| 184 WrappedResourceResponse wrappedRedirectResponse(redirectResponse); | 184 WrappedResourceResponse wrappedRedirectResponse(redirectResponse); |
| 185 m_client->willFollowRedirect(m_loader, wrappedNewRequest, wrappedRedirectRes
ponse); | 185 m_client->willFollowRedirect(m_loader, wrappedNewRequest, wrappedRedirectRes
ponse); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 return; | 222 return; |
| 223 | 223 |
| 224 m_client->didDownloadData(m_loader, dataLength, -1); | 224 m_client->didDownloadData(m_loader, dataLength, -1); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void AssociatedURLLoader::ClientAdapter::didReceiveData(const char* data, unsign
ed dataLength) | 227 void AssociatedURLLoader::ClientAdapter::didReceiveData(const char* data, unsign
ed dataLength) |
| 228 { | 228 { |
| 229 if (!m_client) | 229 if (!m_client) |
| 230 return; | 230 return; |
| 231 | 231 |
| 232 RELEASE_ASSERT(dataLength <= static_cast<unsigned>(std::numeric_limits<int>:
:max())); | 232 CHECK_LE(dataLength, static_cast<unsigned>(std::numeric_limits<int>::max()))
; |
| 233 | 233 |
| 234 m_client->didReceiveData(m_loader, data, dataLength, -1); | 234 m_client->didReceiveData(m_loader, data, dataLength, -1); |
| 235 } | 235 } |
| 236 | 236 |
| 237 void AssociatedURLLoader::ClientAdapter::didReceiveCachedMetadata(const char* da
ta, int dataLength) | 237 void AssociatedURLLoader::ClientAdapter::didReceiveCachedMetadata(const char* da
ta, int dataLength) |
| 238 { | 238 { |
| 239 if (!m_client) | 239 if (!m_client) |
| 240 return; | 240 return; |
| 241 | 241 |
| 242 m_client->didReceiveCachedMetadata(m_loader, data, dataLength); | 242 m_client->didReceiveCachedMetadata(m_loader, data, dataLength); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 ASSERT_UNUSED(timer, timer == &m_errorTimer); | 285 ASSERT_UNUSED(timer, timer == &m_errorTimer); |
| 286 | 286 |
| 287 m_client->didFail(m_loader, m_error); | 287 m_client->didFail(m_loader, m_error); |
| 288 } | 288 } |
| 289 | 289 |
| 290 AssociatedURLLoader::AssociatedURLLoader(RawPtr<WebLocalFrameImpl> frameImpl, co
nst WebURLLoaderOptions& options) | 290 AssociatedURLLoader::AssociatedURLLoader(RawPtr<WebLocalFrameImpl> frameImpl, co
nst WebURLLoaderOptions& options) |
| 291 : m_frameImpl(frameImpl) | 291 : m_frameImpl(frameImpl) |
| 292 , m_options(options) | 292 , m_options(options) |
| 293 , m_client(0) | 293 , m_client(0) |
| 294 { | 294 { |
| 295 ASSERT(m_frameImpl); | 295 DCHECK(m_frameImpl); |
| 296 } | 296 } |
| 297 | 297 |
| 298 AssociatedURLLoader::~AssociatedURLLoader() | 298 AssociatedURLLoader::~AssociatedURLLoader() |
| 299 { | 299 { |
| 300 cancel(); | 300 cancel(); |
| 301 } | 301 } |
| 302 | 302 |
| 303 #define STATIC_ASSERT_ENUM(a, b) \ | 303 #define STATIC_ASSERT_ENUM(a, b) \ |
| 304 static_assert(static_cast<int>(a) == static_cast<int>(b), \ | 304 static_assert(static_cast<int>(a) == static_cast<int>(b), \ |
| 305 "mismatching enum: " #a) | 305 "mismatching enum: " #a) |
| 306 | 306 |
| 307 STATIC_ASSERT_ENUM(WebURLLoaderOptions::CrossOriginRequestPolicyDeny, DenyCrossO
riginRequests); | 307 STATIC_ASSERT_ENUM(WebURLLoaderOptions::CrossOriginRequestPolicyDeny, DenyCrossO
riginRequests); |
| 308 STATIC_ASSERT_ENUM(WebURLLoaderOptions::CrossOriginRequestPolicyUseAccessControl
, UseAccessControl); | 308 STATIC_ASSERT_ENUM(WebURLLoaderOptions::CrossOriginRequestPolicyUseAccessControl
, UseAccessControl); |
| 309 STATIC_ASSERT_ENUM(WebURLLoaderOptions::CrossOriginRequestPolicyAllow, AllowCros
sOriginRequests); | 309 STATIC_ASSERT_ENUM(WebURLLoaderOptions::CrossOriginRequestPolicyAllow, AllowCros
sOriginRequests); |
| 310 | 310 |
| 311 STATIC_ASSERT_ENUM(WebURLLoaderOptions::ConsiderPreflight, ConsiderPreflight); | 311 STATIC_ASSERT_ENUM(WebURLLoaderOptions::ConsiderPreflight, ConsiderPreflight); |
| 312 STATIC_ASSERT_ENUM(WebURLLoaderOptions::ForcePreflight, ForcePreflight); | 312 STATIC_ASSERT_ENUM(WebURLLoaderOptions::ForcePreflight, ForcePreflight); |
| 313 STATIC_ASSERT_ENUM(WebURLLoaderOptions::PreventPreflight, PreventPreflight); | 313 STATIC_ASSERT_ENUM(WebURLLoaderOptions::PreventPreflight, PreventPreflight); |
| 314 | 314 |
| 315 void AssociatedURLLoader::loadSynchronously(const WebURLRequest& request, WebURL
Response& response, WebURLError& error, WebData& data) | 315 void AssociatedURLLoader::loadSynchronously(const WebURLRequest& request, WebURL
Response& response, WebURLError& error, WebData& data) |
| 316 { | 316 { |
| 317 ASSERT(0); // Synchronous loading is not supported. | 317 DCHECK(0); // Synchronous loading is not supported. |
| 318 } | 318 } |
| 319 | 319 |
| 320 void AssociatedURLLoader::loadAsynchronously(const WebURLRequest& request, WebUR
LLoaderClient* client) | 320 void AssociatedURLLoader::loadAsynchronously(const WebURLRequest& request, WebUR
LLoaderClient* client) |
| 321 { | 321 { |
| 322 ASSERT(!m_loader); | 322 DCHECK(!m_loader); |
| 323 ASSERT(!m_client); | 323 DCHECK(!m_client); |
| 324 | 324 |
| 325 m_client = client; | 325 m_client = client; |
| 326 ASSERT(m_client); | 326 DCHECK(m_client); |
| 327 | 327 |
| 328 bool allowLoad = true; | 328 bool allowLoad = true; |
| 329 WebURLRequest newRequest(request); | 329 WebURLRequest newRequest(request); |
| 330 if (m_options.untrustedHTTP) { | 330 if (m_options.untrustedHTTP) { |
| 331 WebString method = newRequest.httpMethod(); | 331 WebString method = newRequest.httpMethod(); |
| 332 allowLoad = isValidHTTPToken(method) && FetchUtils::isUsefulMethod(metho
d); | 332 allowLoad = isValidHTTPToken(method) && FetchUtils::isUsefulMethod(metho
d); |
| 333 if (allowLoad) { | 333 if (allowLoad) { |
| 334 newRequest.setHTTPMethod(FetchUtils::normalizeMethod(method)); | 334 newRequest.setHTTPMethod(FetchUtils::normalizeMethod(method)); |
| 335 HTTPRequestHeaderValidator validator; | 335 HTTPRequestHeaderValidator validator; |
| 336 newRequest.visitHTTPHeaderFields(&validator); | 336 newRequest.visitHTTPHeaderFields(&validator); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 351 | 351 |
| 352 const ResourceRequest& webcoreRequest = newRequest.toResourceRequest(); | 352 const ResourceRequest& webcoreRequest = newRequest.toResourceRequest(); |
| 353 if (webcoreRequest.requestContext() == WebURLRequest::RequestContextUnsp
ecified) { | 353 if (webcoreRequest.requestContext() == WebURLRequest::RequestContextUnsp
ecified) { |
| 354 // FIXME: We load URLs without setting a TargetType (and therefore a
request context) in several | 354 // FIXME: We load URLs without setting a TargetType (and therefore a
request context) in several |
| 355 // places in content/ (P2PPortAllocatorSession::AllocateLegacyRelayS
ession, for example). Remove | 355 // places in content/ (P2PPortAllocatorSession::AllocateLegacyRelayS
ession, for example). Remove |
| 356 // this once those places are patched up. | 356 // this once those places are patched up. |
| 357 newRequest.setRequestContext(WebURLRequest::RequestContextInternal); | 357 newRequest.setRequestContext(WebURLRequest::RequestContextInternal); |
| 358 } | 358 } |
| 359 | 359 |
| 360 Document* webcoreDocument = m_frameImpl->frame()->document(); | 360 Document* webcoreDocument = m_frameImpl->frame()->document(); |
| 361 ASSERT(webcoreDocument); | 361 DCHECK(webcoreDocument); |
| 362 m_loader = DocumentThreadableLoader::create(*webcoreDocument, m_clientAd
apter.get(), options, resourceLoaderOptions); | 362 m_loader = DocumentThreadableLoader::create(*webcoreDocument, m_clientAd
apter.get(), options, resourceLoaderOptions); |
| 363 m_loader->start(webcoreRequest); | 363 m_loader->start(webcoreRequest); |
| 364 } | 364 } |
| 365 | 365 |
| 366 if (!m_loader) { | 366 if (!m_loader) { |
| 367 // FIXME: return meaningful error codes. | 367 // FIXME: return meaningful error codes. |
| 368 m_clientAdapter->setDelayedError(ResourceError()); | 368 m_clientAdapter->setDelayedError(ResourceError()); |
| 369 } | 369 } |
| 370 m_clientAdapter->enableErrorNotifications(); | 370 m_clientAdapter->enableErrorNotifications(); |
| 371 } | 371 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 383 if (m_loader) | 383 if (m_loader) |
| 384 m_loader->setDefersLoading(defersLoading); | 384 m_loader->setDefersLoading(defersLoading); |
| 385 } | 385 } |
| 386 | 386 |
| 387 void AssociatedURLLoader::setLoadingTaskRunner(blink::WebTaskRunner*) | 387 void AssociatedURLLoader::setLoadingTaskRunner(blink::WebTaskRunner*) |
| 388 { | 388 { |
| 389 // TODO(alexclarke): Maybe support this one day if it proves worthwhile. | 389 // TODO(alexclarke): Maybe support this one day if it proves worthwhile. |
| 390 } | 390 } |
| 391 | 391 |
| 392 } // namespace blink | 392 } // namespace blink |
| OLD | NEW |