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

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

Issue 1145013004: Introduce bad_message.h for chrome and NaCl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove newline Created 5 years, 7 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 <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/bind_helpers.h" 14 #include "base/bind_helpers.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
17 #include "base/debug/alias.h" 17 #include "base/debug/alias.h"
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/memory/scoped_ptr.h" 19 #include "base/memory/scoped_ptr.h"
20 #include "base/memory/shared_memory.h" 20 #include "base/memory/shared_memory.h"
21 #include "base/message_loop/message_loop.h" 21 #include "base/message_loop/message_loop.h"
22 #include "base/metrics/histogram_macros.h" 22 #include "base/metrics/histogram_macros.h"
23 #include "base/metrics/sparse_histogram.h" 23 #include "base/metrics/sparse_histogram.h"
24 #include "base/profiler/scoped_tracker.h" 24 #include "base/profiler/scoped_tracker.h"
25 #include "base/stl_util.h" 25 #include "base/stl_util.h"
26 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 26 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
27 #include "base/time/time.h" 27 #include "base/time/time.h"
28 #include "content/browser/appcache/appcache_interceptor.h" 28 #include "content/browser/appcache/appcache_interceptor.h"
29 #include "content/browser/appcache/chrome_appcache_service.h" 29 #include "content/browser/appcache/chrome_appcache_service.h"
30 #include "content/browser/bad_message.h"
30 #include "content/browser/cert_store_impl.h" 31 #include "content/browser/cert_store_impl.h"
31 #include "content/browser/child_process_security_policy_impl.h" 32 #include "content/browser/child_process_security_policy_impl.h"
32 #include "content/browser/download/download_resource_handler.h" 33 #include "content/browser/download/download_resource_handler.h"
33 #include "content/browser/download/save_file_manager.h" 34 #include "content/browser/download/save_file_manager.h"
34 #include "content/browser/download/save_file_resource_handler.h" 35 #include "content/browser/download/save_file_resource_handler.h"
35 #include "content/browser/fileapi/chrome_blob_storage_context.h" 36 #include "content/browser/fileapi/chrome_blob_storage_context.h"
36 #include "content/browser/frame_host/navigation_request_info.h" 37 #include "content/browser/frame_host/navigation_request_info.h"
37 #include "content/browser/frame_host/navigator.h" 38 #include "content/browser/frame_host/navigator.h"
38 #include "content/browser/loader/async_resource_handler.h" 39 #include "content/browser/loader/async_resource_handler.h"
39 #include "content/browser/loader/buffered_resource_handler.h" 40 #include "content/browser/loader/buffered_resource_handler.h"
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 int request_id, 1126 int request_id,
1126 const ResourceHostMsg_Request& request_data, 1127 const ResourceHostMsg_Request& request_data,
1127 IPC::Message* sync_result, // only valid for sync 1128 IPC::Message* sync_result, // only valid for sync
1128 int route_id) { 1129 int route_id) {
1129 int process_type = filter_->process_type(); 1130 int process_type = filter_->process_type();
1130 int child_id = filter_->child_id(); 1131 int child_id = filter_->child_id();
1131 1132
1132 // Reject invalid priority. 1133 // Reject invalid priority.
1133 if (request_data.priority < net::MINIMUM_PRIORITY || 1134 if (request_data.priority < net::MINIMUM_PRIORITY ||
1134 request_data.priority > net::MAXIMUM_PRIORITY) { 1135 request_data.priority > net::MAXIMUM_PRIORITY) {
1135 RecordAction(base::UserMetricsAction("BadMessageTerminate_RDH")); 1136 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_INVALID_PRIORITY);
1136 filter_->BadMessageReceived();
1137 return; 1137 return;
1138 } 1138 }
1139 1139
1140 // If we crash here, figure out what URL the renderer was requesting. 1140 // If we crash here, figure out what URL the renderer was requesting.
1141 // http://crbug.com/91398 1141 // http://crbug.com/91398
1142 char url_buf[128]; 1142 char url_buf[128];
1143 base::strlcpy(url_buf, request_data.url.spec().c_str(), arraysize(url_buf)); 1143 base::strlcpy(url_buf, request_data.url.spec().c_str(), arraysize(url_buf));
1144 base::debug::Alias(url_buf); 1144 base::debug::Alias(url_buf);
1145 1145
1146 // If the request that's coming in is being transferred from another process, 1146 // If the request that's coming in is being transferred from another process,
1147 // we want to reuse and resume the old loader rather than start a new one. 1147 // we want to reuse and resume the old loader rather than start a new one.
1148 LoaderMap::iterator it = pending_loaders_.find( 1148 LoaderMap::iterator it = pending_loaders_.find(
1149 GlobalRequestID(request_data.transferred_request_child_id, 1149 GlobalRequestID(request_data.transferred_request_child_id,
1150 request_data.transferred_request_request_id)); 1150 request_data.transferred_request_request_id));
1151 if (it != pending_loaders_.end()) { 1151 if (it != pending_loaders_.end()) {
1152 // If the request is transferring to a new process, we can update our 1152 // If the request is transferring to a new process, we can update our
1153 // state and let it resume with its existing ResourceHandlers. 1153 // state and let it resume with its existing ResourceHandlers.
1154 if (it->second->is_transferring()) { 1154 if (it->second->is_transferring()) {
1155 linked_ptr<ResourceLoader> deferred_loader = it->second; 1155 linked_ptr<ResourceLoader> deferred_loader = it->second;
1156 UpdateRequestForTransfer(child_id, route_id, request_id, 1156 UpdateRequestForTransfer(child_id, route_id, request_id,
1157 request_data, deferred_loader); 1157 request_data, deferred_loader);
1158 1158
1159 deferred_loader->CompleteTransfer(); 1159 deferred_loader->CompleteTransfer();
1160 } else { 1160 } else {
1161 RecordAction(base::UserMetricsAction("BadMessageTerminate_RDH")); 1161 bad_message::ReceivedBadMessage(
1162 filter_->BadMessageReceived(); 1162 filter_, bad_message::RDH_REQUEST_NOT_TRANSFERRING);
1163 } 1163 }
1164 return; 1164 return;
1165 } 1165 }
1166 1166
1167 ResourceContext* resource_context = NULL; 1167 ResourceContext* resource_context = NULL;
1168 net::URLRequestContext* request_context = NULL; 1168 net::URLRequestContext* request_context = NULL;
1169 filter_->GetContexts(request_data, &resource_context, &request_context); 1169 filter_->GetContexts(request_data, &resource_context, &request_context);
1170 // http://crbug.com/90971 1170 // http://crbug.com/90971
1171 CHECK(ContainsKey(active_resource_contexts_, resource_context)); 1171 CHECK(ContainsKey(active_resource_contexts_, resource_context));
1172 1172
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 ResourceContext* resource_context) { 1349 ResourceContext* resource_context) {
1350 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed. 1350 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed.
1351 tracked_objects::ScopedTracker tracking_profile( 1351 tracked_objects::ScopedTracker tracking_profile(
1352 FROM_HERE_WITH_EXPLICIT_FUNCTION( 1352 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1353 "456331 ResourceDispatcherHostImpl::CreateResourceHandler")); 1353 "456331 ResourceDispatcherHostImpl::CreateResourceHandler"));
1354 // Construct the IPC resource handler. 1354 // Construct the IPC resource handler.
1355 scoped_ptr<ResourceHandler> handler; 1355 scoped_ptr<ResourceHandler> handler;
1356 if (sync_result) { 1356 if (sync_result) {
1357 // download_to_file is not supported for synchronous requests. 1357 // download_to_file is not supported for synchronous requests.
1358 if (request_data.download_to_file) { 1358 if (request_data.download_to_file) {
1359 RecordAction(base::UserMetricsAction("BadMessageTerminate_RDH")); 1359 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_BAD_DOWNLOAD);
1360 filter_->BadMessageReceived();
1361 return scoped_ptr<ResourceHandler>(); 1360 return scoped_ptr<ResourceHandler>();
1362 } 1361 }
1363 1362
1364 handler.reset(new SyncResourceHandler(request, sync_result, this)); 1363 handler.reset(new SyncResourceHandler(request, sync_result, this));
1365 } else { 1364 } else {
1366 handler.reset(new AsyncResourceHandler(request, this)); 1365 handler.reset(new AsyncResourceHandler(request, this));
1367 1366
1368 // The RedirectToFileResourceHandler depends on being next in the chain. 1367 // The RedirectToFileResourceHandler depends on being next in the chain.
1369 if (request_data.download_to_file) { 1368 if (request_data.download_to_file) {
1370 handler.reset( 1369 handler.reset(
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
2369 2368
2370 // Add a flag to selectively bypass the data reduction proxy if the resource 2369 // Add a flag to selectively bypass the data reduction proxy if the resource
2371 // type is not an image. 2370 // type is not an image.
2372 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) 2371 if (request_data.resource_type != RESOURCE_TYPE_IMAGE)
2373 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; 2372 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY;
2374 2373
2375 return load_flags; 2374 return load_flags;
2376 } 2375 }
2377 2376
2378 } // namespace content 2377 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698