Simple Cache: Enable by default on Android developer builds
[chromium-blink-merge.git] / sync / protocol / sync_protocol_error.cc
blobcd22e9a46f600537df04ba33d6d49e434bd485b1
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 "sync/protocol/sync_protocol_error.h"
7 #include <string>
9 #include "base/logging.h"
10 #include "base/values.h"
12 namespace syncer {
13 #define ENUM_CASE(x) case x: return #x; break;
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(DISABLED_BY_ADMIN);
26 ENUM_CASE(UNKNOWN_ERROR);
28 NOTREACHED();
29 return "";
32 const char* GetClientActionString(ClientAction action) {
33 switch (action) {
34 ENUM_CASE(UPGRADE_CLIENT);
35 ENUM_CASE(CLEAR_USER_DATA_AND_RESYNC);
36 ENUM_CASE(ENABLE_SYNC_ON_ACCOUNT);
37 ENUM_CASE(STOP_AND_RESTART_SYNC);
38 ENUM_CASE(DISABLE_SYNC_ON_CLIENT);
39 ENUM_CASE(STOP_SYNC_FOR_DISABLED_ACCOUNT);
40 ENUM_CASE(UNKNOWN_ACTION);
42 NOTREACHED();
43 return "";
46 SyncProtocolError::SyncProtocolError()
47 : error_type(UNKNOWN_ERROR),
48 action(UNKNOWN_ACTION) {
51 SyncProtocolError::~SyncProtocolError() {
54 base::DictionaryValue* SyncProtocolError::ToValue() const {
55 base::DictionaryValue* value = new base::DictionaryValue();
56 value->SetString("ErrorType",
57 GetSyncErrorTypeString(error_type));
58 value->SetString("ErrorDescription", error_description);
59 value->SetString("url", url);
60 value->SetString("action", GetClientActionString(action));
61 return value;
64 } // namespace syncer