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

Side by Side Diff: components/drive/job_scheduler.cc

Issue 1546143002: Switch to standard integer types in components/, part 1 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
« no previous file with comments | « components/drive/job_scheduler.h ('k') | components/drive/job_scheduler_unittest.cc » ('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 "components/drive/job_scheduler.h" 5 #include "components/drive/job_scheduler.h"
6 6
7 #include <stddef.h>
8
7 #include <algorithm> 9 #include <algorithm>
8 10
9 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
10 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
11 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
12 #include "base/rand_util.h" 14 #include "base/rand_util.h"
13 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
15 #include "base/thread_task_runner_handle.h" 17 #include "base/thread_task_runner_handle.h"
16 #include "components/drive/drive_pref_names.h" 18 #include "components/drive/drive_pref_names.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 const ResumeUploadFileParams& params) { 133 const ResumeUploadFileParams& params) {
132 return uploader->ResumeUploadFile(params.upload_location, 134 return uploader->ResumeUploadFile(params.upload_location,
133 params.local_file_path, 135 params.local_file_path,
134 params.content_type, 136 params.content_type,
135 params.callback, 137 params.callback,
136 params.progress_callback); 138 params.progress_callback);
137 } 139 }
138 140
139 // Collects information about sizes of files copied or moved from or to Drive 141 // Collects information about sizes of files copied or moved from or to Drive
140 // Otherwise does nothing. Temporary for crbug.com/229650. 142 // Otherwise does nothing. Temporary for crbug.com/229650.
141 void CollectCopyHistogramSample(const std::string& histogram_name, int64 size) { 143 void CollectCopyHistogramSample(const std::string& histogram_name,
144 int64_t size) {
142 base::HistogramBase* const counter = 145 base::HistogramBase* const counter =
143 base::Histogram::FactoryGet(histogram_name, 146 base::Histogram::FactoryGet(histogram_name,
144 1, 147 1,
145 1024 * 1024 /* 1 GB */, 148 1024 * 1024 /* 1 GB */,
146 50, 149 50,
147 base::Histogram::kUmaTargetedHistogramFlag); 150 base::Histogram::kUmaTargetedHistogramFlag);
148 counter->Add(size / 1024); 151 counter->Add(size / 1024);
149 } 152 }
150 153
151 } // namespace 154 } // namespace
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 search_query, 331 search_query,
329 base::Bind(&JobScheduler::OnGetFileListJobDone, 332 base::Bind(&JobScheduler::OnGetFileListJobDone,
330 weak_ptr_factory_.GetWeakPtr(), 333 weak_ptr_factory_.GetWeakPtr(),
331 new_job->job_info.job_id, 334 new_job->job_info.job_id,
332 callback)); 335 callback));
333 new_job->abort_callback = CreateErrorRunCallback(callback); 336 new_job->abort_callback = CreateErrorRunCallback(callback);
334 StartJob(new_job); 337 StartJob(new_job);
335 } 338 }
336 339
337 void JobScheduler::GetChangeList( 340 void JobScheduler::GetChangeList(
338 int64 start_changestamp, 341 int64_t start_changestamp,
339 const google_apis::ChangeListCallback& callback) { 342 const google_apis::ChangeListCallback& callback) {
340 DCHECK(thread_checker_.CalledOnValidThread()); 343 DCHECK(thread_checker_.CalledOnValidThread());
341 DCHECK(!callback.is_null()); 344 DCHECK(!callback.is_null());
342 345
343 JobEntry* new_job = CreateNewJob(TYPE_GET_CHANGE_LIST); 346 JobEntry* new_job = CreateNewJob(TYPE_GET_CHANGE_LIST);
344 new_job->task = base::Bind( 347 new_job->task = base::Bind(
345 &DriveServiceInterface::GetChangeList, 348 &DriveServiceInterface::GetChangeList,
346 base::Unretained(drive_service_), 349 base::Unretained(drive_service_),
347 start_changestamp, 350 start_changestamp,
348 base::Bind(&JobScheduler::OnGetChangeListJobDone, 351 base::Bind(&JobScheduler::OnGetChangeListJobDone,
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 base::Bind(&JobScheduler::OnGetFileResourceJobDone, 571 base::Bind(&JobScheduler::OnGetFileResourceJobDone,
569 weak_ptr_factory_.GetWeakPtr(), 572 weak_ptr_factory_.GetWeakPtr(),
570 new_job->job_info.job_id, 573 new_job->job_info.job_id,
571 callback)); 574 callback));
572 new_job->abort_callback = CreateErrorRunCallback(callback); 575 new_job->abort_callback = CreateErrorRunCallback(callback);
573 StartJob(new_job); 576 StartJob(new_job);
574 } 577 }
575 578
576 JobID JobScheduler::DownloadFile( 579 JobID JobScheduler::DownloadFile(
577 const base::FilePath& virtual_path, 580 const base::FilePath& virtual_path,
578 int64 expected_file_size, 581 int64_t expected_file_size,
579 const base::FilePath& local_cache_path, 582 const base::FilePath& local_cache_path,
580 const std::string& resource_id, 583 const std::string& resource_id,
581 const ClientContext& context, 584 const ClientContext& context,
582 const google_apis::DownloadActionCallback& download_action_callback, 585 const google_apis::DownloadActionCallback& download_action_callback,
583 const google_apis::GetContentCallback& get_content_callback) { 586 const google_apis::GetContentCallback& get_content_callback) {
584 DCHECK(thread_checker_.CalledOnValidThread()); 587 DCHECK(thread_checker_.CalledOnValidThread());
585 588
586 // Temporary histogram for crbug.com/229650. 589 // Temporary histogram for crbug.com/229650.
587 CollectCopyHistogramSample("Drive.DownloadFromDriveFileSize", 590 CollectCopyHistogramSample("Drive.DownloadFromDriveFileSize",
588 expected_file_size); 591 expected_file_size);
(...skipping 15 matching lines...) Expand all
604 base::Bind(&JobScheduler::UpdateProgress, 607 base::Bind(&JobScheduler::UpdateProgress,
605 weak_ptr_factory_.GetWeakPtr(), 608 weak_ptr_factory_.GetWeakPtr(),
606 new_job->job_info.job_id)); 609 new_job->job_info.job_id));
607 new_job->abort_callback = CreateErrorRunCallback(download_action_callback); 610 new_job->abort_callback = CreateErrorRunCallback(download_action_callback);
608 StartJob(new_job); 611 StartJob(new_job);
609 return new_job->job_info.job_id; 612 return new_job->job_info.job_id;
610 } 613 }
611 614
612 void JobScheduler::UploadNewFile( 615 void JobScheduler::UploadNewFile(
613 const std::string& parent_resource_id, 616 const std::string& parent_resource_id,
614 int64 expected_file_size, 617 int64_t expected_file_size,
615 const base::FilePath& drive_file_path, 618 const base::FilePath& drive_file_path,
616 const base::FilePath& local_file_path, 619 const base::FilePath& local_file_path,
617 const std::string& title, 620 const std::string& title,
618 const std::string& content_type, 621 const std::string& content_type,
619 const UploadNewFileOptions& options, 622 const UploadNewFileOptions& options,
620 const ClientContext& context, 623 const ClientContext& context,
621 const google_apis::FileResourceCallback& callback) { 624 const google_apis::FileResourceCallback& callback) {
622 DCHECK(thread_checker_.CalledOnValidThread()); 625 DCHECK(thread_checker_.CalledOnValidThread());
623 626
624 JobEntry* new_job = CreateNewJob(TYPE_UPLOAD_NEW_FILE); 627 JobEntry* new_job = CreateNewJob(TYPE_UPLOAD_NEW_FILE);
(...skipping 23 matching lines...) Expand all
648 params.progress_callback = base::Bind(&JobScheduler::UpdateProgress, 651 params.progress_callback = base::Bind(&JobScheduler::UpdateProgress,
649 weak_ptr_factory_.GetWeakPtr(), 652 weak_ptr_factory_.GetWeakPtr(),
650 new_job->job_info.job_id); 653 new_job->job_info.job_id);
651 new_job->task = base::Bind(&RunUploadNewFile, uploader_.get(), params); 654 new_job->task = base::Bind(&RunUploadNewFile, uploader_.get(), params);
652 new_job->abort_callback = CreateErrorRunCallback(callback); 655 new_job->abort_callback = CreateErrorRunCallback(callback);
653 StartJob(new_job); 656 StartJob(new_job);
654 } 657 }
655 658
656 void JobScheduler::UploadExistingFile( 659 void JobScheduler::UploadExistingFile(
657 const std::string& resource_id, 660 const std::string& resource_id,
658 int64 expected_file_size, 661 int64_t expected_file_size,
659 const base::FilePath& drive_file_path, 662 const base::FilePath& drive_file_path,
660 const base::FilePath& local_file_path, 663 const base::FilePath& local_file_path,
661 const std::string& content_type, 664 const std::string& content_type,
662 const UploadExistingFileOptions& options, 665 const UploadExistingFileOptions& options,
663 const ClientContext& context, 666 const ClientContext& context,
664 const google_apis::FileResourceCallback& callback) { 667 const google_apis::FileResourceCallback& callback) {
665 DCHECK(thread_checker_.CalledOnValidThread()); 668 DCHECK(thread_checker_.CalledOnValidThread());
666 669
667 JobEntry* new_job = CreateNewJob(TYPE_UPLOAD_EXISTING_FILE); 670 JobEntry* new_job = CreateNewJob(TYPE_UPLOAD_EXISTING_FILE);
668 new_job->job_info.file_path = drive_file_path; 671 new_job->job_info.file_path = drive_file_path;
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 // to resume. Restore the original task. 1075 // to resume. Restore the original task.
1073 JobEntry* job_entry = job_map_.Lookup(job_id); 1076 JobEntry* job_entry = job_map_.Lookup(job_id);
1074 DCHECK(job_entry); 1077 DCHECK(job_entry);
1075 job_entry->task = original_task; 1078 job_entry->task = original_task;
1076 } 1079 }
1077 1080
1078 if (OnJobDone(job_id, error)) 1081 if (OnJobDone(job_id, error))
1079 callback.Run(error, entry.Pass()); 1082 callback.Run(error, entry.Pass());
1080 } 1083 }
1081 1084
1082 void JobScheduler::UpdateProgress(JobID job_id, int64 progress, int64 total) { 1085 void JobScheduler::UpdateProgress(JobID job_id,
1086 int64_t progress,
1087 int64_t total) {
1083 JobEntry* job_entry = job_map_.Lookup(job_id); 1088 JobEntry* job_entry = job_map_.Lookup(job_id);
1084 DCHECK(job_entry); 1089 DCHECK(job_entry);
1085 1090
1086 job_entry->job_info.num_completed_bytes = progress; 1091 job_entry->job_info.num_completed_bytes = progress;
1087 if (total != -1) 1092 if (total != -1)
1088 job_entry->job_info.num_total_bytes = total; 1093 job_entry->job_info.num_total_bytes = total;
1089 NotifyJobUpdated(job_entry->job_info); 1094 NotifyJobUpdated(job_entry->job_info);
1090 } 1095 }
1091 1096
1092 void JobScheduler::OnConnectionTypeChanged( 1097 void JobScheduler::OnConnectionTypeChanged(
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 case FILE_QUEUE: 1186 case FILE_QUEUE:
1182 return "FILE_QUEUE"; 1187 return "FILE_QUEUE";
1183 case NUM_QUEUES: 1188 case NUM_QUEUES:
1184 break; // This value is just a sentinel. Should never be used. 1189 break; // This value is just a sentinel. Should never be used.
1185 } 1190 }
1186 NOTREACHED(); 1191 NOTREACHED();
1187 return ""; 1192 return "";
1188 } 1193 }
1189 1194
1190 } // namespace drive 1195 } // namespace drive
OLDNEW
« no previous file with comments | « components/drive/job_scheduler.h ('k') | components/drive/job_scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698