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 2be9669db0f09c60e6a4dd0b469594c0547e92c0..b3a4edcaf56da346ea1902d8f4b216b400106420 100644 |
--- a/chrome/browser/chromeos/drive/job_scheduler.cc |
+++ b/chrome/browser/chromeos/drive/job_scheduler.cc |
@@ -3,6 +3,8 @@ |
// found in the LICENSE file. |
#include "chrome/browser/chromeos/drive/job_scheduler.h" |
+ |
+#include <algorithm> |
#include "base/files/file_util.h" |
#include "base/message_loop/message_loop.h" |
@@ -742,7 +744,9 @@ |
const JobInfo& job_info = job_entry->job_info; |
const QueueType queue_type = GetJobQueueType(job_info.job_type); |
- queue_[queue_type]->Push(job_id, job_entry->context.type, false, |
+ const bool batchable = job_info.job_type == TYPE_UPLOAD_EXISTING_FILE || |
+ job_info.job_type == TYPE_UPLOAD_NEW_FILE; |
+ queue_[queue_type]->Push(job_id, job_entry->context.type, batchable, |
job_info.num_total_bytes); |
// Temporary histogram for crbug.com/229650. |
@@ -802,25 +806,28 @@ |
if (job_ids.empty()) |
return; |
- // TODO(hirono): Currently all requests are not batchable. So the queue always |
- // return just 1 job. |
- DCHECK_EQ(1u, job_ids.size()); |
- JobEntry* entry = job_map_.Lookup(job_ids.front()); |
- DCHECK(entry); |
- |
- JobInfo* job_info = &entry->job_info; |
- job_info->state = STATE_RUNNING; |
- job_info->start_time = now; |
- NotifyJobUpdated(*job_info); |
- |
- entry->cancel_callback = entry->task.Run(); |
+ if (job_ids.size() > 1) |
+ uploader_->StartBatchProcessing(); |
+ |
+ for (JobID job_id : job_ids) { |
+ JobEntry* entry = job_map_.Lookup(job_id); |
+ DCHECK(entry); |
+ |
+ JobInfo* job_info = &entry->job_info; |
+ job_info->state = STATE_RUNNING; |
+ job_info->start_time = now; |
+ NotifyJobUpdated(*job_info); |
+ |
+ entry->cancel_callback = entry->task.Run(); |
+ logger_->Log(logging::LOG_INFO, "Job started: %s - %s", |
+ job_info->ToString().c_str(), |
+ GetQueueInfo(queue_type).c_str()); |
+ } |
+ |
+ if (job_ids.size() > 1) |
+ uploader_->StopBatchProcessing(); |
UpdateWait(); |
- |
- logger_->Log(logging::LOG_INFO, |
- "Job started: %s - %s", |
- job_info->ToString().c_str(), |
- GetQueueInfo(queue_type).c_str()); |
} |
int JobScheduler::GetCurrentAcceptedPriority(QueueType queue_type) { |