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

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

Issue 1710733002: Move multipart resource handling to core/fetch (2/2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@multipart-cleanup
Patch Set: rebase Created 4 years, 9 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
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 { 62 {
63 ResourceLoader* loader = new ResourceLoader(fetcher, resource, options); 63 ResourceLoader* loader = new ResourceLoader(fetcher, resource, options);
64 loader->init(request); 64 loader->init(request);
65 return loader; 65 return loader;
66 } 66 }
67 67
68 ResourceLoader::ResourceLoader(ResourceFetcher* fetcher, Resource* resource, con st ResourceLoaderOptions& options) 68 ResourceLoader::ResourceLoader(ResourceFetcher* fetcher, Resource* resource, con st ResourceLoaderOptions& options)
69 : m_fetcher(fetcher) 69 : m_fetcher(fetcher)
70 , m_notifiedLoadComplete(false) 70 , m_notifiedLoadComplete(false)
71 , m_defersLoading(fetcher->defersLoading()) 71 , m_defersLoading(fetcher->defersLoading())
72 , m_loadingMultipartContent(false)
73 , m_options(options) 72 , m_options(options)
74 , m_resource(resource) 73 , m_resource(resource)
75 , m_state(Initialized) 74 , m_state(Initialized)
76 , m_connectionState(ConnectionStateNew) 75 , m_connectionState(ConnectionStateNew)
77 { 76 {
78 ASSERT(m_resource); 77 ASSERT(m_resource);
79 ASSERT(m_fetcher); 78 ASSERT(m_fetcher);
80 } 79 }
81 80
82 ResourceLoader::~ResourceLoader() 81 ResourceLoader::~ResourceLoader()
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 355 }
357 356
358 m_resource->responseReceived(resourceResponse, handle.release()); 357 m_resource->responseReceived(resourceResponse, handle.release());
359 if (m_state == Terminated) 358 if (m_state == Terminated)
360 return; 359 return;
361 360
362 m_fetcher->didReceiveResponse(m_resource.get(), resourceResponse); 361 m_fetcher->didReceiveResponse(m_resource.get(), resourceResponse);
363 if (m_state == Terminated) 362 if (m_state == Terminated)
364 return; 363 return;
365 364
366 if (response.toResourceResponse().isMultipart()) {
367 // We only support multipart for images, though the image may be loaded
368 // as a main resource that we end up displaying through an ImageDocument .
369 if (!m_resource->isImage() && m_resource->type() != Resource::MainResour ce) {
370 cancel();
371 return;
372 }
373 m_loadingMultipartContent = true;
374 } else if (isMultipartPayload) {
375 // Since a subresource loader does not load multipart sections progressi vely, data was delivered to the loader all at once.
376 // After the first multipart section is complete, signal to delegates th at this load is "finished"
377 m_fetcher->subresourceLoaderFinishedLoadingOnePart(this);
378 didFinishLoadingOnePart(0, WebURLLoaderClient::kUnknownEncodedDataLength );
379 }
380 if (m_state == Terminated)
381 return;
382
383 if (m_resource->response().httpStatusCode() < 400 || m_resource->shouldIgnor eHTTPStatusCodeErrors()) 365 if (m_resource->response().httpStatusCode() < 400 || m_resource->shouldIgnor eHTTPStatusCodeErrors())
384 return; 366 return;
385 m_state = Finishing; 367 m_state = Finishing;
386 368
387 if (!m_notifiedLoadComplete) { 369 if (!m_notifiedLoadComplete) {
388 m_notifiedLoadComplete = true; 370 m_notifiedLoadComplete = true;
389 m_fetcher->didFailLoading(m_resource.get(), ResourceError::cancelledErro r(m_request.url())); 371 m_fetcher->didFailLoading(m_resource.get(), ResourceError::cancelledErro r(m_request.url()));
390 } 372 }
391 373
392 ASSERT(m_state != Terminated); 374 ASSERT(m_state != Terminated);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); 503 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength);
522 } 504 }
523 505
524 ResourceRequest& ResourceLoader::applyOptions(ResourceRequest& request) const 506 ResourceRequest& ResourceLoader::applyOptions(ResourceRequest& request) const
525 { 507 {
526 request.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredC redentials); 508 request.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredC redentials);
527 return request; 509 return request;
528 } 510 }
529 511
530 } // namespace blink 512 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698