Fix build break
[chromium-blink-merge.git] / chrome / browser / sync_file_system / drive_file_sync_util.cc
blob76de67437261348ac50c722ffc05957dfd7f9d95
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
3 // found in the LICENSE file.
5 #include "chrome/browser/sync_file_system/drive_file_sync_util.h"
7 #include "base/logging.h"
9 namespace sync_file_system {
11 SyncStatusCode GDataErrorCodeToSyncStatusCode(
12 google_apis::GDataErrorCode error) {
13 // NOTE: Please update DriveFileSyncService::UpdateServiceState when you add
14 // more error code mapping.
15 switch (error) {
16 case google_apis::HTTP_SUCCESS:
17 case google_apis::HTTP_CREATED:
18 case google_apis::HTTP_NO_CONTENT:
19 case google_apis::HTTP_FOUND:
20 return SYNC_STATUS_OK;
22 case google_apis::HTTP_NOT_MODIFIED:
23 return SYNC_STATUS_NOT_MODIFIED;
25 case google_apis::HTTP_CONFLICT:
26 return SYNC_STATUS_HAS_CONFLICT;
28 case google_apis::HTTP_UNAUTHORIZED:
29 return SYNC_STATUS_AUTHENTICATION_FAILED;
31 case google_apis::GDATA_NO_CONNECTION:
32 return SYNC_STATUS_NETWORK_ERROR;
34 case google_apis::HTTP_INTERNAL_SERVER_ERROR:
35 case google_apis::HTTP_BAD_GATEWAY:
36 case google_apis::HTTP_SERVICE_UNAVAILABLE:
37 case google_apis::GDATA_CANCELLED:
38 case google_apis::GDATA_NOT_READY:
39 return SYNC_STATUS_RETRY;
41 case google_apis::HTTP_NOT_FOUND:
42 return SYNC_FILE_ERROR_NOT_FOUND;
44 case google_apis::GDATA_FILE_ERROR:
45 return SYNC_FILE_ERROR_FAILED;
47 case google_apis::HTTP_RESUME_INCOMPLETE:
48 case google_apis::HTTP_BAD_REQUEST:
49 case google_apis::HTTP_FORBIDDEN:
50 case google_apis::HTTP_LENGTH_REQUIRED:
51 case google_apis::HTTP_PRECONDITION:
52 case google_apis::GDATA_PARSE_ERROR:
53 case google_apis::GDATA_OTHER_ERROR:
54 return SYNC_STATUS_FAILED;
56 case google_apis::GDATA_NO_SPACE:
57 return SYNC_FILE_ERROR_NO_SPACE;
60 // There's a case where DriveService layer returns GDataErrorCode==-1
61 // when network is unavailable. (http://crbug.com/223042)
62 // TODO(kinuko,nhiroki): We should identify from where this undefined error
63 // code is coming.
64 if (error == -1)
65 return SYNC_STATUS_NETWORK_ERROR;
67 LOG(WARNING) << "Got unexpected error: " << error;
68 return SYNC_STATUS_FAILED;
71 google_apis::GDataErrorCode DriveUploadErrorToGDataErrorCode(
72 google_apis::DriveUploadError error) {
73 switch (error) {
74 case google_apis::DRIVE_UPLOAD_OK:
75 return google_apis::HTTP_SUCCESS;
76 case google_apis::DRIVE_UPLOAD_ERROR_NOT_FOUND:
77 return google_apis::HTTP_NOT_FOUND;
78 case google_apis::DRIVE_UPLOAD_ERROR_NO_SPACE:
79 return google_apis::GDATA_NO_SPACE;
80 case google_apis::DRIVE_UPLOAD_ERROR_CONFLICT:
81 return google_apis::HTTP_CONFLICT;
82 case google_apis::DRIVE_UPLOAD_ERROR_ABORT:
83 return google_apis::GDATA_OTHER_ERROR;
85 NOTREACHED();
86 return google_apis::GDATA_OTHER_ERROR;
89 } // namespace sync_file_system