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

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

Issue 2526983002: Refactor ResourceHandler API. (Closed)
Patch Set: Fix merge Created 3 years, 11 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 2310 matching lines...) Expand 10 before | Expand all | Expand 10 after
2376 info->set_memory_cost(CalculateApproximateMemoryCost(request.get())); 2377 info->set_memory_cost(CalculateApproximateMemoryCost(request.get()));
2377 2378
2378 // If enqueing/starting this request will exceed our per-process memory 2379 // If enqueing/starting this request will exceed our per-process memory
2379 // bound, abort it right away. 2380 // bound, abort it right away.
2380 OustandingRequestsStats stats = IncrementOutstandingRequestsMemory(1, *info); 2381 OustandingRequestsStats stats = IncrementOutstandingRequestsMemory(1, *info);
2381 if (stats.memory_cost > max_outstanding_requests_cost_per_process_) { 2382 if (stats.memory_cost > max_outstanding_requests_cost_per_process_) {
2382 // We call "CancelWithError()" as a way of setting the net::URLRequest's 2383 // We call "CancelWithError()" as a way of setting the net::URLRequest's
2383 // status -- it has no effect beyond this, since the request hasn't started. 2384 // status -- it has no effect beyond this, since the request hasn't started.
2384 request->CancelWithError(net::ERR_INSUFFICIENT_RESOURCES); 2385 request->CancelWithError(net::ERR_INSUFFICIENT_RESOURCES);
2385 2386
2386 bool defer = false; 2387 bool was_resumed = false;
2387 handler->OnResponseCompleted(request->status(), &defer); 2388 handler->OnResponseCompleted(
2388 if (defer) { 2389 request->status(),
2389 // TODO(darin): The handler is not ready for us to kill the request. Oops! 2390 base::MakeUnique<NullResourceController>(&was_resumed));
2390 NOTREACHED(); 2391 // TODO(darin): The handler is not ready for us to kill the request. Oops!
2391 } 2392 DCHECK(was_resumed);
2392 2393
2393 IncrementOutstandingRequestsMemory(-1, *info); 2394 IncrementOutstandingRequestsMemory(-1, *info);
2394 2395
2395 // A ResourceHandler must not outlive its associated URLRequest. 2396 // A ResourceHandler must not outlive its associated URLRequest.
2396 handler.reset(); 2397 handler.reset();
2397 return; 2398 return;
2398 } 2399 }
2399 2400
2400 std::unique_ptr<ResourceLoader> loader(new ResourceLoader( 2401 std::unique_ptr<ResourceLoader> loader(new ResourceLoader(
2401 std::move(request), std::move(handler), this)); 2402 std::move(request), std::move(handler), this));
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
2831 &throttles); 2832 &throttles);
2832 if (!throttles.empty()) { 2833 if (!throttles.empty()) {
2833 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, 2834 handler.reset(new ThrottlingResourceHandler(std::move(handler), request,
2834 std::move(throttles))); 2835 std::move(throttles)));
2835 } 2836 }
2836 } 2837 }
2837 return handler; 2838 return handler;
2838 } 2839 }
2839 2840
2840 } // namespace content 2841 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698