Index: chrome/browser/chromeos/drive/drive_scheduler.cc |
diff --git a/chrome/browser/chromeos/drive/drive_scheduler.cc b/chrome/browser/chromeos/drive/drive_scheduler.cc |
index bbf055c4d368446437f380574c973e20c784d2fc..223fe723b7e16b983b5597365e02ae09423b49a9 100644 |
--- a/chrome/browser/chromeos/drive/drive_scheduler.cc |
+++ b/chrome/browser/chromeos/drive/drive_scheduler.cc |
@@ -34,23 +34,16 @@ DriveScheduler::JobInfo::JobInfo(JobType in_job_type, FilePath in_file_path) |
} |
DriveScheduler::QueueEntry::QueueEntry(JobType in_job_type, |
- FilePath in_file_path) |
- : job_info(TYPE_REMOVE, in_file_path) { |
+ FilePath in_file_path, |
+ FileOperationCallback in_callback) |
+ : job_info(in_job_type, in_file_path), |
+ callback(in_callback), |
+ is_recursive(false) { |
} |
DriveScheduler::QueueEntry::~QueueEntry() { |
} |
-DriveScheduler::RemoveJobPrivate::RemoveJobPrivate( |
- bool in_is_recursive, |
- FileOperationCallback in_callback) |
- : is_recursive(in_is_recursive), |
- callback(in_callback) { |
-} |
- |
-DriveScheduler::RemoveJobPrivate::~RemoveJobPrivate() { |
-} |
- |
DriveScheduler::DriveScheduler(Profile* profile, |
file_system::DriveOperations* drive_operations) |
: job_loop_is_running_(false), |
@@ -75,14 +68,26 @@ void DriveScheduler::Initialize() { |
net::NetworkChangeNotifier::AddConnectionTypeObserver(this); |
} |
+void DriveScheduler::Move(const FilePath& src_file_path, |
+ const FilePath& dest_file_path, |
+ const FileOperationCallback& callback) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ |
+ QueueEntry* new_job = new QueueEntry(TYPE_MOVE, src_file_path, callback); |
satorux1
2012/10/16 04:34:01
This made me think how the object is deleted. This
Zachary Kuznia
2012/10/16 04:59:10
Done.
|
+ new_job->dest_file_path = dest_file_path; |
+ |
+ QueueJob(new_job); |
+ |
+ StartJobLoop(); |
+} |
void DriveScheduler::Remove(const FilePath& file_path, |
bool is_recursive, |
const FileOperationCallback& callback) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
- QueueEntry* new_job = new QueueEntry(TYPE_REMOVE, file_path); |
- new_job->remove_private.reset(new RemoveJobPrivate(is_recursive, callback)); |
+ QueueEntry* new_job = new QueueEntry(TYPE_REMOVE, file_path, callback); |
satorux1
2012/10/16 04:34:01
ditto.
Zachary Kuznia
2012/10/16 04:59:10
Done.
|
+ new_job->is_recursive = is_recursive; |
QueueJob(new_job); |
@@ -132,13 +137,21 @@ void DriveScheduler::DoJobLoop() { |
job_info.state = STATE_RUNNING; |
switch (job_info.job_type) { |
- case TYPE_REMOVE: { |
- DCHECK(job_iter->second->remove_private.get()); |
+ case TYPE_MOVE: { |
+ drive_operations_->Move( |
+ job_info.file_path, |
+ job_iter->second->dest_file_path, |
+ base::Bind(&DriveScheduler::OnJobDone, |
+ weak_ptr_factory_.GetWeakPtr(), |
+ job_id)); |
+ } |
+ break; |
+ case TYPE_REMOVE: { |
drive_operations_->Remove( |
job_info.file_path, |
- job_iter->second->remove_private->is_recursive, |
- base::Bind(&DriveScheduler::OnRemoveDone, |
+ job_iter->second->is_recursive, |
+ base::Bind(&DriveScheduler::OnJobDone, |
weak_ptr_factory_.GetWeakPtr(), |
job_id)); |
} |
@@ -197,7 +210,7 @@ void DriveScheduler::ResetThrottleAndContinueJobLoop() { |
DoJobLoop(); |
} |
-void DriveScheduler::OnRemoveDone(int job_id, DriveFileError error) { |
+void DriveScheduler::OnJobDone(int job_id, DriveFileError error) { |
JobMap::iterator job_iter = job_info_.find(job_id); |
DCHECK(job_iter != job_info_.end()); |
@@ -210,12 +223,10 @@ void DriveScheduler::OnRemoveDone(int job_id, DriveFileError error) { |
queue_.push_back(job_id); |
ThrottleAndContinueJobLoop(); |
} else { |
- DCHECK(job_iter->second->remove_private.get()); |
- |
// Handle the callback. |
- if (!job_iter->second->remove_private->callback.is_null()) { |
+ if (!job_iter->second->callback.is_null()) { |
MessageLoop::current()->PostTask(FROM_HERE, |
- base::Bind(job_iter->second->remove_private->callback, error)); |
+ base::Bind(job_iter->second->callback, error)); |
} |
// Delete the job. |