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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 return "TYPE_CREATE_FILE"; | 54 return "TYPE_CREATE_FILE"; |
55 case TYPE_ADD_PERMISSION: | 55 case TYPE_ADD_PERMISSION: |
56 return "TYPE_ADD_PERMISSION"; | 56 return "TYPE_ADD_PERMISSION"; |
57 } | 57 } |
58 NOTREACHED(); | 58 NOTREACHED(); |
59 return "(unknown job type)"; | 59 return "(unknown job type)"; |
60 } | 60 } |
61 | 61 |
62 std::string JobStateToString(JobState state) { | 62 std::string JobStateToString(JobState state) { |
63 switch (state) { | 63 switch (state) { |
| 64 case STATE_NEW: |
| 65 return "STATE_NEW"; |
64 case STATE_NONE: | 66 case STATE_NONE: |
65 return "STATE_NONE"; | 67 return "STATE_NONE"; |
66 case STATE_RUNNING: | 68 case STATE_RUNNING: |
67 return "STATE_RUNNING"; | 69 return "STATE_RUNNING"; |
68 case STATE_RETRY: | 70 case STATE_RETRY: |
69 return "STATE_RETRY"; | 71 return "STATE_RETRY"; |
70 } | 72 } |
71 NOTREACHED(); | 73 NOTREACHED(); |
72 return "(unknown job state)"; | 74 return "(unknown job state)"; |
73 } | 75 } |
74 | 76 |
75 JobInfo::JobInfo(JobType in_job_type) | 77 JobInfo::JobInfo(JobType in_job_type) |
76 : job_type(in_job_type), | 78 : job_type(in_job_type), |
77 job_id(-1), | 79 job_id(-1), |
78 state(STATE_NONE), | 80 state(STATE_NONE), |
79 num_completed_bytes(0), | 81 num_completed_bytes(0), |
80 num_total_bytes(0) { | 82 num_total_bytes(0), |
| 83 num_total_jobs(0) { |
81 } | 84 } |
82 | 85 |
83 std::string JobInfo::ToString() const { | 86 std::string JobInfo::ToString() const { |
84 std::string output = base::StringPrintf( | 87 std::string output = base::StringPrintf( |
85 "%s %s [%d]", | 88 "%s %s [%d]", |
86 JobTypeToString(job_type).c_str(), | 89 JobTypeToString(job_type).c_str(), |
87 JobStateToString(state).c_str(), | 90 JobStateToString(state).c_str(), |
88 job_id); | 91 job_id); |
89 if (job_type == TYPE_DOWNLOAD_FILE || | 92 if (job_type == TYPE_DOWNLOAD_FILE || |
90 job_type == TYPE_UPLOAD_NEW_FILE || | 93 job_type == TYPE_UPLOAD_NEW_FILE || |
91 job_type == TYPE_UPLOAD_EXISTING_FILE) { | 94 job_type == TYPE_UPLOAD_EXISTING_FILE) { |
92 base::StringAppendF(&output, | 95 base::StringAppendF(&output, |
93 " bytes: %s/%s", | 96 " bytes: %s/%s", |
94 base::Int64ToString(num_completed_bytes).c_str(), | 97 base::Int64ToString(num_completed_bytes).c_str(), |
95 base::Int64ToString(num_total_bytes).c_str()); | 98 base::Int64ToString(num_total_bytes).c_str()); |
96 } | 99 } |
97 return output; | 100 return output; |
98 } | 101 } |
99 | 102 |
100 bool IsActiveFileTransferJobInfo(const JobInfo& job_info) { | 103 bool IsActiveFileTransferJobInfo(const JobInfo& job_info) { |
101 // Using switch statement so that compiler can warn when new states or types | 104 // Using switch statement so that compiler can warn when new states or types |
102 // are added. | 105 // are added. |
103 switch (job_info.state) { | 106 switch (job_info.state) { |
104 case STATE_NONE: | 107 case STATE_NONE: |
105 return false; | 108 return false; |
| 109 case STATE_NEW: |
106 case STATE_RUNNING: | 110 case STATE_RUNNING: |
107 case STATE_RETRY: | 111 case STATE_RETRY: |
108 break; | 112 break; |
109 } | 113 } |
110 | 114 |
111 switch (job_info.job_type) { | 115 switch (job_info.job_type) { |
112 case TYPE_GET_ABOUT_RESOURCE: | 116 case TYPE_GET_ABOUT_RESOURCE: |
113 case TYPE_GET_APP_LIST: | 117 case TYPE_GET_APP_LIST: |
114 case TYPE_GET_ALL_RESOURCE_LIST: | 118 case TYPE_GET_ALL_RESOURCE_LIST: |
115 case TYPE_GET_RESOURCE_LIST_IN_DIRECTORY: | 119 case TYPE_GET_RESOURCE_LIST_IN_DIRECTORY: |
(...skipping 15 matching lines...) Expand all Loading... |
131 case TYPE_DOWNLOAD_FILE: | 135 case TYPE_DOWNLOAD_FILE: |
132 case TYPE_UPLOAD_NEW_FILE: | 136 case TYPE_UPLOAD_NEW_FILE: |
133 case TYPE_UPLOAD_EXISTING_FILE: | 137 case TYPE_UPLOAD_EXISTING_FILE: |
134 break; | 138 break; |
135 } | 139 } |
136 | 140 |
137 return true; | 141 return true; |
138 } | 142 } |
139 | 143 |
140 } // namespace drive | 144 } // namespace drive |
OLD | NEW |