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

Side by Side Diff: chrome/browser/chromeos/drive/drive_scheduler.cc

Issue 11280140: Pass calls to GetApplicationInfo through the scheduler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/drive/drive_scheduler.h" 5 #include "chrome/browser/chromeos/drive/drive_scheduler.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 // Initialize() may be called more than once for the lifetime when the 70 // Initialize() may be called more than once for the lifetime when the
71 // file system is remounted. 71 // file system is remounted.
72 if (initialized_) 72 if (initialized_)
73 return; 73 return;
74 74
75 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); 75 net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
76 initialized_ = true; 76 initialized_ = true;
77 } 77 }
78 78
79 void DriveScheduler::GetApplicationInfo(
80 const google_apis::GetDataCallback& callback) {
81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
82
83 scoped_ptr<QueueEntry> new_job(
84 new QueueEntry(TYPE_GET_APPLICATION_INFO, FilePath()));
85 new_job->get_data_callback = callback;
86
87 QueueJob(new_job.Pass());
88
89 StartJobLoop();
90 }
91
79 void DriveScheduler::Copy(const FilePath& src_file_path, 92 void DriveScheduler::Copy(const FilePath& src_file_path,
80 const FilePath& dest_file_path, 93 const FilePath& dest_file_path,
81 const FileOperationCallback& callback) { 94 const FileOperationCallback& callback) {
82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
83 96
84 scoped_ptr<QueueEntry> new_job(new QueueEntry(TYPE_COPY, src_file_path)); 97 scoped_ptr<QueueEntry> new_job(new QueueEntry(TYPE_COPY, src_file_path));
85 new_job->dest_file_path = dest_file_path; 98 new_job->dest_file_path = dest_file_path;
86 new_job->file_operation_callback = callback; 99 new_job->file_operation_callback = callback;
87 100
88 QueueJob(new_job.Pass()); 101 QueueJob(new_job.Pass());
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 queue_.pop_front(); 239 queue_.pop_front();
227 240
228 JobMap::iterator job_iter = job_info_map_.find(job_id); 241 JobMap::iterator job_iter = job_info_map_.find(job_id);
229 DCHECK(job_iter != job_info_map_.end()); 242 DCHECK(job_iter != job_info_map_.end());
230 243
231 JobInfo& job_info = job_iter->second->job_info; 244 JobInfo& job_info = job_iter->second->job_info;
232 job_info.state = STATE_RUNNING; 245 job_info.state = STATE_RUNNING;
233 const QueueEntry* queue_entry = job_iter->second.get(); 246 const QueueEntry* queue_entry = job_iter->second.get();
234 247
235 switch (job_info.job_type) { 248 switch (job_info.job_type) {
249 case TYPE_GET_APPLICATION_INFO: {
250 drive_service_->GetApplicationInfo(
251 base::Bind(&DriveScheduler::OnGetDataJobDone,
252 weak_ptr_factory_.GetWeakPtr(),
253 job_id));
254 }
255 break;
256
236 case TYPE_COPY: { 257 case TYPE_COPY: {
237 drive_operations_->Copy( 258 drive_operations_->Copy(
238 job_info.file_path, 259 job_info.file_path,
239 queue_entry->dest_file_path, 260 queue_entry->dest_file_path,
240 base::Bind(&DriveScheduler::OnFileOperationJobDone, 261 base::Bind(&DriveScheduler::OnFileOperationJobDone,
241 weak_ptr_factory_.GetWeakPtr(), 262 weak_ptr_factory_.GetWeakPtr(),
242 job_id)); 263 job_id));
243 } 264 }
244 break; 265 break;
245 266
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 450 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
430 451
431 // Resume the job loop if the network is back online. Note that we don't 452 // Resume the job loop if the network is back online. Note that we don't
432 // need to check the type of the network as it will be checked in 453 // need to check the type of the network as it will be checked in
433 // ShouldStopJobLoop() as soon as the loop is resumed. 454 // ShouldStopJobLoop() as soon as the loop is resumed.
434 if (!net::NetworkChangeNotifier::IsOffline()) 455 if (!net::NetworkChangeNotifier::IsOffline())
435 StartJobLoop(); 456 StartJobLoop();
436 } 457 }
437 458
438 } // namespace drive 459 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/drive_scheduler.h ('k') | chrome/browser/chromeos/drive/drive_scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698