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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 } else if (value->GetAsList(&list)) { | 60 } else if (value->GetAsList(&list)) { |
61 std::unique_ptr<base::ListValue> list_copy(new base::ListValue()); | 61 std::unique_ptr<base::ListValue> list_copy(new base::ListValue()); |
62 for (size_t i = 0; i < list->GetSize(); ++i) { | 62 for (size_t i = 0; i < list->GetSize(); ++i) { |
63 const base::Value* child = NULL; | 63 const base::Value* child = NULL; |
64 if (!list->Get(i, &child)) | 64 if (!list->Get(i, &child)) |
65 continue; | 65 continue; |
66 if (list_copy->GetSize() >= kMaxChildren - 1) { | 66 if (list_copy->GetSize() >= kMaxChildren - 1) { |
67 list_copy->AppendString("..."); | 67 list_copy->AppendString("..."); |
68 break; | 68 break; |
69 } | 69 } |
70 list_copy->Append(SmartDeepCopy(child).release()); | 70 list_copy->Append(SmartDeepCopy(child)); |
71 } | 71 } |
72 return std::move(list_copy); | 72 return std::move(list_copy); |
73 } else if (value->GetAsString(&data)) { | 73 } else if (value->GetAsString(&data)) { |
74 TruncateString(&data); | 74 TruncateString(&data); |
75 return std::unique_ptr<base::Value>(new base::StringValue(data)); | 75 return std::unique_ptr<base::Value>(new base::StringValue(data)); |
76 } | 76 } |
77 return std::unique_ptr<base::Value>(value->DeepCopy()); | 77 return std::unique_ptr<base::Value>(value->DeepCopy()); |
78 } | 78 } |
79 | 79 |
80 } // namespace | 80 } // namespace |
(...skipping 25 matching lines...) Expand all Loading... |
106 std::unique_ptr<base::Value> copy(SmartDeepCopy(&value)); | 106 std::unique_ptr<base::Value> copy(SmartDeepCopy(&value)); |
107 return PrettyPrintValue(*copy); | 107 return PrettyPrintValue(*copy); |
108 } | 108 } |
109 | 109 |
110 std::string FormatJsonForDisplay(const std::string& json) { | 110 std::string FormatJsonForDisplay(const std::string& json) { |
111 std::unique_ptr<base::Value> value = base::JSONReader::Read(json); | 111 std::unique_ptr<base::Value> value = base::JSONReader::Read(json); |
112 if (!value) | 112 if (!value) |
113 value.reset(new base::StringValue(json)); | 113 value.reset(new base::StringValue(json)); |
114 return FormatValueForDisplay(*value); | 114 return FormatValueForDisplay(*value); |
115 } | 115 } |
OLD | NEW |