Index: chrome/browser/chromeos/drive/job_scheduler.cc |
diff --git a/chrome/browser/chromeos/drive/job_scheduler.cc b/chrome/browser/chromeos/drive/job_scheduler.cc |
index 13aa7df2d4e9296ca1b1eea5045157cb2d0245cb..61f8d3009641022f596bd7c939b9947b6d6a24b4 100644 |
--- a/chrome/browser/chromeos/drive/job_scheduler.cc |
+++ b/chrome/browser/chromeos/drive/job_scheduler.cc |
@@ -704,7 +704,16 @@ void JobScheduler::StartJob(JobEntry* job) { |
DCHECK(!job->task.is_null()); |
QueueJob(job->job_info.job_id); |
+ QueueType queue_type = GetJobQueueType(job->job_info.job_type); |
+ job->job_info.num_total_jobs = queue_[queue_type]->GetNumberOfJobs(); |
+ if (queue_type == FILE_QUEUE) { |
+ job->job_info.state = STATE_NEW; |
+ } |
NotifyJobAdded(job->job_info); |
+ if (job->job_info.num_total_jobs == 1) { |
+ base::TimeDelta delay = base::TimeDelta::FromMilliseconds(500); |
hirono
2014/08/27 08:37:20
It looks to affect actual performance.
Can we dela
iseki
2014/08/28 07:13:32
Done.
|
+ wait_until_ = std::max(wait_until_, base::Time::Now() + delay); |
+ } |
DoJobLoop(GetJobQueueType(job->job_info.job_type)); |
} |
@@ -766,6 +775,7 @@ void JobScheduler::DoJobLoop(QueueType queue_type) { |
JobInfo* job_info = &entry->job_info; |
job_info->state = STATE_RUNNING; |
job_info->start_time = now; |
+ job_info->num_total_jobs = queue_[queue_type]->GetNumberOfJobs(); |
NotifyJobUpdated(*job_info); |
entry->cancel_callback = entry->task.Run(); |
@@ -853,6 +863,8 @@ bool JobScheduler::OnJobDone(JobID job_id, google_apis::GDataErrorCode error) { |
if (should_retry) { |
job_entry->cancel_callback.Reset(); |
job_info->state = STATE_RETRY; |
+ QueueType queue_type = GetJobQueueType(job_info->job_type); |
+ job_info->num_total_jobs = queue_[queue_type]->GetNumberOfJobs(); |
NotifyJobUpdated(*job_info); |
++job_entry->retry_count; |
@@ -860,6 +872,8 @@ bool JobScheduler::OnJobDone(JobID job_id, google_apis::GDataErrorCode error) { |
// Requeue the job. |
QueueJob(job_id); |
} else { |
+ QueueType queue_type = GetJobQueueType(job_info->job_type); |
+ job_info->num_total_jobs = queue_[queue_type]->GetNumberOfJobs(); |
NotifyJobDone(*job_info, error); |
// The job has finished, no retry will happen in the scheduler. Now we can |
// remove the job info from the map. |
@@ -1037,6 +1051,8 @@ void JobScheduler::UpdateProgress(JobID job_id, int64 progress, int64 total) { |
job_entry->job_info.num_completed_bytes = progress; |
if (total != -1) |
job_entry->job_info.num_total_bytes = total; |
+ QueueType queue_type = GetJobQueueType(job_entry->job_info.job_type); |
+ job_entry->job_info.num_total_jobs = queue_[queue_type]->GetNumberOfJobs(); |
NotifyJobUpdated(job_entry->job_info); |
} |
@@ -1098,6 +1114,7 @@ void JobScheduler::AbortNotRunningJob(JobEntry* job, |
base::Callback<void(google_apis::GDataErrorCode)> callback = |
job->abort_callback; |
queue_[GetJobQueueType(job->job_info.job_type)]->Remove(job->job_info.job_id); |
+ job->job_info.num_total_jobs = queue_[queue_type]->GetNumberOfJobs(); |
NotifyJobDone(job->job_info, error); |
job_map_.Remove(job->job_info.job_id); |
base::MessageLoopProxy::current()->PostTask(FROM_HERE, |