Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: chrome/browser/chromeos/drive/job_scheduler.cc

Issue 1138883004: Revert of Revert of Drive: Let DriveUploader use batch request API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/drive/job_queue.cc ('k') | chrome/browser/drive/drive_uploader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « chrome/browser/chromeos/drive/job_queue.cc ('k') | chrome/browser/drive/drive_uploader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698