Commit d2ba7bcc authored by tonyg's avatar tonyg Committed by Commit bot

Shortcut a couple of IPCs when the task manager is disabled.

This saves about 6 idle wakeups on the top_10 idle energy benchmark. It can save up to 1/second in the general case.

BUG=411488

Review URL: https://codereview.chromium.org/542353002

Cr-Commit-Position: refs/heads/master@{#293813}
parent e58cfbb6
......@@ -241,6 +241,7 @@ TaskManagerModel::TaskManagerModel(TaskManager* task_manager)
update_requests_(0),
listen_requests_(0),
update_state_(IDLE),
is_updating_byte_count_(false),
goat_salt_(base::RandUint64()) {
AddResourceProvider(
new task_manager::BrowserProcessResourceProvider(task_manager));
......@@ -1055,6 +1056,10 @@ void TaskManagerModel::StartUpdating() {
FOR_EACH_OBSERVER(TaskManagerModelObserver, observer_list_,
OnReadyPeriodicalUpdate());
}
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&TaskManagerModel::SetUpdatingByteCount, this, true));
}
void TaskManagerModel::StopUpdating() {
......@@ -1070,6 +1075,10 @@ void TaskManagerModel::StopUpdating() {
// Notify resource providers that we are done updating.
StopListening();
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&TaskManagerModel::SetUpdatingByteCount, this, false));
}
void TaskManagerModel::StartListening() {
......@@ -1244,6 +1253,8 @@ void TaskManagerModel::NotifyV8HeapStats(base::ProcessId renderer_id,
void TaskManagerModel::NotifyBytesRead(const net::URLRequest& request,
int byte_count) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (!is_updating_byte_count_)
return;
// Only net::URLRequestJob instances created by the ResourceDispatcherHost
// have an associated ResourceRequestInfo and a render frame associated.
......@@ -1393,6 +1404,11 @@ void TaskManagerModel::NotifyMultipleBytesRead() {
base::Owned(bytes_read_buffer)));
}
void TaskManagerModel::SetUpdatingByteCount(bool is_updating) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
is_updating_byte_count_ = is_updating;
}
int64 TaskManagerModel::GetNetworkUsage(Resource* resource) const {
int64 net_usage = GetNetworkUsageForResource(resource);
if (net_usage == 0 && !resource->SupportNetworkUsage())
......
......@@ -450,6 +450,9 @@ class TaskManagerModel : public base::RefCountedThreadSafe<TaskManagerModel> {
// for each one is expensive.
void NotifyMultipleBytesRead();
// Called on the IO thread to start/stop updating byte counts.
void SetUpdatingByteCount(bool is_updating);
// Returns the network usage (in byte per second) that should be displayed for
// the passed |resource|. -1 means the information is not available for that
// resource.
......@@ -533,6 +536,10 @@ class TaskManagerModel : public base::RefCountedThreadSafe<TaskManagerModel> {
// Whether we are currently in the process of updating.
UpdateState update_state_;
// Whether the IO thread is currently in the process of updating; accessed
// only on the IO thread.
bool is_updating_byte_count_;
// A salt lick for the goats.
uint64 goat_salt_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment