blob: cd22e9a46f600537df04ba33d6d49e434bd485b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sync/protocol/sync_protocol_error.h"
#include <string>
#include "base/logging.h"
#include "base/values.h"
namespace syncer {
#define ENUM_CASE(x) case x: return #x; break;
const char* GetSyncErrorTypeString(SyncProtocolErrorType type) {
switch (type) {
ENUM_CASE(SYNC_SUCCESS);
ENUM_CASE(NOT_MY_BIRTHDAY);
ENUM_CASE(THROTTLED);
ENUM_CASE(CLEAR_PENDING);
ENUM_CASE(TRANSIENT_ERROR);
ENUM_CASE(NON_RETRIABLE_ERROR);
ENUM_CASE(MIGRATION_DONE);
ENUM_CASE(INVALID_CREDENTIAL);
ENUM_CASE(DISABLED_BY_ADMIN);
ENUM_CASE(UNKNOWN_ERROR);
}
NOTREACHED();
return "";
}
const char* GetClientActionString(ClientAction action) {
switch (action) {
ENUM_CASE(UPGRADE_CLIENT);
ENUM_CASE(CLEAR_USER_DATA_AND_RESYNC);
ENUM_CASE(ENABLE_SYNC_ON_ACCOUNT);
ENUM_CASE(STOP_AND_RESTART_SYNC);
ENUM_CASE(DISABLE_SYNC_ON_CLIENT);
ENUM_CASE(STOP_SYNC_FOR_DISABLED_ACCOUNT);
ENUM_CASE(UNKNOWN_ACTION);
}
NOTREACHED();
return "";
}
SyncProtocolError::SyncProtocolError()
: error_type(UNKNOWN_ERROR),
action(UNKNOWN_ACTION) {
}
SyncProtocolError::~SyncProtocolError() {
}
base::DictionaryValue* SyncProtocolError::ToValue() const {
base::DictionaryValue* value = new base::DictionaryValue();
value->SetString("ErrorType",
GetSyncErrorTypeString(error_type));
value->SetString("ErrorDescription", error_description);
value->SetString("url", url);
value->SetString("action", GetClientActionString(action));
return value;
}
} // namespace syncer
|