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

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

Issue 309463002: drive: Change DriveServiceInterface::GetChangeList's callback type to ChangeListCallback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/drive/job_scheduler.h ('k') | chrome/browser/drive/drive_api_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/job_scheduler.h" 5 #include "chrome/browser/chromeos/drive/job_scheduler.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "chrome/browser/chromeos/drive/file_system_util.h" 12 #include "chrome/browser/chromeos/drive/file_system_util.h"
13 #include "chrome/browser/drive/drive_api_util.h"
13 #include "chrome/browser/drive/event_logger.h" 14 #include "chrome/browser/drive/event_logger.h"
14 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
15 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
16 #include "google_apis/drive/drive_api_parser.h" 17 #include "google_apis/drive/drive_api_parser.h"
17 18
18 using content::BrowserThread; 19 using content::BrowserThread;
19 20
20 namespace drive { 21 namespace drive {
21 22
22 namespace { 23 namespace {
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 int64 start_changestamp, 328 int64 start_changestamp,
328 const google_apis::GetResourceListCallback& callback) { 329 const google_apis::GetResourceListCallback& callback) {
329 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 330 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
330 DCHECK(!callback.is_null()); 331 DCHECK(!callback.is_null());
331 332
332 JobEntry* new_job = CreateNewJob(TYPE_GET_CHANGE_LIST); 333 JobEntry* new_job = CreateNewJob(TYPE_GET_CHANGE_LIST);
333 new_job->task = base::Bind( 334 new_job->task = base::Bind(
334 &DriveServiceInterface::GetChangeList, 335 &DriveServiceInterface::GetChangeList,
335 base::Unretained(drive_service_), 336 base::Unretained(drive_service_),
336 start_changestamp, 337 start_changestamp,
337 base::Bind(&JobScheduler::OnGetResourceListJobDone, 338 base::Bind(&JobScheduler::OnGetChangeListJobDone,
338 weak_ptr_factory_.GetWeakPtr(), 339 weak_ptr_factory_.GetWeakPtr(),
339 new_job->job_info.job_id, 340 new_job->job_info.job_id,
340 callback)); 341 callback));
341 new_job->abort_callback = CreateErrorRunCallback(callback); 342 new_job->abort_callback = CreateErrorRunCallback(callback);
342 StartJob(new_job); 343 StartJob(new_job);
343 } 344 }
344 345
345 void JobScheduler::GetRemainingChangeList( 346 void JobScheduler::GetRemainingChangeList(
346 const GURL& next_link, 347 const GURL& next_link,
347 const google_apis::GetResourceListCallback& callback) { 348 const google_apis::GetResourceListCallback& callback) {
348 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 349 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
349 DCHECK(!callback.is_null()); 350 DCHECK(!callback.is_null());
350 351
351 JobEntry* new_job = CreateNewJob(TYPE_GET_REMAINING_CHANGE_LIST); 352 JobEntry* new_job = CreateNewJob(TYPE_GET_REMAINING_CHANGE_LIST);
352 new_job->task = base::Bind( 353 new_job->task = base::Bind(
353 &DriveServiceInterface::GetRemainingChangeList, 354 &DriveServiceInterface::GetRemainingChangeList,
354 base::Unretained(drive_service_), 355 base::Unretained(drive_service_),
355 next_link, 356 next_link,
356 base::Bind(&JobScheduler::OnGetResourceListJobDone, 357 base::Bind(&JobScheduler::OnGetChangeListJobDone,
357 weak_ptr_factory_.GetWeakPtr(), 358 weak_ptr_factory_.GetWeakPtr(),
358 new_job->job_info.job_id, 359 new_job->job_info.job_id,
359 callback)); 360 callback));
360 new_job->abort_callback = CreateErrorRunCallback(callback); 361 new_job->abort_callback = CreateErrorRunCallback(callback);
361 StartJob(new_job); 362 StartJob(new_job);
362 } 363 }
363 364
364 void JobScheduler::GetRemainingFileList( 365 void JobScheduler::GetRemainingFileList(
365 const GURL& next_link, 366 const GURL& next_link,
366 const google_apis::GetResourceListCallback& callback) { 367 const google_apis::GetResourceListCallback& callback) {
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 892
892 // Post a task to continue the job loop. This allows us to finish handling 893 // Post a task to continue the job loop. This allows us to finish handling
893 // the current job before starting the next one. 894 // the current job before starting the next one.
894 base::MessageLoopProxy::current()->PostTask(FROM_HERE, 895 base::MessageLoopProxy::current()->PostTask(FROM_HERE,
895 base::Bind(&JobScheduler::DoJobLoop, 896 base::Bind(&JobScheduler::DoJobLoop,
896 weak_ptr_factory_.GetWeakPtr(), 897 weak_ptr_factory_.GetWeakPtr(),
897 queue_type)); 898 queue_type));
898 return !should_retry; 899 return !should_retry;
899 } 900 }
900 901
902 void JobScheduler::OnGetChangeListJobDone(
903 JobID job_id,
904 const google_apis::GetResourceListCallback& callback,
905 google_apis::GDataErrorCode error,
906 scoped_ptr<google_apis::ChangeList> change_list) {
907 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
908 DCHECK(!callback.is_null());
909
910 if (OnJobDone(job_id, error)) {
911 callback.Run(error, change_list ?
912 util::ConvertChangeListToResourceList(*change_list) :
913 scoped_ptr<google_apis::ResourceList>());
914
915 }
916 }
917
901 void JobScheduler::OnGetResourceListJobDone( 918 void JobScheduler::OnGetResourceListJobDone(
902 JobID job_id, 919 JobID job_id,
903 const google_apis::GetResourceListCallback& callback, 920 const google_apis::GetResourceListCallback& callback,
904 google_apis::GDataErrorCode error, 921 google_apis::GDataErrorCode error,
905 scoped_ptr<google_apis::ResourceList> resource_list) { 922 scoped_ptr<google_apis::ResourceList> resource_list) {
906 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 923 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
907 DCHECK(!callback.is_null()); 924 DCHECK(!callback.is_null());
908 925
909 if (OnJobDone(job_id, error)) 926 if (OnJobDone(job_id, error))
910 callback.Run(error, resource_list.Pass()); 927 callback.Run(error, resource_list.Pass());
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 case FILE_QUEUE: 1162 case FILE_QUEUE:
1146 return "FILE_QUEUE"; 1163 return "FILE_QUEUE";
1147 case NUM_QUEUES: 1164 case NUM_QUEUES:
1148 break; // This value is just a sentinel. Should never be used. 1165 break; // This value is just a sentinel. Should never be used.
1149 } 1166 }
1150 NOTREACHED(); 1167 NOTREACHED();
1151 return ""; 1168 return "";
1152 } 1169 }
1153 1170
1154 } // namespace drive 1171 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/job_scheduler.h ('k') | chrome/browser/drive/drive_api_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698