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

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

Issue 962423002: Update instrumentation for many different bugs based on new UMA data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 // 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>
(...skipping 2015 matching lines...) Expand 10 before | Expand all | Expand 10 after
2026 request->method().size(); 2026 request->method().size();
2027 2027
2028 // Note that this expression will typically be dominated by: 2028 // Note that this expression will typically be dominated by:
2029 // |kAvgBytesPerOutstandingRequest|. 2029 // |kAvgBytesPerOutstandingRequest|.
2030 return kAvgBytesPerOutstandingRequest + strings_cost; 2030 return kAvgBytesPerOutstandingRequest + strings_cost;
2031 } 2031 }
2032 2032
2033 void ResourceDispatcherHostImpl::BeginRequestInternal( 2033 void ResourceDispatcherHostImpl::BeginRequestInternal(
2034 scoped_ptr<net::URLRequest> request, 2034 scoped_ptr<net::URLRequest> request,
2035 scoped_ptr<ResourceHandler> handler) { 2035 scoped_ptr<ResourceHandler> handler) {
2036 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed.
2037 tracked_objects::ScopedTracker tracking_profile1(
2038 FROM_HERE_WITH_EXPLICIT_FUNCTION(
2039 "456331 ResourceDispatcherHostImpl::BeginRequestInternal1"));
2040 DCHECK(!request->is_pending()); 2036 DCHECK(!request->is_pending());
2041 ResourceRequestInfoImpl* info = 2037 ResourceRequestInfoImpl* info =
2042 ResourceRequestInfoImpl::ForRequest(request.get()); 2038 ResourceRequestInfoImpl::ForRequest(request.get());
2043 2039
2044 if ((TimeTicks::Now() - last_user_gesture_time_) < 2040 if ((TimeTicks::Now() - last_user_gesture_time_) <
2045 TimeDelta::FromMilliseconds(kUserGestureWindowMs)) { 2041 TimeDelta::FromMilliseconds(kUserGestureWindowMs)) {
2046 request->SetLoadFlags( 2042 request->SetLoadFlags(
2047 request->load_flags() | net::LOAD_MAYBE_USER_GESTURE); 2043 request->load_flags() | net::LOAD_MAYBE_USER_GESTURE);
2048 } 2044 }
2049 2045
2050 // Add the memory estimate that starting this request will consume. 2046 // Add the memory estimate that starting this request will consume.
2051 info->set_memory_cost(CalculateApproximateMemoryCost(request.get())); 2047 info->set_memory_cost(CalculateApproximateMemoryCost(request.get()));
2052 2048
2053 // If enqueing/starting this request will exceed our per-process memory 2049 // If enqueing/starting this request will exceed our per-process memory
2054 // bound, abort it right away. 2050 // bound, abort it right away.
2055 OustandingRequestsStats stats = IncrementOutstandingRequestsMemory(1, *info); 2051 OustandingRequestsStats stats = IncrementOutstandingRequestsMemory(1, *info);
2056 if (stats.memory_cost > max_outstanding_requests_cost_per_process_) { 2052 if (stats.memory_cost > max_outstanding_requests_cost_per_process_) {
2057 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is
2058 // fixed.
2059 tracked_objects::ScopedTracker tracking_profile2(
2060 FROM_HERE_WITH_EXPLICIT_FUNCTION(
2061 "456331 ResourceDispatcherHostImpl::BeginRequestInternal2"));
2062 // We call "CancelWithError()" as a way of setting the net::URLRequest's 2053 // We call "CancelWithError()" as a way of setting the net::URLRequest's
2063 // status -- it has no effect beyond this, since the request hasn't started. 2054 // status -- it has no effect beyond this, since the request hasn't started.
2064 request->CancelWithError(net::ERR_INSUFFICIENT_RESOURCES); 2055 request->CancelWithError(net::ERR_INSUFFICIENT_RESOURCES);
2065 2056
2066 bool defer = false; 2057 bool defer = false;
2067 handler->OnResponseCompleted(request->status(), std::string(), &defer); 2058 handler->OnResponseCompleted(request->status(), std::string(), &defer);
2068 if (defer) { 2059 if (defer) {
2069 // TODO(darin): The handler is not ready for us to kill the request. Oops! 2060 // TODO(darin): The handler is not ready for us to kill the request. Oops!
2070 NOTREACHED(); 2061 NOTREACHED();
2071 } 2062 }
2072 2063
2073 IncrementOutstandingRequestsMemory(-1, *info); 2064 IncrementOutstandingRequestsMemory(-1, *info);
2074 2065
2075 // A ResourceHandler must not outlive its associated URLRequest. 2066 // A ResourceHandler must not outlive its associated URLRequest.
2076 handler.reset(); 2067 handler.reset();
2077 return; 2068 return;
2078 } 2069 }
2079 2070
2080 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed.
2081 tracked_objects::ScopedTracker tracking_profile3(
2082 FROM_HERE_WITH_EXPLICIT_FUNCTION(
2083 "456331 ResourceDispatcherHostImpl::BeginRequestInternal3"));
2084 linked_ptr<ResourceLoader> loader( 2071 linked_ptr<ResourceLoader> loader(
2085 new ResourceLoader(request.Pass(), handler.Pass(), this)); 2072 new ResourceLoader(request.Pass(), handler.Pass(), this));
2086 2073
2087 GlobalRoutingID id(info->GetGlobalRoutingID()); 2074 GlobalRoutingID id(info->GetGlobalRoutingID());
2088 BlockedLoadersMap::const_iterator iter = blocked_loaders_map_.find(id); 2075 BlockedLoadersMap::const_iterator iter = blocked_loaders_map_.find(id);
2089 if (iter != blocked_loaders_map_.end()) { 2076 if (iter != blocked_loaders_map_.end()) {
2090 // The request should be blocked. 2077 // The request should be blocked.
2091 iter->second->push_back(loader); 2078 iter->second->push_back(loader);
2092 return; 2079 return;
2093 } 2080 }
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
2381 2368
2382 // 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
2383 // type is not an image. 2370 // type is not an image.
2384 if (request_data.resource_type != RESOURCE_TYPE_IMAGE) 2371 if (request_data.resource_type != RESOURCE_TYPE_IMAGE)
2385 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY; 2372 load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY;
2386 2373
2387 return load_flags; 2374 return load_flags;
2388 } 2375 }
2389 2376
2390 } // namespace content 2377 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_interceptor.cc ('k') | content/browser/renderer_host/media/media_stream_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698