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/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 } | 150 } |
151 | 151 |
152 // static | 152 // static |
153 PP_Var StringVar::StringToPPVar(const std::string& var) { | 153 PP_Var StringVar::StringToPPVar(const std::string& var) { |
154 return StringToPPVar(var.c_str(), static_cast<uint32>(var.size())); | 154 return StringToPPVar(var.c_str(), static_cast<uint32>(var.size())); |
155 } | 155 } |
156 | 156 |
157 // static | 157 // static |
158 PP_Var StringVar::StringToPPVar(const char* data, uint32 len) { | 158 PP_Var StringVar::StringToPPVar(const char* data, uint32 len) { |
159 scoped_refptr<StringVar> str(new StringVar(data, len)); | 159 scoped_refptr<StringVar> str(new StringVar(data, len)); |
160 if (!str || !IsStringUTF8(str->value())) | 160 if (!str.get() || !IsStringUTF8(str->value())) |
161 return PP_MakeNull(); | 161 return PP_MakeNull(); |
162 return str->GetPPVar(); | 162 return str->GetPPVar(); |
163 } | 163 } |
164 | 164 |
165 // static | 165 // static |
166 StringVar* StringVar::FromPPVar(PP_Var var) { | 166 StringVar* StringVar::FromPPVar(PP_Var var) { |
167 if (var.type != PP_VARTYPE_STRING) | 167 if (var.type != PP_VARTYPE_STRING) |
168 return NULL; | 168 return NULL; |
169 scoped_refptr<Var> var_object( | 169 scoped_refptr<Var> var_object( |
170 PpapiGlobals::Get()->GetVarTracker()->GetVar(var)); | 170 PpapiGlobals::Get()->GetVarTracker()->GetVar(var)); |
171 if (!var_object) | 171 if (!var_object.get()) |
172 return NULL; | 172 return NULL; |
173 return var_object->AsStringVar(); | 173 return var_object->AsStringVar(); |
174 } | 174 } |
175 | 175 |
176 // static | 176 // static |
177 PP_Var StringVar::SwapValidatedUTF8StringIntoPPVar(std::string* src) { | 177 PP_Var StringVar::SwapValidatedUTF8StringIntoPPVar(std::string* src) { |
178 scoped_refptr<StringVar> str(new StringVar); | 178 scoped_refptr<StringVar> str(new StringVar); |
179 str->value_.swap(*src); | 179 str->value_.swap(*src); |
180 return str->GetPPVar(); | 180 return str->GetPPVar(); |
181 } | 181 } |
(...skipping 13 matching lines...) Expand all Loading... |
195 PP_VarType ArrayBufferVar::GetType() const { | 195 PP_VarType ArrayBufferVar::GetType() const { |
196 return PP_VARTYPE_ARRAY_BUFFER; | 196 return PP_VARTYPE_ARRAY_BUFFER; |
197 } | 197 } |
198 | 198 |
199 // static | 199 // static |
200 ArrayBufferVar* ArrayBufferVar::FromPPVar(PP_Var var) { | 200 ArrayBufferVar* ArrayBufferVar::FromPPVar(PP_Var var) { |
201 if (var.type != PP_VARTYPE_ARRAY_BUFFER) | 201 if (var.type != PP_VARTYPE_ARRAY_BUFFER) |
202 return NULL; | 202 return NULL; |
203 scoped_refptr<Var> var_object( | 203 scoped_refptr<Var> var_object( |
204 PpapiGlobals::Get()->GetVarTracker()->GetVar(var)); | 204 PpapiGlobals::Get()->GetVarTracker()->GetVar(var)); |
205 if (!var_object) | 205 if (!var_object.get()) |
206 return NULL; | 206 return NULL; |
207 return var_object->AsArrayBufferVar(); | 207 return var_object->AsArrayBufferVar(); |
208 } | 208 } |
209 | 209 |
210 } // namespace ppapi | 210 } // namespace ppapi |
211 | 211 |
OLD | NEW |