OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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. | |
4 | |
5 #include "chrome/browser/sync/protocol/sync_protocol_error.h" | |
6 | |
7 #include <string> | |
8 | |
9 #include "base/logging.h" | |
10 #include "base/values.h" | |
11 | |
12 namespace browser_sync { | |
13 #define ENUM_CASE(x) case x: return #x; break; | |
14 | |
15 const char* GetSyncErrorTypeString(SyncProtocolErrorType type) { | |
16 switch (type) { | |
17 ENUM_CASE(SYNC_SUCCESS); | |
18 ENUM_CASE(NOT_MY_BIRTHDAY); | |
19 ENUM_CASE(THROTTLED); | |
20 ENUM_CASE(CLEAR_PENDING); | |
21 ENUM_CASE(TRANSIENT_ERROR); | |
22 ENUM_CASE(NON_RETRIABLE_ERROR); | |
23 ENUM_CASE(MIGRATION_DONE); | |
24 ENUM_CASE(INVALID_CREDENTIAL); | |
25 ENUM_CASE(UNKNOWN_ERROR); | |
26 } | |
27 NOTREACHED(); | |
28 return ""; | |
29 } | |
30 | |
31 const char* GetClientActionString(ClientAction action) { | |
32 switch (action) { | |
33 ENUM_CASE(UPGRADE_CLIENT); | |
34 ENUM_CASE(CLEAR_USER_DATA_AND_RESYNC); | |
35 ENUM_CASE(ENABLE_SYNC_ON_ACCOUNT); | |
36 ENUM_CASE(STOP_AND_RESTART_SYNC); | |
37 ENUM_CASE(DISABLE_SYNC_ON_CLIENT); | |
38 ENUM_CASE(UNKNOWN_ACTION); | |
39 } | |
40 NOTREACHED(); | |
41 return ""; | |
42 } | |
43 | |
44 SyncProtocolError::SyncProtocolError() | |
45 : error_type(UNKNOWN_ERROR), | |
46 action(UNKNOWN_ACTION) { | |
47 } | |
48 | |
49 SyncProtocolError::~SyncProtocolError() { | |
50 } | |
51 | |
52 DictionaryValue* SyncProtocolError::ToValue() const { | |
53 DictionaryValue* value = new DictionaryValue(); | |
54 value->SetString("ErrorType", | |
55 GetSyncErrorTypeString(error_type)); | |
56 value->SetString("ErrorDescription", error_description); | |
57 value->SetString("url", url); | |
58 value->SetString("action", GetClientActionString(action)); | |
59 return value; | |
60 } | |
61 | |
62 } // namespace browser_sync | |
63 | |
OLD | NEW |