Index: content/browser/renderer_host/resource_dispatcher_host.cc |
diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host.cc |
index 24ef6825bfd520b7177f8b5f97cb61a6294aaa40..206059e9e7a0cc022e08ec1dad357cb3b3cb738a 100644 |
--- a/content/browser/renderer_host/resource_dispatcher_host.cc |
+++ b/content/browser/renderer_host/resource_dispatcher_host.cc |
@@ -18,7 +18,6 @@ |
#include "base/metrics/histogram.h" |
#include "base/shared_memory.h" |
#include "base/stl_util.h" |
-#include "base/time.h" |
#include "chrome/browser/download/download_file_manager.h" |
#include "chrome/browser/download/download_manager.h" |
#include "chrome/browser/download/download_request_limiter.h" |
@@ -116,6 +115,11 @@ const int kMaxPendingDataMessages = 20; |
// This bound is 25MB, which allows for around 6000 outstanding requests. |
const int kMaxOutstandingRequestsCostPerProcess = 26214400; |
+// The number of milliseconds after noting a user gesture that we will |
+// tag newly-created URLRequest objects with the |
+// NET_MAYBE_USER_GESTURE load flag. |
yzshen1
2011/08/05 21:50:41
1) NET_MAYBE_USER_GESTURE -> LOAD_MAYBE_USER_GESTU
Jói
2011/08/08 17:09:45
1) Done.
2) See updated comment for this constant
|
+const int kUserGestureWindowMs = 3500; |
+ |
// All possible error codes from the network module. Note that the error codes |
// are all positive (since histograms expect positive sample values). |
const int kAllNetErrorCodes[] = { |
@@ -1409,6 +1413,12 @@ void ResourceDispatcherHost::BeginRequestInternal(net::URLRequest* request) { |
DCHECK(!request->is_pending()); |
ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); |
+ if ((TimeTicks::Now() - last_user_gesture_time_) < |
+ TimeDelta::FromMilliseconds(kUserGestureWindowMs)) { |
+ request->set_load_flags( |
+ request->load_flags() | net::LOAD_MAYBE_USER_GESTURE); |
+ } |
+ |
// Add the memory estimate that starting this request will consume. |
info->set_memory_cost(CalculateApproximateMemoryCost(request)); |
int memory_cost = IncrementOutstandingRequestsMemoryCost(info->memory_cost(), |
@@ -1674,6 +1684,12 @@ void ResourceDispatcherHost::OnResponseCompleted(net::URLRequest* request) { |
// call until later. We will notify the world and clean up when we resume. |
} |
+void ResourceDispatcherHost::OnUserGesture(TabContents* tab) { |
+ download_request_limiter()->OnUserGesture(tab); |
+ |
+ last_user_gesture_time_ = TimeTicks::Now(); |
+} |
+ |
// static |
ResourceDispatcherHostRequestInfo* ResourceDispatcherHost::InfoForRequest( |
net::URLRequest* request) { |