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

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

Issue 20609006: Add severity info to drive::EventLogger. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 "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"
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 void JobScheduler::QueueJob(JobID job_id) { 685 void JobScheduler::QueueJob(JobID job_id) {
686 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 686 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
687 687
688 JobEntry* job_entry = job_map_.Lookup(job_id); 688 JobEntry* job_entry = job_map_.Lookup(job_id);
689 DCHECK(job_entry); 689 DCHECK(job_entry);
690 const JobInfo& job_info = job_entry->job_info; 690 const JobInfo& job_info = job_entry->job_info;
691 691
692 QueueType queue_type = GetJobQueueType(job_info.job_type); 692 QueueType queue_type = GetJobQueueType(job_info.job_type);
693 queue_[queue_type]->Push(job_id, job_entry->context.type); 693 queue_[queue_type]->Push(job_id, job_entry->context.type);
694 694
695 util::Log("Job queued: %s - %s", job_info.ToString().c_str(), 695 util::Log(logging::LOG_INFO,
696 "Job queued: %s - %s",
697 job_info.ToString().c_str(),
696 GetQueueInfo(queue_type).c_str()); 698 GetQueueInfo(queue_type).c_str());
697 } 699 }
698 700
699 void JobScheduler::DoJobLoop(QueueType queue_type) { 701 void JobScheduler::DoJobLoop(QueueType queue_type) {
700 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 702 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
701 703
702 const int accepted_priority = GetCurrentAcceptedPriority(queue_type); 704 const int accepted_priority = GetCurrentAcceptedPriority(queue_type);
703 705
704 // Abort all USER_INITAITED jobs when not accepted. 706 // Abort all USER_INITAITED jobs when not accepted.
705 if (accepted_priority < USER_INITIATED) { 707 if (accepted_priority < USER_INITIATED) {
(...skipping 14 matching lines...) Expand all
720 JobEntry* entry = job_map_.Lookup(job_id); 722 JobEntry* entry = job_map_.Lookup(job_id);
721 DCHECK(entry); 723 DCHECK(entry);
722 724
723 JobInfo* job_info = &entry->job_info; 725 JobInfo* job_info = &entry->job_info;
724 job_info->state = STATE_RUNNING; 726 job_info->state = STATE_RUNNING;
725 job_info->start_time = base::Time::Now(); 727 job_info->start_time = base::Time::Now();
726 NotifyJobUpdated(*job_info); 728 NotifyJobUpdated(*job_info);
727 729
728 entry->cancel_callback = entry->task.Run(); 730 entry->cancel_callback = entry->task.Run();
729 731
730 util::Log("Job started: %s - %s", 732 util::Log(logging::LOG_INFO,
733 "Job started: %s - %s",
731 job_info->ToString().c_str(), 734 job_info->ToString().c_str(),
732 GetQueueInfo(queue_type).c_str()); 735 GetQueueInfo(queue_type).c_str());
733 } 736 }
734 737
735 int JobScheduler::GetCurrentAcceptedPriority(QueueType queue_type) { 738 int JobScheduler::GetCurrentAcceptedPriority(QueueType queue_type) {
736 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 739 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
737 740
738 const int kNoJobShouldRun = -1; 741 const int kNoJobShouldRun = -1;
739 742
740 // Should stop if Drive was disabled while running the fetch loop. 743 // Should stop if Drive was disabled while running the fetch loop.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 bool JobScheduler::OnJobDone(JobID job_id, google_apis::GDataErrorCode error) { 801 bool JobScheduler::OnJobDone(JobID job_id, google_apis::GDataErrorCode error) {
799 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 802 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
800 803
801 JobEntry* job_entry = job_map_.Lookup(job_id); 804 JobEntry* job_entry = job_map_.Lookup(job_id);
802 DCHECK(job_entry); 805 DCHECK(job_entry);
803 JobInfo* job_info = &job_entry->job_info; 806 JobInfo* job_info = &job_entry->job_info;
804 QueueType queue_type = GetJobQueueType(job_info->job_type); 807 QueueType queue_type = GetJobQueueType(job_info->job_type);
805 queue_[queue_type]->MarkFinished(job_id); 808 queue_[queue_type]->MarkFinished(job_id);
806 809
807 const base::TimeDelta elapsed = base::Time::Now() - job_info->start_time; 810 const base::TimeDelta elapsed = base::Time::Now() - job_info->start_time;
808 util::Log("Job done: %s => %s (elapsed time: %sms) - %s", 811 bool success = (GDataToFileError(error) == FILE_ERROR_OK);
812 util::Log(success ? logging::LOG_INFO : logging::LOG_WARNING,
813 "Job done: %s => %s (elapsed time: %sms) - %s",
809 job_info->ToString().c_str(), 814 job_info->ToString().c_str(),
810 GDataErrorCodeToString(error).c_str(), 815 GDataErrorCodeToString(error).c_str(),
811 base::Int64ToString(elapsed.InMilliseconds()).c_str(), 816 base::Int64ToString(elapsed.InMilliseconds()).c_str(),
812 GetQueueInfo(queue_type).c_str()); 817 GetQueueInfo(queue_type).c_str());
813 818
814 // Retry, depending on the error. 819 // Retry, depending on the error.
815 if ((error == google_apis::HTTP_SERVICE_UNAVAILABLE || 820 if ((error == google_apis::HTTP_SERVICE_UNAVAILABLE ||
816 error == google_apis::HTTP_INTERNAL_SERVER_ERROR) && 821 error == google_apis::HTTP_INTERNAL_SERVER_ERROR) &&
817 job_entry->retry_count < kMaxRetryCount) { 822 job_entry->retry_count < kMaxRetryCount) {
818 job_entry->cancel_callback.Reset(); 823 job_entry->cancel_callback.Reset();
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 NOTREACHED(); 1012 NOTREACHED();
1008 return FILE_QUEUE; 1013 return FILE_QUEUE;
1009 } 1014 }
1010 1015
1011 void JobScheduler::AbortNotRunningJob(JobEntry* job, 1016 void JobScheduler::AbortNotRunningJob(JobEntry* job,
1012 google_apis::GDataErrorCode error) { 1017 google_apis::GDataErrorCode error) {
1013 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1018 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1014 1019
1015 const base::TimeDelta elapsed = base::Time::Now() - job->job_info.start_time; 1020 const base::TimeDelta elapsed = base::Time::Now() - job->job_info.start_time;
1016 const QueueType queue_type = GetJobQueueType(job->job_info.job_type); 1021 const QueueType queue_type = GetJobQueueType(job->job_info.job_type);
1017 util::Log("Job aborted: %s => %s (elapsed time: %sms) - %s", 1022 util::Log(logging::LOG_INFO,
1023 "Job aborted: %s => %s (elapsed time: %sms) - %s",
1018 job->job_info.ToString().c_str(), 1024 job->job_info.ToString().c_str(),
1019 GDataErrorCodeToString(error).c_str(), 1025 GDataErrorCodeToString(error).c_str(),
1020 base::Int64ToString(elapsed.InMilliseconds()).c_str(), 1026 base::Int64ToString(elapsed.InMilliseconds()).c_str(),
1021 GetQueueInfo(queue_type).c_str()); 1027 GetQueueInfo(queue_type).c_str());
1022 1028
1023 base::Callback<void(google_apis::GDataErrorCode)> callback = 1029 base::Callback<void(google_apis::GDataErrorCode)> callback =
1024 job->abort_callback; 1030 job->abort_callback;
1025 queue_[GetJobQueueType(job->job_info.job_type)]->Remove(job->job_info.job_id); 1031 queue_[GetJobQueueType(job->job_info.job_type)]->Remove(job->job_info.job_id);
1026 NotifyJobDone(job->job_info, error); 1032 NotifyJobDone(job->job_info, error);
1027 job_map_.Remove(job->job_info.job_id); 1033 job_map_.Remove(job->job_info.job_id);
(...skipping 30 matching lines...) Expand all
1058 case FILE_QUEUE: 1064 case FILE_QUEUE:
1059 return "FILE_QUEUE"; 1065 return "FILE_QUEUE";
1060 case NUM_QUEUES: 1066 case NUM_QUEUES:
1061 break; // This value is just a sentinel. Should never be used. 1067 break; // This value is just a sentinel. Should never be used.
1062 } 1068 }
1063 NOTREACHED(); 1069 NOTREACHED();
1064 return ""; 1070 return "";
1065 } 1071 }
1066 1072
1067 } // namespace drive 1073 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698