Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Side by Side Diff: ppapi/shared_impl/var.cc

Issue 1200393002: Add more string_util functions to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@string
Patch Set: Android Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pdf/pdfium/pdfium_engine.cc ('k') | storage/browser/fileapi/file_system_url.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « pdf/pdfium/pdfium_engine.cc ('k') | storage/browser/fileapi/file_system_url.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698