OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_list.h" | 5 #include "chrome/browser/chromeos/drive/job_list.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } | 70 } |
71 NOTREACHED(); | 71 NOTREACHED(); |
72 return "(unknown job state)"; | 72 return "(unknown job state)"; |
73 } | 73 } |
74 | 74 |
75 JobInfo::JobInfo(JobType in_job_type) | 75 JobInfo::JobInfo(JobType in_job_type) |
76 : job_type(in_job_type), | 76 : job_type(in_job_type), |
77 job_id(-1), | 77 job_id(-1), |
78 state(STATE_NONE), | 78 state(STATE_NONE), |
79 num_completed_bytes(0), | 79 num_completed_bytes(0), |
80 num_total_bytes(0) { | 80 num_total_bytes(0), |
| 81 num_total_jobs(0) { |
81 } | 82 } |
82 | 83 |
83 std::string JobInfo::ToString() const { | 84 std::string JobInfo::ToString() const { |
84 std::string output = base::StringPrintf( | 85 std::string output = base::StringPrintf( |
85 "%s %s [%d]", | 86 "%s %s [%d]", |
86 JobTypeToString(job_type).c_str(), | 87 JobTypeToString(job_type).c_str(), |
87 JobStateToString(state).c_str(), | 88 JobStateToString(state).c_str(), |
88 job_id); | 89 job_id); |
89 if (job_type == TYPE_DOWNLOAD_FILE || | 90 if (job_type == TYPE_DOWNLOAD_FILE || |
90 job_type == TYPE_UPLOAD_NEW_FILE || | 91 job_type == TYPE_UPLOAD_NEW_FILE || |
91 job_type == TYPE_UPLOAD_EXISTING_FILE) { | 92 job_type == TYPE_UPLOAD_EXISTING_FILE) { |
92 base::StringAppendF(&output, | 93 base::StringAppendF(&output, |
93 " bytes: %s/%s", | 94 " bytes: %s/%s", |
94 base::Int64ToString(num_completed_bytes).c_str(), | 95 base::Int64ToString(num_completed_bytes).c_str(), |
95 base::Int64ToString(num_total_bytes).c_str()); | 96 base::Int64ToString(num_total_bytes).c_str()); |
96 } | 97 } |
97 return output; | 98 return output; |
98 } | 99 } |
99 | 100 |
100 bool IsActiveFileTransferJobInfo(const JobInfo& job_info) { | 101 bool IsActiveFileTransferJobInfo(const JobInfo& job_info) { |
101 // Using switch statement so that compiler can warn when new states or types | 102 // Using switch statement so that compiler can warn when new states or types |
102 // are added. | 103 // are added. |
103 switch (job_info.state) { | |
104 case STATE_NONE: | |
105 return false; | |
106 case STATE_RUNNING: | |
107 case STATE_RETRY: | |
108 break; | |
109 } | |
110 | |
111 switch (job_info.job_type) { | 104 switch (job_info.job_type) { |
112 case TYPE_GET_ABOUT_RESOURCE: | 105 case TYPE_GET_ABOUT_RESOURCE: |
113 case TYPE_GET_APP_LIST: | 106 case TYPE_GET_APP_LIST: |
114 case TYPE_GET_ALL_RESOURCE_LIST: | 107 case TYPE_GET_ALL_RESOURCE_LIST: |
115 case TYPE_GET_RESOURCE_LIST_IN_DIRECTORY: | 108 case TYPE_GET_RESOURCE_LIST_IN_DIRECTORY: |
116 case TYPE_SEARCH: | 109 case TYPE_SEARCH: |
117 case TYPE_GET_CHANGE_LIST: | 110 case TYPE_GET_CHANGE_LIST: |
118 case TYPE_GET_REMAINING_CHANGE_LIST: | 111 case TYPE_GET_REMAINING_CHANGE_LIST: |
119 case TYPE_GET_REMAINING_FILE_LIST: | 112 case TYPE_GET_REMAINING_FILE_LIST: |
120 case TYPE_GET_RESOURCE_ENTRY: | 113 case TYPE_GET_RESOURCE_ENTRY: |
(...skipping 10 matching lines...) Expand all Loading... |
131 case TYPE_DOWNLOAD_FILE: | 124 case TYPE_DOWNLOAD_FILE: |
132 case TYPE_UPLOAD_NEW_FILE: | 125 case TYPE_UPLOAD_NEW_FILE: |
133 case TYPE_UPLOAD_EXISTING_FILE: | 126 case TYPE_UPLOAD_EXISTING_FILE: |
134 break; | 127 break; |
135 } | 128 } |
136 | 129 |
137 return true; | 130 return true; |
138 } | 131 } |
139 | 132 |
140 } // namespace drive | 133 } // namespace drive |
OLD | NEW |