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

Side by Side Diff: Source/core/loader/DocumentThreadableLoader.cpp

Issue 300893002: Rename methods in DocumentThreadableLoader for readability (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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
« no previous file with comments | « Source/core/loader/DocumentThreadableLoader.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013, Intel Corporation 3 * Copyright (C) 2013, Intel Corporation
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 loadRequest(crossOriginRequest); 119 loadRequest(crossOriginRequest);
120 } else { 120 } else {
121 m_simpleRequest = false; 121 m_simpleRequest = false;
122 122
123 OwnPtr<ResourceRequest> crossOriginRequest = adoptPtr(new ResourceReques t(request)); 123 OwnPtr<ResourceRequest> crossOriginRequest = adoptPtr(new ResourceReques t(request));
124 // Do not set the Origin header for preflight requests. 124 // Do not set the Origin header for preflight requests.
125 updateRequestForAccessControl(*crossOriginRequest, 0, m_options.allowCre dentials); 125 updateRequestForAccessControl(*crossOriginRequest, 0, m_options.allowCre dentials);
126 m_actualRequest = crossOriginRequest.release(); 126 m_actualRequest = crossOriginRequest.release();
127 127
128 if (CrossOriginPreflightResultCache::shared().canSkipPreflight(securityO rigin()->toString(), m_actualRequest->url(), m_options.allowCredentials, m_actua lRequest->httpMethod(), m_actualRequest->httpHeaderFields())) { 128 if (CrossOriginPreflightResultCache::shared().canSkipPreflight(securityO rigin()->toString(), m_actualRequest->url(), m_options.allowCredentials, m_actua lRequest->httpMethod(), m_actualRequest->httpHeaderFields())) {
129 preflightSuccess(); 129 loadActualRequest();
130 } else { 130 } else {
131 ResourceRequest preflightRequest = createAccessControlPreflightReque st(*m_actualRequest, securityOrigin()); 131 ResourceRequest preflightRequest = createAccessControlPreflightReque st(*m_actualRequest, securityOrigin());
132 loadRequest(preflightRequest); 132 loadRequest(preflightRequest);
133 } 133 }
134 } 134 }
135 } 135 }
136 136
137 DocumentThreadableLoader::~DocumentThreadableLoader() 137 DocumentThreadableLoader::~DocumentThreadableLoader()
138 { 138 {
139 } 139 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 261 }
262 262
263 void DocumentThreadableLoader::responseReceived(Resource* resource, const Resour ceResponse& response) 263 void DocumentThreadableLoader::responseReceived(Resource* resource, const Resour ceResponse& response)
264 { 264 {
265 ASSERT_UNUSED(resource, resource == this->resource()); 265 ASSERT_UNUSED(resource, resource == this->resource());
266 handleResponse(resource->identifier(), response); 266 handleResponse(resource->identifier(), response);
267 } 267 }
268 268
269 void DocumentThreadableLoader::handlePreflightResponse(unsigned long identifier, const ResourceResponse& response) 269 void DocumentThreadableLoader::handlePreflightResponse(unsigned long identifier, const ResourceResponse& response)
270 { 270 {
271 // Notifying the inspector here is necessary because a call to preflightFail ure() might synchronously 271 // Notifying the inspector here is necessary because a call to handlePreflig htFailure() might synchronously
272 // cause the underlying ResourceLoader to be cancelled before it tells the i nspector about the response. 272 // cause the underlying ResourceLoader to be cancelled before it tells the i nspector about the response.
273 // In that case, if we don't tell the inspector about the response now, the resource type in the inspector 273 // In that case, if we don't tell the inspector about the response now, the resource type in the inspector
274 // will default to "other" instead of something more descriptive. 274 // will default to "other" instead of something more descriptive.
275 DocumentLoader* loader = m_document.frame()->loader().documentLoader(); 275 DocumentLoader* loader = m_document.frame()->loader().documentLoader();
276 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Resour ceReceiveResponse", "data", InspectorReceiveResponseEvent::data(identifier, m_do cument.frame(), response)); 276 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Resour ceReceiveResponse", "data", InspectorReceiveResponseEvent::data(identifier, m_do cument.frame(), response));
277 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing. 277 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing.
278 InspectorInstrumentation::didReceiveResourceResponse(m_document.frame(), ide ntifier, loader, response, resource() ? resource()->loader() : 0); 278 InspectorInstrumentation::didReceiveResourceResponse(m_document.frame(), ide ntifier, loader, response, resource() ? resource()->loader() : 0);
279 279
280 String accessControlErrorDescription; 280 String accessControlErrorDescription;
281 281
282 if (!passesAccessControlCheck(response, m_options.allowCredentials, security Origin(), accessControlErrorDescription)) { 282 if (!passesAccessControlCheck(response, m_options.allowCredentials, security Origin(), accessControlErrorDescription)) {
283 preflightFailure(response.url().string(), accessControlErrorDescription) ; 283 handlePreflightFailure(response.url().string(), accessControlErrorDescri ption);
284 return; 284 return;
285 } 285 }
286 286
287 if (!passesPreflightStatusCheck(response, accessControlErrorDescription)) { 287 if (!passesPreflightStatusCheck(response, accessControlErrorDescription)) {
288 preflightFailure(response.url().string(), accessControlErrorDescription) ; 288 handlePreflightFailure(response.url().string(), accessControlErrorDescri ption);
289 return; 289 return;
290 } 290 }
291 291
292 OwnPtr<CrossOriginPreflightResultCacheItem> preflightResult = adoptPtr(new C rossOriginPreflightResultCacheItem(m_options.allowCredentials)); 292 OwnPtr<CrossOriginPreflightResultCacheItem> preflightResult = adoptPtr(new C rossOriginPreflightResultCacheItem(m_options.allowCredentials));
293 if (!preflightResult->parse(response, accessControlErrorDescription) 293 if (!preflightResult->parse(response, accessControlErrorDescription)
294 || !preflightResult->allowsCrossOriginMethod(m_actualRequest->httpMethod (), accessControlErrorDescription) 294 || !preflightResult->allowsCrossOriginMethod(m_actualRequest->httpMethod (), accessControlErrorDescription)
295 || !preflightResult->allowsCrossOriginHeaders(m_actualRequest->httpHeade rFields(), accessControlErrorDescription)) { 295 || !preflightResult->allowsCrossOriginHeaders(m_actualRequest->httpHeade rFields(), accessControlErrorDescription)) {
296 preflightFailure(response.url().string(), accessControlErrorDescription) ; 296 handlePreflightFailure(response.url().string(), accessControlErrorDescri ption);
297 return; 297 return;
298 } 298 }
299 299
300 CrossOriginPreflightResultCache::shared().appendEntry(securityOrigin()->toSt ring(), m_actualRequest->url(), preflightResult.release()); 300 CrossOriginPreflightResultCache::shared().appendEntry(securityOrigin()->toSt ring(), m_actualRequest->url(), preflightResult.release());
301 } 301 }
302 302
303 void DocumentThreadableLoader::handleResponse(unsigned long identifier, const Re sourceResponse& response) 303 void DocumentThreadableLoader::handleResponse(unsigned long identifier, const Re sourceResponse& response)
304 { 304 {
305 ASSERT(m_client); 305 ASSERT(m_client);
306 306
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 m_client->didFail(resource->resourceError()); 345 m_client->didFail(resource->resourceError());
346 else 346 else
347 handleSuccessfulFinish(resource->identifier(), resource->loadFinishTime( )); 347 handleSuccessfulFinish(resource->identifier(), resource->loadFinishTime( ));
348 } 348 }
349 349
350 void DocumentThreadableLoader::handleSuccessfulFinish(unsigned long identifier, double finishTime) 350 void DocumentThreadableLoader::handleSuccessfulFinish(unsigned long identifier, double finishTime)
351 { 351 {
352 if (m_actualRequest) { 352 if (m_actualRequest) {
353 ASSERT(!m_sameOriginRequest); 353 ASSERT(!m_sameOriginRequest);
354 ASSERT(m_options.crossOriginRequestPolicy == UseAccessControl); 354 ASSERT(m_options.crossOriginRequestPolicy == UseAccessControl);
355 preflightSuccess(); 355 loadActualRequest();
356 } else 356 } else
357 m_client->didFinishLoading(identifier, finishTime); 357 m_client->didFinishLoading(identifier, finishTime);
358 } 358 }
359 359
360 void DocumentThreadableLoader::didTimeout(Timer<DocumentThreadableLoader>* timer ) 360 void DocumentThreadableLoader::didTimeout(Timer<DocumentThreadableLoader>* timer )
361 { 361 {
362 ASSERT_UNUSED(timer, timer == &m_timeoutTimer); 362 ASSERT_UNUSED(timer, timer == &m_timeoutTimer);
363 363
364 // Using values from net/base/net_error_list.h ERR_TIMED_OUT, 364 // Using values from net/base/net_error_list.h ERR_TIMED_OUT,
365 // Same as existing FIXME above - this error should be coming from FrameLoad erClient to be identifiable. 365 // Same as existing FIXME above - this error should be coming from FrameLoad erClient to be identifiable.
366 static const int timeoutError = -7; 366 static const int timeoutError = -7;
367 ResourceError error("net", timeoutError, resource()->url(), String()); 367 ResourceError error("net", timeoutError, resource()->url(), String());
368 error.setIsTimeout(true); 368 error.setIsTimeout(true);
369 cancelWithError(error); 369 cancelWithError(error);
370 } 370 }
371 371
372 void DocumentThreadableLoader::preflightSuccess() 372 void DocumentThreadableLoader::loadActualRequest()
373 { 373 {
374 OwnPtr<ResourceRequest> actualRequest; 374 OwnPtr<ResourceRequest> actualRequest;
375 actualRequest.swap(m_actualRequest); 375 actualRequest.swap(m_actualRequest);
376 376
377 actualRequest->setHTTPOrigin(securityOrigin()->toAtomicString()); 377 actualRequest->setHTTPOrigin(securityOrigin()->toAtomicString());
378 378
379 clearResource(); 379 clearResource();
380 380
381 loadRequest(*actualRequest); 381 loadRequest(*actualRequest);
382 } 382 }
383 383
384 void DocumentThreadableLoader::preflightFailure(const String& url, const String& errorDescription) 384 void DocumentThreadableLoader::handlePreflightFailure(const String& url, const S tring& errorDescription)
385 { 385 {
386 ResourceError error(errorDomainBlinkInternal, 0, url, errorDescription); 386 ResourceError error(errorDomainBlinkInternal, 0, url, errorDescription);
387 387
388 // Prevent handleSuccessfulFinish() from bypassing access check. 388 // Prevent handleSuccessfulFinish() from bypassing access check.
389 m_actualRequest = nullptr; 389 m_actualRequest = nullptr;
390 390
391 m_client->didFailAccessControlCheck(error); 391 m_client->didFailAccessControlCheck(error);
392 } 392 }
393 393
394 void DocumentThreadableLoader::loadRequest(const ResourceRequest& request) 394 void DocumentThreadableLoader::loadRequest(const ResourceRequest& request)
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 return true; 472 return true;
473 return m_document.contentSecurityPolicy()->allowConnectToSource(url); 473 return m_document.contentSecurityPolicy()->allowConnectToSource(url);
474 } 474 }
475 475
476 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const 476 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const
477 { 477 {
478 return m_options.securityOrigin ? m_options.securityOrigin.get() : m_documen t.securityOrigin(); 478 return m_options.securityOrigin ? m_options.securityOrigin.get() : m_documen t.securityOrigin();
479 } 479 }
480 480
481 } // namespace WebCore 481 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/loader/DocumentThreadableLoader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698