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 7030b105a227676cd035ece266b5e28cde9fe4c2..98b7a58e9cb60f282fd3deea1002e6e1439946dc 100644 |
--- a/content/browser/renderer_host/resource_dispatcher_host.cc |
+++ b/content/browser/renderer_host/resource_dispatcher_host.cc |
@@ -1791,14 +1791,15 @@ namespace { |
// doing something that corresponds to changes that the user might observe, |
// whereas waiting for a host name to resolve implies being stuck. |
// |
-net::LoadState MoreInterestingLoadState(net::LoadState a, net::LoadState b) { |
- return (a < b) ? b : a; |
+const net::LoadStateWithParam& MoreInterestingLoadState( |
+ const net::LoadStateWithParam& a, const net::LoadStateWithParam& b) { |
+ return (a.state < b.state) ? b : a; |
} |
// Carries information about a load state change. |
struct LoadInfo { |
GURL url; |
- net::LoadState load_state; |
+ net::LoadStateWithParam load_state; |
uint64 upload_position; |
uint64 upload_size; |
}; |
@@ -1840,7 +1841,7 @@ void ResourceDispatcherHost::UpdateLoadStates() { |
net::URLRequest* request = i->second; |
ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); |
uint64 upload_size = info->upload_size(); |
- if (request->GetLoadState() != net::LOAD_STATE_SENDING_REQUEST) |
+ if (request->GetLoadState().state != net::LOAD_STATE_SENDING_REQUEST) |
upload_size = 0; |
std::pair<int, int> key(info->child_id(), info->route_id()); |
if (upload_size && largest_upload_size[key] < upload_size) |
@@ -1849,40 +1850,33 @@ void ResourceDispatcherHost::UpdateLoadStates() { |
for (i = pending_requests_.begin(); i != pending_requests_.end(); ++i) { |
net::URLRequest* request = i->second; |
- net::LoadState load_state = request->GetLoadState(); |
+ net::LoadStateWithParam load_state = request->GetLoadState(); |
ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); |
+ std::pair<int, int> key(info->child_id(), info->route_id()); |
// We also poll for upload progress on this timer and send upload |
// progress ipc messages to the plugin process. |
- bool update_upload_progress = MaybeUpdateUploadProgress(info, request); |
- |
- if (info->last_load_state() != load_state || update_upload_progress) { |
Matt Perry
2011/07/29 00:36:54
I believe this logic was wrong. Consider this scen
|
- std::pair<int, int> key(info->child_id(), info->route_id()); |
+ MaybeUpdateUploadProgress(info, request); |
- // If a request is uploading data, ignore all other requests so that the |
- // upload progress takes priority for being shown in the status bar. |
- if (largest_upload_size.find(key) != largest_upload_size.end() && |
- info->upload_size() < largest_upload_size[key]) |
+ // If a request is uploading data, ignore all other requests so that the |
+ // upload progress takes priority for being shown in the status bar. |
+ if (largest_upload_size.find(key) != largest_upload_size.end() && |
+ info->upload_size() < largest_upload_size[key]) |
+ continue; |
+ |
+ net::LoadStateWithParam to_insert = load_state; |
+ LoadInfoMap::iterator existing = info_map.find(key); |
+ if (existing != info_map.end()) { |
+ to_insert = |
+ MoreInterestingLoadState(existing->second.load_state, load_state); |
+ if (to_insert.state == existing->second.load_state.state) |
continue; |
- |
- info->set_last_load_state(load_state); |
- |
- net::LoadState to_insert; |
- LoadInfoMap::iterator existing = info_map.find(key); |
- if (existing == info_map.end()) { |
- to_insert = load_state; |
- } else { |
- to_insert = |
- MoreInterestingLoadState(existing->second.load_state, load_state); |
- if (to_insert == existing->second.load_state) |
- continue; |
- } |
- LoadInfo& load_info = info_map[key]; |
- load_info.url = request->url(); |
- load_info.load_state = to_insert; |
- load_info.upload_size = info->upload_size(); |
- load_info.upload_position = request->GetUploadProgress(); |
} |
+ LoadInfo& load_info = info_map[key]; |
+ load_info.url = request->url(); |
+ load_info.load_state = to_insert; |
+ load_info.upload_size = info->upload_size(); |
+ load_info.upload_position = request->GetUploadProgress(); |
} |
if (info_map.empty()) |
@@ -1894,18 +1888,17 @@ void ResourceDispatcherHost::UpdateLoadStates() { |
} |
// Calls the ResourceHandler to send upload progress messages to the renderer. |
-// Returns true iff an upload progress message should be sent to the UI thread. |
-bool ResourceDispatcherHost::MaybeUpdateUploadProgress( |
+void ResourceDispatcherHost::MaybeUpdateUploadProgress( |
ResourceDispatcherHostRequestInfo *info, |
net::URLRequest *request) { |
if (!info->upload_size() || info->waiting_for_upload_progress_ack()) |
- return false; |
+ return; |
uint64 size = info->upload_size(); |
uint64 position = request->GetUploadProgress(); |
if (position == info->last_upload_position()) |
- return false; // no progress made since last time |
+ return; // no progress made since last time |
const uint64 kHalfPercentIncrements = 200; |
const TimeDelta kOneSecond = TimeDelta::FromMilliseconds(1000); |
@@ -1925,9 +1918,7 @@ bool ResourceDispatcherHost::MaybeUpdateUploadProgress( |
} |
info->set_last_upload_ticks(TimeTicks::Now()); |
info->set_last_upload_position(position); |
- return true; |
} |
- return false; |
} |
void ResourceDispatcherHost::BlockRequestsForRoute(int child_id, int route_id) { |