| 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 "chrome/test/chromedriver/chrome/log.h" | 5 #include "chrome/test/chromedriver/chrome/log.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 std::unique_ptr<base::DictionaryValue> dict_copy( | 46 std::unique_ptr<base::DictionaryValue> dict_copy( |
| 47 new base::DictionaryValue()); | 47 new base::DictionaryValue()); |
| 48 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); | 48 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); |
| 49 it.Advance()) { | 49 it.Advance()) { |
| 50 if (dict_copy->size() >= kMaxChildren - 1) { | 50 if (dict_copy->size() >= kMaxChildren - 1) { |
| 51 dict_copy->SetStringWithoutPathExpansion("~~~", "..."); | 51 dict_copy->SetStringWithoutPathExpansion("~~~", "..."); |
| 52 break; | 52 break; |
| 53 } | 53 } |
| 54 const base::Value* child = NULL; | 54 const base::Value* child = NULL; |
| 55 dict->GetWithoutPathExpansion(it.key(), &child); | 55 dict->GetWithoutPathExpansion(it.key(), &child); |
| 56 dict_copy->SetWithoutPathExpansion(it.key(), | 56 dict_copy->SetWithoutPathExpansion(it.key(), SmartDeepCopy(child)); |
| 57 SmartDeepCopy(child).release()); | |
| 58 } | 57 } |
| 59 return std::move(dict_copy); | 58 return std::move(dict_copy); |
| 60 } else if (value->GetAsList(&list)) { | 59 } else if (value->GetAsList(&list)) { |
| 61 std::unique_ptr<base::ListValue> list_copy(new base::ListValue()); | 60 std::unique_ptr<base::ListValue> list_copy(new base::ListValue()); |
| 62 for (size_t i = 0; i < list->GetSize(); ++i) { | 61 for (size_t i = 0; i < list->GetSize(); ++i) { |
| 63 const base::Value* child = NULL; | 62 const base::Value* child = NULL; |
| 64 if (!list->Get(i, &child)) | 63 if (!list->Get(i, &child)) |
| 65 continue; | 64 continue; |
| 66 if (list_copy->GetSize() >= kMaxChildren - 1) { | 65 if (list_copy->GetSize() >= kMaxChildren - 1) { |
| 67 list_copy->AppendString("..."); | 66 list_copy->AppendString("..."); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 std::unique_ptr<base::Value> copy(SmartDeepCopy(&value)); | 105 std::unique_ptr<base::Value> copy(SmartDeepCopy(&value)); |
| 107 return PrettyPrintValue(*copy); | 106 return PrettyPrintValue(*copy); |
| 108 } | 107 } |
| 109 | 108 |
| 110 std::string FormatJsonForDisplay(const std::string& json) { | 109 std::string FormatJsonForDisplay(const std::string& json) { |
| 111 std::unique_ptr<base::Value> value = base::JSONReader::Read(json); | 110 std::unique_ptr<base::Value> value = base::JSONReader::Read(json); |
| 112 if (!value) | 111 if (!value) |
| 113 value.reset(new base::Value(json)); | 112 value.reset(new base::Value(json)); |
| 114 return FormatValueForDisplay(*value); | 113 return FormatValueForDisplay(*value); |
| 115 } | 114 } |
| OLD | NEW |