| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/sync/protocol/sync_protocol_error.h" | 5 #include "components/sync/protocol/sync_protocol_error.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" |
| 8 | 11 |
| 9 namespace syncer { | 12 namespace syncer { |
| 10 #define ENUM_CASE(x) \ | 13 #define ENUM_CASE(x) \ |
| 11 case x: \ | 14 case x: \ |
| 12 return #x; \ | 15 return #x; \ |
| 13 break; | 16 break; |
| 14 | 17 |
| 15 const char* GetSyncErrorTypeString(SyncProtocolErrorType type) { | 18 const char* GetSyncErrorTypeString(SyncProtocolErrorType type) { |
| 16 switch (type) { | 19 switch (type) { |
| 17 ENUM_CASE(SYNC_SUCCESS); | 20 ENUM_CASE(SYNC_SUCCESS); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 45 return ""; | 48 return ""; |
| 46 } | 49 } |
| 47 | 50 |
| 48 SyncProtocolError::SyncProtocolError() | 51 SyncProtocolError::SyncProtocolError() |
| 49 : error_type(UNKNOWN_ERROR), action(UNKNOWN_ACTION) {} | 52 : error_type(UNKNOWN_ERROR), action(UNKNOWN_ACTION) {} |
| 50 | 53 |
| 51 SyncProtocolError::SyncProtocolError(const SyncProtocolError& other) = default; | 54 SyncProtocolError::SyncProtocolError(const SyncProtocolError& other) = default; |
| 52 | 55 |
| 53 SyncProtocolError::~SyncProtocolError() {} | 56 SyncProtocolError::~SyncProtocolError() {} |
| 54 | 57 |
| 55 base::DictionaryValue* SyncProtocolError::ToValue() const { | 58 std::unique_ptr<base::DictionaryValue> SyncProtocolError::ToValue() const { |
| 56 base::DictionaryValue* value = new base::DictionaryValue(); | 59 auto value = base::MakeUnique<base::DictionaryValue>(); |
| 57 value->SetString("ErrorType", GetSyncErrorTypeString(error_type)); | 60 value->SetString("ErrorType", GetSyncErrorTypeString(error_type)); |
| 58 value->SetString("ErrorDescription", error_description); | 61 value->SetString("ErrorDescription", error_description); |
| 59 value->SetString("url", url); | 62 value->SetString("url", url); |
| 60 value->SetString("action", GetClientActionString(action)); | 63 value->SetString("action", GetClientActionString(action)); |
| 61 return value; | 64 return value; |
| 62 } | 65 } |
| 63 | 66 |
| 64 } // namespace syncer | 67 } // namespace syncer |
| OLD | NEW |