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

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: Rebase - the 2nd try - 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 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 688
689 JobEntry* job_entry = job_map_.Lookup(job_id); 689 JobEntry* job_entry = job_map_.Lookup(job_id);
690 DCHECK(job_entry); 690 DCHECK(job_entry);
691 const JobInfo& job_info = job_entry->job_info; 691 const JobInfo& job_info = job_entry->job_info;
692 692
693 QueueType queue_type = GetJobQueueType(job_info.job_type); 693 QueueType queue_type = GetJobQueueType(job_info.job_type);
694 queue_[queue_type]->Push(job_id, job_entry->context.type); 694 queue_[queue_type]->Push(job_id, job_entry->context.type);
695 695
696 const std::string retry_prefix = job_entry->retry_count > 0 ? 696 const std::string retry_prefix = job_entry->retry_count > 0 ?
697 base::StringPrintf(" (retry %d)", job_entry->retry_count) : ""; 697 base::StringPrintf(" (retry %d)", job_entry->retry_count) : "";
698 util::Log("Job queued%s: %s - %s", 698 util::Log(logging::LOG_INFO,
699 "Job queued%s: %s - %s",
699 retry_prefix.c_str(), 700 retry_prefix.c_str(),
700 job_info.ToString().c_str(), 701 job_info.ToString().c_str(),
701 GetQueueInfo(queue_type).c_str()); 702 GetQueueInfo(queue_type).c_str());
702 } 703 }
703 704
704 void JobScheduler::DoJobLoop(QueueType queue_type) { 705 void JobScheduler::DoJobLoop(QueueType queue_type) {
705 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 706 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
706 707
707 const int accepted_priority = GetCurrentAcceptedPriority(queue_type); 708 const int accepted_priority = GetCurrentAcceptedPriority(queue_type);
708 709
(...skipping 16 matching lines...) Expand all
725 JobEntry* entry = job_map_.Lookup(job_id); 726 JobEntry* entry = job_map_.Lookup(job_id);
726 DCHECK(entry); 727 DCHECK(entry);
727 728
728 JobInfo* job_info = &entry->job_info; 729 JobInfo* job_info = &entry->job_info;
729 job_info->state = STATE_RUNNING; 730 job_info->state = STATE_RUNNING;
730 job_info->start_time = base::Time::Now(); 731 job_info->start_time = base::Time::Now();
731 NotifyJobUpdated(*job_info); 732 NotifyJobUpdated(*job_info);
732 733
733 entry->cancel_callback = entry->task.Run(); 734 entry->cancel_callback = entry->task.Run();
734 735
735 util::Log("Job started: %s - %s", 736 util::Log(logging::LOG_INFO,
737 "Job started: %s - %s",
736 job_info->ToString().c_str(), 738 job_info->ToString().c_str(),
737 GetQueueInfo(queue_type).c_str()); 739 GetQueueInfo(queue_type).c_str());
738 } 740 }
739 741
740 int JobScheduler::GetCurrentAcceptedPriority(QueueType queue_type) { 742 int JobScheduler::GetCurrentAcceptedPriority(QueueType queue_type) {
741 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 743 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
742 744
743 const int kNoJobShouldRun = -1; 745 const int kNoJobShouldRun = -1;
744 746
745 // Should stop if Drive was disabled while running the fetch loop. 747 // Should stop if Drive was disabled while running the fetch loop.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 bool JobScheduler::OnJobDone(JobID job_id, google_apis::GDataErrorCode error) { 805 bool JobScheduler::OnJobDone(JobID job_id, google_apis::GDataErrorCode error) {
804 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 806 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
805 807
806 JobEntry* job_entry = job_map_.Lookup(job_id); 808 JobEntry* job_entry = job_map_.Lookup(job_id);
807 DCHECK(job_entry); 809 DCHECK(job_entry);
808 JobInfo* job_info = &job_entry->job_info; 810 JobInfo* job_info = &job_entry->job_info;
809 QueueType queue_type = GetJobQueueType(job_info->job_type); 811 QueueType queue_type = GetJobQueueType(job_info->job_type);
810 queue_[queue_type]->MarkFinished(job_id); 812 queue_[queue_type]->MarkFinished(job_id);
811 813
812 const base::TimeDelta elapsed = base::Time::Now() - job_info->start_time; 814 const base::TimeDelta elapsed = base::Time::Now() - job_info->start_time;
813 util::Log("Job done: %s => %s (elapsed time: %sms) - %s", 815 bool success = (GDataToFileError(error) == FILE_ERROR_OK);
816 util::Log(success ? logging::LOG_INFO : logging::LOG_WARNING,
817 "Job done: %s => %s (elapsed time: %sms) - %s",
814 job_info->ToString().c_str(), 818 job_info->ToString().c_str(),
815 GDataErrorCodeToString(error).c_str(), 819 GDataErrorCodeToString(error).c_str(),
816 base::Int64ToString(elapsed.InMilliseconds()).c_str(), 820 base::Int64ToString(elapsed.InMilliseconds()).c_str(),
817 GetQueueInfo(queue_type).c_str()); 821 GetQueueInfo(queue_type).c_str());
818 822
819 // Retry, depending on the error. 823 // Retry, depending on the error.
820 if ((error == google_apis::HTTP_SERVICE_UNAVAILABLE || 824 if ((error == google_apis::HTTP_SERVICE_UNAVAILABLE ||
821 error == google_apis::HTTP_INTERNAL_SERVER_ERROR) && 825 error == google_apis::HTTP_INTERNAL_SERVER_ERROR) &&
822 job_entry->retry_count < kMaxRetryCount) { 826 job_entry->retry_count < kMaxRetryCount) {
823 job_entry->cancel_callback.Reset(); 827 job_entry->cancel_callback.Reset();
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 NOTREACHED(); 1016 NOTREACHED();
1013 return FILE_QUEUE; 1017 return FILE_QUEUE;
1014 } 1018 }
1015 1019
1016 void JobScheduler::AbortNotRunningJob(JobEntry* job, 1020 void JobScheduler::AbortNotRunningJob(JobEntry* job,
1017 google_apis::GDataErrorCode error) { 1021 google_apis::GDataErrorCode error) {
1018 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1022 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1019 1023
1020 const base::TimeDelta elapsed = base::Time::Now() - job->job_info.start_time; 1024 const base::TimeDelta elapsed = base::Time::Now() - job->job_info.start_time;
1021 const QueueType queue_type = GetJobQueueType(job->job_info.job_type); 1025 const QueueType queue_type = GetJobQueueType(job->job_info.job_type);
1022 util::Log("Job aborted: %s => %s (elapsed time: %sms) - %s", 1026 util::Log(logging::LOG_INFO,
1027 "Job aborted: %s => %s (elapsed time: %sms) - %s",
1023 job->job_info.ToString().c_str(), 1028 job->job_info.ToString().c_str(),
1024 GDataErrorCodeToString(error).c_str(), 1029 GDataErrorCodeToString(error).c_str(),
1025 base::Int64ToString(elapsed.InMilliseconds()).c_str(), 1030 base::Int64ToString(elapsed.InMilliseconds()).c_str(),
1026 GetQueueInfo(queue_type).c_str()); 1031 GetQueueInfo(queue_type).c_str());
1027 1032
1028 base::Callback<void(google_apis::GDataErrorCode)> callback = 1033 base::Callback<void(google_apis::GDataErrorCode)> callback =
1029 job->abort_callback; 1034 job->abort_callback;
1030 queue_[GetJobQueueType(job->job_info.job_type)]->Remove(job->job_info.job_id); 1035 queue_[GetJobQueueType(job->job_info.job_type)]->Remove(job->job_info.job_id);
1031 NotifyJobDone(job->job_info, error); 1036 NotifyJobDone(job->job_info, error);
1032 job_map_.Remove(job->job_info.job_id); 1037 job_map_.Remove(job->job_info.job_id);
(...skipping 30 matching lines...) Expand all
1063 case FILE_QUEUE: 1068 case FILE_QUEUE:
1064 return "FILE_QUEUE"; 1069 return "FILE_QUEUE";
1065 case NUM_QUEUES: 1070 case NUM_QUEUES:
1066 break; // This value is just a sentinel. Should never be used. 1071 break; // This value is just a sentinel. Should never be used.
1067 } 1072 }
1068 NOTREACHED(); 1073 NOTREACHED();
1069 return ""; 1074 return "";
1070 } 1075 }
1071 1076
1072 } // namespace drive 1077 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/drive_integration_service.cc ('k') | chrome/browser/chromeos/drive/logging.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698