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

Side by Side Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 2526983002: Refactor ResourceHandler API. (Closed)
Patch Set: Response to comments Created 3 years, 10 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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading
6 6
7 #include "content/browser/loader/resource_dispatcher_host_impl.h" 7 #include "content/browser/loader/resource_dispatcher_host_impl.h"
8 8
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "content/browser/loader/async_resource_handler.h" 46 #include "content/browser/loader/async_resource_handler.h"
47 #include "content/browser/loader/async_revalidation_manager.h" 47 #include "content/browser/loader/async_revalidation_manager.h"
48 #include "content/browser/loader/detachable_resource_handler.h" 48 #include "content/browser/loader/detachable_resource_handler.h"
49 #include "content/browser/loader/intercepting_resource_handler.h" 49 #include "content/browser/loader/intercepting_resource_handler.h"
50 #include "content/browser/loader/loader_delegate.h" 50 #include "content/browser/loader/loader_delegate.h"
51 #include "content/browser/loader/mime_sniffing_resource_handler.h" 51 #include "content/browser/loader/mime_sniffing_resource_handler.h"
52 #include "content/browser/loader/mojo_async_resource_handler.h" 52 #include "content/browser/loader/mojo_async_resource_handler.h"
53 #include "content/browser/loader/navigation_resource_handler.h" 53 #include "content/browser/loader/navigation_resource_handler.h"
54 #include "content/browser/loader/navigation_resource_throttle.h" 54 #include "content/browser/loader/navigation_resource_throttle.h"
55 #include "content/browser/loader/navigation_url_loader_impl_core.h" 55 #include "content/browser/loader/navigation_url_loader_impl_core.h"
56 #include "content/browser/loader/null_resource_controller.h"
56 #include "content/browser/loader/power_save_block_resource_throttle.h" 57 #include "content/browser/loader/power_save_block_resource_throttle.h"
57 #include "content/browser/loader/redirect_to_file_resource_handler.h" 58 #include "content/browser/loader/redirect_to_file_resource_handler.h"
58 #include "content/browser/loader/resource_loader.h" 59 #include "content/browser/loader/resource_loader.h"
59 #include "content/browser/loader/resource_message_filter.h" 60 #include "content/browser/loader/resource_message_filter.h"
60 #include "content/browser/loader/resource_request_info_impl.h" 61 #include "content/browser/loader/resource_request_info_impl.h"
61 #include "content/browser/loader/resource_requester_info.h" 62 #include "content/browser/loader/resource_requester_info.h"
62 #include "content/browser/loader/resource_scheduler.h" 63 #include "content/browser/loader/resource_scheduler.h"
63 #include "content/browser/loader/stream_resource_handler.h" 64 #include "content/browser/loader/stream_resource_handler.h"
64 #include "content/browser/loader/sync_resource_handler.h" 65 #include "content/browser/loader/sync_resource_handler.h"
65 #include "content/browser/loader/throttling_resource_handler.h" 66 #include "content/browser/loader/throttling_resource_handler.h"
(...skipping 2272 matching lines...) Expand 10 before | Expand all | Expand 10 after
2338 info->set_memory_cost(CalculateApproximateMemoryCost(request.get())); 2339 info->set_memory_cost(CalculateApproximateMemoryCost(request.get()));
2339 2340
2340 // If enqueing/starting this request will exceed our per-process memory 2341 // If enqueing/starting this request will exceed our per-process memory
2341 // bound, abort it right away. 2342 // bound, abort it right away.
2342 OustandingRequestsStats stats = IncrementOutstandingRequestsMemory(1, *info); 2343 OustandingRequestsStats stats = IncrementOutstandingRequestsMemory(1, *info);
2343 if (stats.memory_cost > max_outstanding_requests_cost_per_process_) { 2344 if (stats.memory_cost > max_outstanding_requests_cost_per_process_) {
2344 // We call "CancelWithError()" as a way of setting the net::URLRequest's 2345 // We call "CancelWithError()" as a way of setting the net::URLRequest's
2345 // status -- it has no effect beyond this, since the request hasn't started. 2346 // status -- it has no effect beyond this, since the request hasn't started.
2346 request->CancelWithError(net::ERR_INSUFFICIENT_RESOURCES); 2347 request->CancelWithError(net::ERR_INSUFFICIENT_RESOURCES);
2347 2348
2348 bool defer = false; 2349 bool was_resumed = false;
2349 handler->OnResponseCompleted(request->status(), &defer); 2350 // TODO(mmenke): Get rid of NullResourceController and do something more
2350 if (defer) { 2351 // reasonable.
2351 // TODO(darin): The handler is not ready for us to kill the request. Oops! 2352 handler->OnResponseCompleted(
2352 NOTREACHED(); 2353 request->status(),
2353 } 2354 base::MakeUnique<NullResourceController>(&was_resumed));
2355 // TODO(darin): The handler is not ready for us to kill the request. Oops!
2356 DCHECK(was_resumed);
2354 2357
2355 IncrementOutstandingRequestsMemory(-1, *info); 2358 IncrementOutstandingRequestsMemory(-1, *info);
2356 2359
2357 // A ResourceHandler must not outlive its associated URLRequest. 2360 // A ResourceHandler must not outlive its associated URLRequest.
2358 handler.reset(); 2361 handler.reset();
2359 return; 2362 return;
2360 } 2363 }
2361 2364
2362 std::unique_ptr<ResourceLoader> loader(new ResourceLoader( 2365 std::unique_ptr<ResourceLoader> loader(new ResourceLoader(
2363 std::move(request), std::move(handler), this)); 2366 std::move(request), std::move(handler), this));
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
2793 &throttles); 2796 &throttles);
2794 if (!throttles.empty()) { 2797 if (!throttles.empty()) {
2795 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, 2798 handler.reset(new ThrottlingResourceHandler(std::move(handler), request,
2796 std::move(throttles))); 2799 std::move(throttles)));
2797 } 2800 }
2798 } 2801 }
2799 return handler; 2802 return handler;
2800 } 2803 }
2801 2804
2802 } // namespace content 2805 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_controller.h ('k') | content/browser/loader/resource_dispatcher_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698