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

Side by Side Diff: Source/core/fetch/ResourceLoader.cpp

Issue 603903003: [Streams] Pass WebDataConsumerHandle when the response arrives. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@web-data-pipe
Patch Set: rebase Created 6 years, 1 month 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
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved.
3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com) 3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com)
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 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 RefPtrWillBeRawPtr<ResourceLoader> protect(this); 339 RefPtrWillBeRawPtr<ResourceLoader> protect(this);
340 m_resource->didSendData(bytesSent, totalBytesToBeSent); 340 m_resource->didSendData(bytesSent, totalBytesToBeSent);
341 } 341 }
342 342
343 bool ResourceLoader::responseNeedsAccessControlCheck() const 343 bool ResourceLoader::responseNeedsAccessControlCheck() const
344 { 344 {
345 // If the fetch was (potentially) CORS enabled, an access control check of t he response is required. 345 // If the fetch was (potentially) CORS enabled, an access control check of t he response is required.
346 return m_options.corsEnabled == IsCORSEnabled; 346 return m_options.corsEnabled == IsCORSEnabled;
347 } 347 }
348 348
349 void ResourceLoader::didReceiveResponse(blink::WebURLLoader*, const blink::WebUR LResponse& response) 349 void ResourceLoader::didReceiveResponse(blink::WebURLLoader*, const blink::WebUR LResponse& response, WebDataConsumerHandle* rawHandle)
350 { 350 {
351 ASSERT(!response.isNull()); 351 ASSERT(!response.isNull());
352 ASSERT(m_state == Initialized); 352 ASSERT(m_state == Initialized);
353 // |rawHandle|'s ownership is transferred to the callee.
354 OwnPtr<WebDataConsumerHandle> handle = adoptPtr(rawHandle);
353 355
354 bool isMultipartPayload = response.isMultipartPayload(); 356 bool isMultipartPayload = response.isMultipartPayload();
355 bool isValidStateTransition = (m_connectionState == ConnectionStateStarted | | m_connectionState == ConnectionStateReceivedResponse); 357 bool isValidStateTransition = (m_connectionState == ConnectionStateStarted | | m_connectionState == ConnectionStateReceivedResponse);
356 // In the case of multipart loads, calls to didReceiveData & didReceiveRespo nse can be interleaved. 358 // In the case of multipart loads, calls to didReceiveData & didReceiveRespo nse can be interleaved.
357 RELEASE_ASSERT(isMultipartPayload || isValidStateTransition); 359 RELEASE_ASSERT(isMultipartPayload || isValidStateTransition);
358 m_connectionState = ConnectionStateReceivedResponse; 360 m_connectionState = ConnectionStateReceivedResponse;
359 361
360 const ResourceResponse& resourceResponse = response.toResourceResponse(); 362 const ResourceResponse& resourceResponse = response.toResourceResponse();
361 363
362 if (responseNeedsAccessControlCheck()) { 364 if (responseNeedsAccessControlCheck()) {
(...skipping 22 matching lines...) Expand all
385 m_host->didReceiveResponse(m_resource, resourceResponse); 387 m_host->didReceiveResponse(m_resource, resourceResponse);
386 cancel(); 388 cancel();
387 return; 389 return;
388 } 390 }
389 } 391 }
390 } 392 }
391 393
392 // Reference the object in this method since the additional processing can d o 394 // Reference the object in this method since the additional processing can d o
393 // anything including removing the last reference to this object. 395 // anything including removing the last reference to this object.
394 RefPtrWillBeRawPtr<ResourceLoader> protect(this); 396 RefPtrWillBeRawPtr<ResourceLoader> protect(this);
395 m_resource->responseReceived(resourceResponse); 397 m_resource->responseReceived(resourceResponse, handle.release());
396 if (m_state == Terminated) 398 if (m_state == Terminated)
397 return; 399 return;
398 400
399 m_host->didReceiveResponse(m_resource, resourceResponse); 401 m_host->didReceiveResponse(m_resource, resourceResponse);
400 if (m_state == Terminated) 402 if (m_state == Terminated)
401 return; 403 return;
402 404
403 if (response.toResourceResponse().isMultipart()) { 405 if (response.toResourceResponse().isMultipart()) {
404 // We don't count multiParts in a ResourceFetcher's request count 406 // We don't count multiParts in a ResourceFetcher's request count
405 m_requestCountTracker.clear(); 407 m_requestCountTracker.clear();
(...skipping 18 matching lines...) Expand all
424 if (!m_notifiedLoadComplete) { 426 if (!m_notifiedLoadComplete) {
425 m_notifiedLoadComplete = true; 427 m_notifiedLoadComplete = true;
426 m_host->didFailLoading(m_resource, ResourceError::cancelledError(m_reque st.url())); 428 m_host->didFailLoading(m_resource, ResourceError::cancelledError(m_reque st.url()));
427 } 429 }
428 430
429 ASSERT(m_state != Terminated); 431 ASSERT(m_state != Terminated);
430 m_resource->error(Resource::LoadError); 432 m_resource->error(Resource::LoadError);
431 cancel(); 433 cancel();
432 } 434 }
433 435
436 void ResourceLoader::didReceiveResponse(blink::WebURLLoader* loader, const blink ::WebURLResponse& response)
437 {
438 didReceiveResponse(loader, response, nullptr);
439 }
440
434 void ResourceLoader::didReceiveData(blink::WebURLLoader*, const char* data, int length, int encodedDataLength) 441 void ResourceLoader::didReceiveData(blink::WebURLLoader*, const char* data, int length, int encodedDataLength)
435 { 442 {
436 ASSERT(m_state != Terminated); 443 ASSERT(m_state != Terminated);
437 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con nectionState == ConnectionStateReceivingData); 444 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con nectionState == ConnectionStateReceivingData);
438 m_connectionState = ConnectionStateReceivingData; 445 m_connectionState = ConnectionStateReceivingData;
439 446
440 // It is possible to receive data on uninitialized resources if it had an er ror status code, and we are running a nested message 447 // It is possible to receive data on uninitialized resources if it had an er ror status code, and we are running a nested message
441 // loop. When this occurs, ignoring the data is the correct action. 448 // loop. When this occurs, ignoring the data is the correct action.
442 if (m_resource->response().httpStatusCode() >= 400 && !m_resource->shouldIgn oreHTTPStatusCodeErrors()) 449 if (m_resource->response().httpStatusCode() >= 400 && !m_resource->shouldIgn oreHTTPStatusCodeErrors())
443 return; 450 return;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); 555 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength);
549 } 556 }
550 557
551 ResourceRequest& ResourceLoader::applyOptions(ResourceRequest& request) const 558 ResourceRequest& ResourceLoader::applyOptions(ResourceRequest& request) const
552 { 559 {
553 request.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredC redentials); 560 request.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredC redentials);
554 return request; 561 return request;
555 } 562 }
556 563
557 } 564 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698