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/sync_file_system/drive_backend/drive_backend_util.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 return tracker.tracker_kind() == TRACKER_KIND_APP_ROOT || | 77 return tracker.tracker_kind() == TRACKER_KIND_APP_ROOT || |
78 tracker.tracker_kind() == TRACKER_KIND_DISABLED_APP_ROOT; | 78 tracker.tracker_kind() == TRACKER_KIND_DISABLED_APP_ROOT; |
79 } | 79 } |
80 | 80 |
81 std::string GetTrackerTitle(const FileTracker& tracker) { | 81 std::string GetTrackerTitle(const FileTracker& tracker) { |
82 if (tracker.has_synced_details()) | 82 if (tracker.has_synced_details()) |
83 return tracker.synced_details().title(); | 83 return tracker.synced_details().title(); |
84 return std::string(); | 84 return std::string(); |
85 } | 85 } |
86 | 86 |
87 SyncStatusCode GDataErrorCodeToSyncStatusCode( | 87 SyncStatusCode DriveApiErrorCodeToSyncStatusCode( |
88 google_apis::GDataErrorCode error) { | 88 google_apis::DriveApiErrorCode error) { |
89 // NOTE: Please update DriveFileSyncService::UpdateServiceState when you add | 89 // NOTE: Please update DriveFileSyncService::UpdateServiceState when you add |
90 // more error code mapping. | 90 // more error code mapping. |
91 switch (error) { | 91 switch (error) { |
92 case google_apis::HTTP_SUCCESS: | 92 case google_apis::HTTP_SUCCESS: |
93 case google_apis::HTTP_CREATED: | 93 case google_apis::HTTP_CREATED: |
94 case google_apis::HTTP_NO_CONTENT: | 94 case google_apis::HTTP_NO_CONTENT: |
95 case google_apis::HTTP_FOUND: | 95 case google_apis::HTTP_FOUND: |
96 return SYNC_STATUS_OK; | 96 return SYNC_STATUS_OK; |
97 | 97 |
98 case google_apis::HTTP_NOT_MODIFIED: | 98 case google_apis::HTTP_NOT_MODIFIED: |
99 return SYNC_STATUS_NOT_MODIFIED; | 99 return SYNC_STATUS_NOT_MODIFIED; |
100 | 100 |
101 case google_apis::HTTP_CONFLICT: | 101 case google_apis::HTTP_CONFLICT: |
102 case google_apis::HTTP_PRECONDITION: | 102 case google_apis::HTTP_PRECONDITION: |
103 return SYNC_STATUS_HAS_CONFLICT; | 103 return SYNC_STATUS_HAS_CONFLICT; |
104 | 104 |
105 case google_apis::HTTP_UNAUTHORIZED: | 105 case google_apis::HTTP_UNAUTHORIZED: |
106 return SYNC_STATUS_AUTHENTICATION_FAILED; | 106 return SYNC_STATUS_AUTHENTICATION_FAILED; |
107 | 107 |
108 case google_apis::GDATA_NO_CONNECTION: | 108 case google_apis::DRIVE_NO_CONNECTION: |
109 return SYNC_STATUS_NETWORK_ERROR; | 109 return SYNC_STATUS_NETWORK_ERROR; |
110 | 110 |
111 case google_apis::HTTP_INTERNAL_SERVER_ERROR: | 111 case google_apis::HTTP_INTERNAL_SERVER_ERROR: |
112 case google_apis::HTTP_BAD_GATEWAY: | 112 case google_apis::HTTP_BAD_GATEWAY: |
113 case google_apis::HTTP_SERVICE_UNAVAILABLE: | 113 case google_apis::HTTP_SERVICE_UNAVAILABLE: |
114 case google_apis::GDATA_CANCELLED: | 114 case google_apis::DRIVE_CANCELLED: |
115 case google_apis::GDATA_NOT_READY: | 115 case google_apis::DRIVE_NOT_READY: |
116 return SYNC_STATUS_SERVICE_TEMPORARILY_UNAVAILABLE; | 116 return SYNC_STATUS_SERVICE_TEMPORARILY_UNAVAILABLE; |
117 | 117 |
118 case google_apis::HTTP_NOT_FOUND: | 118 case google_apis::HTTP_NOT_FOUND: |
119 case google_apis::HTTP_GONE: | 119 case google_apis::HTTP_GONE: |
120 return SYNC_FILE_ERROR_NOT_FOUND; | 120 return SYNC_FILE_ERROR_NOT_FOUND; |
121 | 121 |
122 case google_apis::GDATA_FILE_ERROR: | 122 case google_apis::DRIVE_FILE_ERROR: |
123 return SYNC_FILE_ERROR_FAILED; | 123 return SYNC_FILE_ERROR_FAILED; |
124 | 124 |
125 case google_apis::HTTP_FORBIDDEN: | 125 case google_apis::HTTP_FORBIDDEN: |
126 return SYNC_STATUS_ACCESS_FORBIDDEN; | 126 return SYNC_STATUS_ACCESS_FORBIDDEN; |
127 | 127 |
128 case google_apis::HTTP_RESUME_INCOMPLETE: | 128 case google_apis::HTTP_RESUME_INCOMPLETE: |
129 case google_apis::HTTP_BAD_REQUEST: | 129 case google_apis::HTTP_BAD_REQUEST: |
130 case google_apis::HTTP_LENGTH_REQUIRED: | 130 case google_apis::HTTP_LENGTH_REQUIRED: |
131 case google_apis::HTTP_NOT_IMPLEMENTED: | 131 case google_apis::HTTP_NOT_IMPLEMENTED: |
132 case google_apis::GDATA_PARSE_ERROR: | 132 case google_apis::DRIVE_PARSE_ERROR: |
133 case google_apis::GDATA_OTHER_ERROR: | 133 case google_apis::DRIVE_OTHER_ERROR: |
134 return SYNC_STATUS_FAILED; | 134 return SYNC_STATUS_FAILED; |
135 | 135 |
136 case google_apis::GDATA_NO_SPACE: | 136 case google_apis::DRIVE_NO_SPACE: |
137 return SYNC_FILE_ERROR_NO_SPACE; | 137 return SYNC_FILE_ERROR_NO_SPACE; |
138 } | 138 } |
139 | 139 |
140 // There's a case where DriveService layer returns GDataErrorCode==-1 | 140 // There's a case where DriveService layer returns DriveApiErrorCode==-1 |
141 // when network is unavailable. (http://crbug.com/223042) | 141 // when network is unavailable. (http://crbug.com/223042) |
142 // TODO(kinuko,nhiroki): We should identify from where this undefined error | 142 // TODO(kinuko,nhiroki): We should identify from where this undefined error |
143 // code is coming. | 143 // code is coming. |
144 if (error == -1) | 144 if (error == -1) |
145 return SYNC_STATUS_NETWORK_ERROR; | 145 return SYNC_STATUS_NETWORK_ERROR; |
146 | 146 |
147 util::Log(logging::LOG_WARNING, | 147 util::Log(logging::LOG_WARNING, |
148 FROM_HERE, | 148 FROM_HERE, |
149 "Got unexpected error: %d", | 149 "Got unexpected error: %d", |
150 static_cast<int>(error)); | 150 static_cast<int>(error)); |
(...skipping 28 matching lines...) Expand all Loading... |
179 } else if (status.IsNotFound()) { | 179 } else if (status.IsNotFound()) { |
180 service_metadata.reset(new ServiceMetadata); | 180 service_metadata.reset(new ServiceMetadata); |
181 service_metadata->set_next_tracker_id(1); | 181 service_metadata->set_next_tracker_id(1); |
182 } | 182 } |
183 | 183 |
184 return service_metadata.Pass(); | 184 return service_metadata.Pass(); |
185 } | 185 } |
186 | 186 |
187 } // namespace drive_backend | 187 } // namespace drive_backend |
188 } // namespace sync_file_system | 188 } // namespace sync_file_system |
OLD | NEW |