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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/drive_backend_util.cc

Issue 125733003: [SyncFS] Clean up V1 drive_file_sync_util.h dependency from V2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 11 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 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/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "chrome/browser/drive/drive_api_util.h" 12 #include "chrome/browser/drive/drive_api_util.h"
13 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants. h" 13 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants. h"
14 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" 14 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h"
15 #include "chrome/browser/sync_file_system/logger.h"
15 #include "google_apis/drive/drive_api_parser.h" 16 #include "google_apis/drive/drive_api_parser.h"
16 #include "google_apis/drive/gdata_wapi_parser.h" 17 #include "google_apis/drive/gdata_wapi_parser.h"
17 #include "net/base/mime_util.h" 18 #include "net/base/mime_util.h"
18 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" 19 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h"
19 20
20 namespace sync_file_system { 21 namespace sync_file_system {
21 namespace drive_backend { 22 namespace drive_backend {
22 23
23 namespace { 24 namespace {
24 25
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 178
178 if (!oldest || oldest->published_time() > entry->published_time()) { 179 if (!oldest || oldest->published_time() > entry->published_time()) {
179 oldest.reset(entry); 180 oldest.reset(entry);
180 candidates[i] = NULL; 181 candidates[i] = NULL;
181 } 182 }
182 } 183 }
183 184
184 return oldest.Pass(); 185 return oldest.Pass();
185 } 186 }
186 187
188 SyncStatusCode GDataErrorCodeToSyncStatusCode(
189 google_apis::GDataErrorCode error) {
190 // NOTE: Please update DriveFileSyncService::UpdateServiceState when you add
191 // more error code mapping.
192 switch (error) {
193 case google_apis::HTTP_SUCCESS:
194 case google_apis::HTTP_CREATED:
195 case google_apis::HTTP_NO_CONTENT:
196 case google_apis::HTTP_FOUND:
197 return SYNC_STATUS_OK;
198
199 case google_apis::HTTP_NOT_MODIFIED:
200 return SYNC_STATUS_NOT_MODIFIED;
201
202 case google_apis::HTTP_CONFLICT:
203 case google_apis::HTTP_PRECONDITION:
204 return SYNC_STATUS_HAS_CONFLICT;
205
206 case google_apis::HTTP_UNAUTHORIZED:
207 return SYNC_STATUS_AUTHENTICATION_FAILED;
208
209 case google_apis::GDATA_NO_CONNECTION:
210 return SYNC_STATUS_NETWORK_ERROR;
211
212 case google_apis::HTTP_INTERNAL_SERVER_ERROR:
213 case google_apis::HTTP_BAD_GATEWAY:
214 case google_apis::HTTP_SERVICE_UNAVAILABLE:
215 case google_apis::GDATA_CANCELLED:
216 case google_apis::GDATA_NOT_READY:
217 return SYNC_STATUS_SERVICE_TEMPORARILY_UNAVAILABLE;
218
219 case google_apis::HTTP_NOT_FOUND:
220 case google_apis::HTTP_GONE:
221 return SYNC_FILE_ERROR_NOT_FOUND;
222
223 case google_apis::GDATA_FILE_ERROR:
224 return SYNC_FILE_ERROR_FAILED;
225
226 case google_apis::HTTP_FORBIDDEN:
227 return SYNC_STATUS_ACCESS_FORBIDDEN;
228
229 case google_apis::HTTP_RESUME_INCOMPLETE:
230 case google_apis::HTTP_BAD_REQUEST:
231 case google_apis::HTTP_LENGTH_REQUIRED:
232 case google_apis::HTTP_NOT_IMPLEMENTED:
233 case google_apis::GDATA_PARSE_ERROR:
234 case google_apis::GDATA_OTHER_ERROR:
235 return SYNC_STATUS_FAILED;
236
237 case google_apis::GDATA_NO_SPACE:
238 return SYNC_FILE_ERROR_NO_SPACE;
239 }
240
241 // There's a case where DriveService layer returns GDataErrorCode==-1
242 // when network is unavailable. (http://crbug.com/223042)
243 // TODO(kinuko,nhiroki): We should identify from where this undefined error
244 // code is coming.
245 if (error == -1)
246 return SYNC_STATUS_NETWORK_ERROR;
247
248 util::Log(logging::LOG_WARNING,
249 FROM_HERE,
250 "Got unexpected error: %d",
251 static_cast<int>(error));
252 return SYNC_STATUS_FAILED;
253 }
254
187 } // namespace drive_backend 255 } // namespace drive_backend
188 } // namespace sync_file_system 256 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698