| 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 "ppapi/shared_impl/var.h" | 5 #include "ppapi/shared_impl/var.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 return "[Invalid string]"; | 38 return "[Invalid string]"; |
| 39 | 39 |
| 40 // Since this is for logging, escape NULLs, truncate length. | 40 // Since this is for logging, escape NULLs, truncate length. |
| 41 std::string result; | 41 std::string result; |
| 42 const size_t kTruncateAboveLength = 128; | 42 const size_t kTruncateAboveLength = 128; |
| 43 if (string->value().size() > kTruncateAboveLength) | 43 if (string->value().size() > kTruncateAboveLength) |
| 44 result = string->value().substr(0, kTruncateAboveLength) + "..."; | 44 result = string->value().substr(0, kTruncateAboveLength) + "..."; |
| 45 else | 45 else |
| 46 result = string->value(); | 46 result = string->value(); |
| 47 | 47 |
| 48 std::string null; | 48 base::ReplaceSubstringsAfterOffset( |
| 49 null.push_back(0); | 49 &result, 0, base::StringPiece("\0", 1), "\\0"); |
| 50 ReplaceSubstringsAfterOffset(&result, 0, null, "\\0"); | |
| 51 return result; | 50 return result; |
| 52 } | 51 } |
| 53 case PP_VARTYPE_OBJECT: | 52 case PP_VARTYPE_OBJECT: |
| 54 return "[Object]"; | 53 return "[Object]"; |
| 55 case PP_VARTYPE_ARRAY: | 54 case PP_VARTYPE_ARRAY: |
| 56 return "[Array]"; | 55 return "[Array]"; |
| 57 case PP_VARTYPE_DICTIONARY: | 56 case PP_VARTYPE_DICTIONARY: |
| 58 return "[Dictionary]"; | 57 return "[Dictionary]"; |
| 59 case PP_VARTYPE_ARRAY_BUFFER: | 58 case PP_VARTYPE_ARRAY_BUFFER: |
| 60 return "[Array buffer]"; | 59 return "[Array buffer]"; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 if (var.type != PP_VARTYPE_ARRAY_BUFFER) | 185 if (var.type != PP_VARTYPE_ARRAY_BUFFER) |
| 187 return NULL; | 186 return NULL; |
| 188 scoped_refptr<Var> var_object( | 187 scoped_refptr<Var> var_object( |
| 189 PpapiGlobals::Get()->GetVarTracker()->GetVar(var)); | 188 PpapiGlobals::Get()->GetVarTracker()->GetVar(var)); |
| 190 if (!var_object.get()) | 189 if (!var_object.get()) |
| 191 return NULL; | 190 return NULL; |
| 192 return var_object->AsArrayBufferVar(); | 191 return var_object->AsArrayBufferVar(); |
| 193 } | 192 } |
| 194 | 193 |
| 195 } // namespace ppapi | 194 } // namespace ppapi |
| OLD | NEW |