Roll WebRTC 9745:9761, Libjingle 9742:9761
[chromium-blink-merge.git] / sync / protocol / sync_protocol_error.cc
blobe5a7393a0d17470dd207ded306ca74f5442d235c
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(USER_ROLLBACK);
27 ENUM_CASE(PARTIAL_FAILURE);
28 ENUM_CASE(UNKNOWN_ERROR);
30 NOTREACHED();
31 return "";
34 const char* GetClientActionString(ClientAction action) {
35 switch (action) {
36 ENUM_CASE(UPGRADE_CLIENT);
37 ENUM_CASE(CLEAR_USER_DATA_AND_RESYNC);
38 ENUM_CASE(ENABLE_SYNC_ON_ACCOUNT);
39 ENUM_CASE(STOP_AND_RESTART_SYNC);
40 ENUM_CASE(DISABLE_SYNC_ON_CLIENT);
41 ENUM_CASE(STOP_SYNC_FOR_DISABLED_ACCOUNT);
42 ENUM_CASE(DISABLE_SYNC_AND_ROLLBACK);
43 ENUM_CASE(ROLLBACK_DONE);
44 ENUM_CASE(UNKNOWN_ACTION);
46 NOTREACHED();
47 return "";
50 SyncProtocolError::SyncProtocolError()
51 : error_type(UNKNOWN_ERROR),
52 action(UNKNOWN_ACTION) {
55 SyncProtocolError::~SyncProtocolError() {
58 base::DictionaryValue* SyncProtocolError::ToValue() const {
59 base::DictionaryValue* value = new base::DictionaryValue();
60 value->SetString("ErrorType",
61 GetSyncErrorTypeString(error_type));
62 value->SetString("ErrorDescription", error_description);
63 value->SetString("url", url);
64 value->SetString("action", GetClientActionString(action));
65 return value;
68 } // namespace syncer