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

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

Issue 2526983002: Refactor ResourceHandler API. (Closed)
Patch Set: Fix stuff Created 4 years 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "content/browser/loader/async_resource_handler.h" 45 #include "content/browser/loader/async_resource_handler.h"
46 #include "content/browser/loader/async_revalidation_manager.h" 46 #include "content/browser/loader/async_revalidation_manager.h"
47 #include "content/browser/loader/detachable_resource_handler.h" 47 #include "content/browser/loader/detachable_resource_handler.h"
48 #include "content/browser/loader/intercepting_resource_handler.h" 48 #include "content/browser/loader/intercepting_resource_handler.h"
49 #include "content/browser/loader/loader_delegate.h" 49 #include "content/browser/loader/loader_delegate.h"
50 #include "content/browser/loader/mime_sniffing_resource_handler.h" 50 #include "content/browser/loader/mime_sniffing_resource_handler.h"
51 #include "content/browser/loader/mojo_async_resource_handler.h" 51 #include "content/browser/loader/mojo_async_resource_handler.h"
52 #include "content/browser/loader/navigation_resource_handler.h" 52 #include "content/browser/loader/navigation_resource_handler.h"
53 #include "content/browser/loader/navigation_resource_throttle.h" 53 #include "content/browser/loader/navigation_resource_throttle.h"
54 #include "content/browser/loader/navigation_url_loader_impl_core.h" 54 #include "content/browser/loader/navigation_url_loader_impl_core.h"
55 #include "content/browser/loader/null_resource_controller.h"
55 #include "content/browser/loader/power_save_block_resource_throttle.h" 56 #include "content/browser/loader/power_save_block_resource_throttle.h"
56 #include "content/browser/loader/redirect_to_file_resource_handler.h" 57 #include "content/browser/loader/redirect_to_file_resource_handler.h"
57 #include "content/browser/loader/resource_loader.h" 58 #include "content/browser/loader/resource_loader.h"
58 #include "content/browser/loader/resource_message_filter.h" 59 #include "content/browser/loader/resource_message_filter.h"
59 #include "content/browser/loader/resource_request_info_impl.h" 60 #include "content/browser/loader/resource_request_info_impl.h"
60 #include "content/browser/loader/resource_scheduler.h" 61 #include "content/browser/loader/resource_scheduler.h"
61 #include "content/browser/loader/stream_resource_handler.h" 62 #include "content/browser/loader/stream_resource_handler.h"
62 #include "content/browser/loader/sync_resource_handler.h" 63 #include "content/browser/loader/sync_resource_handler.h"
63 #include "content/browser/loader/throttling_resource_handler.h" 64 #include "content/browser/loader/throttling_resource_handler.h"
64 #include "content/browser/loader/upload_data_stream_builder.h" 65 #include "content/browser/loader/upload_data_stream_builder.h"
(...skipping 2281 matching lines...) Expand 10 before | Expand all | Expand 10 after
2346 info->set_memory_cost(CalculateApproximateMemoryCost(request.get())); 2347 info->set_memory_cost(CalculateApproximateMemoryCost(request.get()));
2347 2348
2348 // If enqueing/starting this request will exceed our per-process memory 2349 // If enqueing/starting this request will exceed our per-process memory
2349 // bound, abort it right away. 2350 // bound, abort it right away.
2350 OustandingRequestsStats stats = IncrementOutstandingRequestsMemory(1, *info); 2351 OustandingRequestsStats stats = IncrementOutstandingRequestsMemory(1, *info);
2351 if (stats.memory_cost > max_outstanding_requests_cost_per_process_) { 2352 if (stats.memory_cost > max_outstanding_requests_cost_per_process_) {
2352 // We call "CancelWithError()" as a way of setting the net::URLRequest's 2353 // We call "CancelWithError()" as a way of setting the net::URLRequest's
2353 // status -- it has no effect beyond this, since the request hasn't started. 2354 // status -- it has no effect beyond this, since the request hasn't started.
2354 request->CancelWithError(net::ERR_INSUFFICIENT_RESOURCES); 2355 request->CancelWithError(net::ERR_INSUFFICIENT_RESOURCES);
2355 2356
2356 bool defer = false; 2357 bool was_resumed = false;
2357 handler->OnResponseCompleted(request->status(), &defer); 2358 handler->OnResponseCompleted(
2358 if (defer) { 2359 request->status(),
2359 // TODO(darin): The handler is not ready for us to kill the request. Oops! 2360 base::MakeUnique<NullResourceController>(&was_resumed));
2360 NOTREACHED(); 2361 // TODO(darin): The handler is not ready for us to kill the request. Oops!
2361 } 2362 DCHECK(was_resumed);
2362 2363
2363 IncrementOutstandingRequestsMemory(-1, *info); 2364 IncrementOutstandingRequestsMemory(-1, *info);
2364 2365
2365 // A ResourceHandler must not outlive its associated URLRequest. 2366 // A ResourceHandler must not outlive its associated URLRequest.
2366 handler.reset(); 2367 handler.reset();
2367 return; 2368 return;
2368 } 2369 }
2369 2370
2370 std::unique_ptr<ResourceLoader> loader(new ResourceLoader( 2371 std::unique_ptr<ResourceLoader> loader(new ResourceLoader(
2371 std::move(request), std::move(handler), this)); 2372 std::move(request), std::move(handler), this));
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
2800 &throttles); 2801 &throttles);
2801 if (!throttles.empty()) { 2802 if (!throttles.empty()) {
2802 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, 2803 handler.reset(new ThrottlingResourceHandler(std::move(handler), request,
2803 std::move(throttles))); 2804 std::move(throttles)));
2804 } 2805 }
2805 } 2806 }
2806 return handler; 2807 return handler;
2807 } 2808 }
2808 2809
2809 } // namespace content 2810 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698