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

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

Issue 15650008: drive: Rename drive::DriveClientContext to drive::ClientContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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
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 <math.h> 7 #include <math.h>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 } // namespace 76 } // namespace
77 77
78 const int JobScheduler::kMaxJobCount[] = { 78 const int JobScheduler::kMaxJobCount[] = {
79 5, // METADATA_QUEUE 79 5, // METADATA_QUEUE
80 1, // FILE_QUEUE 80 1, // FILE_QUEUE
81 }; 81 };
82 82
83 JobScheduler::JobEntry::JobEntry(JobType type) 83 JobScheduler::JobEntry::JobEntry(JobType type)
84 : job_info(type), 84 : job_info(type),
85 context(DriveClientContext(USER_INITIATED)), 85 context(ClientContext(USER_INITIATED)),
86 retry_count(0) { 86 retry_count(0) {
87 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 87 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
88 } 88 }
89 89
90 JobScheduler::JobEntry::~JobEntry() { 90 JobScheduler::JobEntry::~JobEntry() {
91 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 91 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
92 } 92 }
93 93
94 struct JobScheduler::ResumeUploadParams { 94 struct JobScheduler::ResumeUploadParams {
95 base::FilePath drive_file_path; 95 base::FilePath drive_file_path;
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 feed_url, 277 feed_url,
278 base::Bind(&JobScheduler::OnGetResourceListJobDone, 278 base::Bind(&JobScheduler::OnGetResourceListJobDone,
279 weak_ptr_factory_.GetWeakPtr(), 279 weak_ptr_factory_.GetWeakPtr(),
280 new_job->job_info.job_id, 280 new_job->job_info.job_id,
281 callback)); 281 callback));
282 StartJob(new_job); 282 StartJob(new_job);
283 } 283 }
284 284
285 void JobScheduler::GetResourceEntry( 285 void JobScheduler::GetResourceEntry(
286 const std::string& resource_id, 286 const std::string& resource_id,
287 const DriveClientContext& context, 287 const ClientContext& context,
288 const google_apis::GetResourceEntryCallback& callback) { 288 const google_apis::GetResourceEntryCallback& callback) {
289 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 289 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
290 DCHECK(!callback.is_null()); 290 DCHECK(!callback.is_null());
291 291
292 JobEntry* new_job = CreateNewJob(TYPE_GET_RESOURCE_ENTRY); 292 JobEntry* new_job = CreateNewJob(TYPE_GET_RESOURCE_ENTRY);
293 new_job->context = context; 293 new_job->context = context;
294 new_job->task = base::Bind( 294 new_job->task = base::Bind(
295 &google_apis::DriveServiceInterface::GetResourceEntry, 295 &google_apis::DriveServiceInterface::GetResourceEntry,
296 base::Unretained(drive_service_), 296 base::Unretained(drive_service_),
297 resource_id, 297 resource_id,
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 weak_ptr_factory_.GetWeakPtr(), 460 weak_ptr_factory_.GetWeakPtr(),
461 new_job->job_info.job_id, 461 new_job->job_info.job_id,
462 callback)); 462 callback));
463 StartJob(new_job); 463 StartJob(new_job);
464 } 464 }
465 465
466 JobID JobScheduler::DownloadFile( 466 JobID JobScheduler::DownloadFile(
467 const base::FilePath& virtual_path, 467 const base::FilePath& virtual_path,
468 const base::FilePath& local_cache_path, 468 const base::FilePath& local_cache_path,
469 const GURL& download_url, 469 const GURL& download_url,
470 const DriveClientContext& context, 470 const ClientContext& context,
471 const google_apis::DownloadActionCallback& download_action_callback, 471 const google_apis::DownloadActionCallback& download_action_callback,
472 const google_apis::GetContentCallback& get_content_callback) { 472 const google_apis::GetContentCallback& get_content_callback) {
473 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 473 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
474 474
475 JobEntry* new_job = CreateNewJob(TYPE_DOWNLOAD_FILE); 475 JobEntry* new_job = CreateNewJob(TYPE_DOWNLOAD_FILE);
476 new_job->job_info.file_path = virtual_path; 476 new_job->job_info.file_path = virtual_path;
477 new_job->context = context; 477 new_job->context = context;
478 new_job->task = base::Bind( 478 new_job->task = base::Bind(
479 &google_apis::DriveServiceInterface::DownloadFile, 479 &google_apis::DriveServiceInterface::DownloadFile,
480 base::Unretained(drive_service_), 480 base::Unretained(drive_service_),
(...skipping 12 matching lines...) Expand all
493 StartJob(new_job); 493 StartJob(new_job);
494 return new_job->job_info.job_id; 494 return new_job->job_info.job_id;
495 } 495 }
496 496
497 void JobScheduler::UploadNewFile( 497 void JobScheduler::UploadNewFile(
498 const std::string& parent_resource_id, 498 const std::string& parent_resource_id,
499 const base::FilePath& drive_file_path, 499 const base::FilePath& drive_file_path,
500 const base::FilePath& local_file_path, 500 const base::FilePath& local_file_path,
501 const std::string& title, 501 const std::string& title,
502 const std::string& content_type, 502 const std::string& content_type,
503 const DriveClientContext& context, 503 const ClientContext& context,
504 const google_apis::GetResourceEntryCallback& callback) { 504 const google_apis::GetResourceEntryCallback& callback) {
505 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 505 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
506 506
507 JobEntry* new_job = CreateNewJob(TYPE_UPLOAD_NEW_FILE); 507 JobEntry* new_job = CreateNewJob(TYPE_UPLOAD_NEW_FILE);
508 new_job->job_info.file_path = drive_file_path; 508 new_job->job_info.file_path = drive_file_path;
509 new_job->context = context; 509 new_job->context = context;
510 510
511 UploadNewFileParams params; 511 UploadNewFileParams params;
512 params.parent_resource_id = parent_resource_id; 512 params.parent_resource_id = parent_resource_id;
513 params.drive_file_path = drive_file_path; 513 params.drive_file_path = drive_file_path;
(...skipping 18 matching lines...) Expand all
532 532
533 StartJob(new_job); 533 StartJob(new_job);
534 } 534 }
535 535
536 void JobScheduler::UploadExistingFile( 536 void JobScheduler::UploadExistingFile(
537 const std::string& resource_id, 537 const std::string& resource_id,
538 const base::FilePath& drive_file_path, 538 const base::FilePath& drive_file_path,
539 const base::FilePath& local_file_path, 539 const base::FilePath& local_file_path,
540 const std::string& content_type, 540 const std::string& content_type,
541 const std::string& etag, 541 const std::string& etag,
542 const DriveClientContext& context, 542 const ClientContext& context,
543 const google_apis::GetResourceEntryCallback& callback) { 543 const google_apis::GetResourceEntryCallback& callback) {
544 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 544 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
545 545
546 JobEntry* new_job = CreateNewJob(TYPE_UPLOAD_EXISTING_FILE); 546 JobEntry* new_job = CreateNewJob(TYPE_UPLOAD_EXISTING_FILE);
547 new_job->job_info.file_path = drive_file_path; 547 new_job->job_info.file_path = drive_file_path;
548 new_job->context = context; 548 new_job->context = context;
549 549
550 UploadExistingFileParams params; 550 UploadExistingFileParams params;
551 params.resource_id = resource_id; 551 params.resource_id = resource_id;
552 params.drive_file_path = drive_file_path; 552 params.drive_file_path = drive_file_path;
(...skipping 17 matching lines...) Expand all
570 new_job->task = base::Bind(&RunUploadExistingFile, uploader_.get(), params); 570 new_job->task = base::Bind(&RunUploadExistingFile, uploader_.get(), params);
571 571
572 StartJob(new_job); 572 StartJob(new_job);
573 } 573 }
574 574
575 void JobScheduler::CreateFile( 575 void JobScheduler::CreateFile(
576 const std::string& parent_resource_id, 576 const std::string& parent_resource_id,
577 const base::FilePath& drive_file_path, 577 const base::FilePath& drive_file_path,
578 const std::string& title, 578 const std::string& title,
579 const std::string& content_type, 579 const std::string& content_type,
580 const DriveClientContext& context, 580 const ClientContext& context,
581 const google_apis::GetResourceEntryCallback& callback) { 581 const google_apis::GetResourceEntryCallback& callback) {
582 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 582 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
583 583
584 const base::FilePath kDevNull(FILE_PATH_LITERAL("/dev/null")); 584 const base::FilePath kDevNull(FILE_PATH_LITERAL("/dev/null"));
585 585
586 JobEntry* new_job = CreateNewJob(TYPE_CREATE_FILE); 586 JobEntry* new_job = CreateNewJob(TYPE_CREATE_FILE);
587 new_job->job_info.file_path = drive_file_path; 587 new_job->job_info.file_path = drive_file_path;
588 new_job->context = context; 588 new_job->context = context;
589 589
590 UploadNewFileParams params; 590 UploadNewFileParams params;
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 case FILE_QUEUE: 958 case FILE_QUEUE:
959 return "FILE_QUEUE"; 959 return "FILE_QUEUE";
960 case NUM_QUEUES: 960 case NUM_QUEUES:
961 break; // This value is just a sentinel. Should never be used. 961 break; // This value is just a sentinel. Should never be used.
962 } 962 }
963 NOTREACHED(); 963 NOTREACHED();
964 return ""; 964 return "";
965 } 965 }
966 966
967 } // namespace drive 967 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/job_scheduler.h ('k') | chrome/browser/chromeos/drive/job_scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698