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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 84 } |
85 | 85 |
86 ArrayVar* Var::AsArrayVar() { | 86 ArrayVar* Var::AsArrayVar() { |
87 return NULL; | 87 return NULL; |
88 } | 88 } |
89 | 89 |
90 DictionaryVar* Var::AsDictionaryVar() { | 90 DictionaryVar* Var::AsDictionaryVar() { |
91 return NULL; | 91 return NULL; |
92 } | 92 } |
93 | 93 |
| 94 ResourceVar* Var::AsResourceVar() { |
| 95 return NULL; |
| 96 } |
| 97 |
94 PP_Var Var::GetPPVar() { | 98 PP_Var Var::GetPPVar() { |
95 int32 id = GetOrCreateVarID(); | 99 int32 id = GetOrCreateVarID(); |
96 if (!id) | 100 if (!id) |
97 return PP_MakeNull(); | 101 return PP_MakeNull(); |
98 | 102 |
99 PP_Var result; | 103 PP_Var result; |
100 result.type = GetType(); | 104 result.type = GetType(); |
101 result.padding = 0; | 105 result.padding = 0; |
102 result.value.as_id = id; | 106 result.value.as_id = id; |
103 return result; | 107 return result; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 ArrayBufferVar* ArrayBufferVar::FromPPVar(PP_Var var) { | 204 ArrayBufferVar* ArrayBufferVar::FromPPVar(PP_Var var) { |
201 if (var.type != PP_VARTYPE_ARRAY_BUFFER) | 205 if (var.type != PP_VARTYPE_ARRAY_BUFFER) |
202 return NULL; | 206 return NULL; |
203 scoped_refptr<Var> var_object( | 207 scoped_refptr<Var> var_object( |
204 PpapiGlobals::Get()->GetVarTracker()->GetVar(var)); | 208 PpapiGlobals::Get()->GetVarTracker()->GetVar(var)); |
205 if (!var_object.get()) | 209 if (!var_object.get()) |
206 return NULL; | 210 return NULL; |
207 return var_object->AsArrayBufferVar(); | 211 return var_object->AsArrayBufferVar(); |
208 } | 212 } |
209 | 213 |
| 214 // ResourceVar ----------------------------------------------------------------- |
| 215 |
| 216 ResourceInfo::ResourceInfo() |
| 217 : pending_renderer_id(0), |
| 218 resource_id(0), |
| 219 file_system_type(PP_FILESYSTEMTYPE_INVALID) { |
| 220 } |
| 221 |
| 222 ResourceVar::ResourceVar() {} |
| 223 |
| 224 ResourceVar::~ResourceVar() {} |
| 225 |
| 226 void ResourceVar::SetPendingId(int pending_renderer_id) { |
| 227 data_.pending_renderer_id = pending_renderer_id; |
| 228 } |
| 229 |
| 230 void ResourceVar::SetResourceId(int resource_id) { |
| 231 data_.resource_id = resource_id; |
| 232 } |
| 233 |
| 234 void ResourceVar::SetFileSystemType(PP_FileSystemType file_system_type) { |
| 235 data_.file_system_type = file_system_type; |
| 236 } |
| 237 |
| 238 ResourceVar* ResourceVar::AsResourceVar() { |
| 239 return this; |
| 240 } |
| 241 |
| 242 PP_VarType ResourceVar::GetType() const { |
| 243 // TODO(mgiuca): Return PP_VARTYPE_RESOURCE, once that is a valid enum value. |
| 244 NOTREACHED(); |
| 245 return PP_VARTYPE_UNDEFINED; |
| 246 } |
| 247 |
| 248 // static |
| 249 ResourceVar* ResourceVar::FromPPVar(PP_Var var) { |
| 250 // TODO(mgiuca): Implement this function, once PP_VARTYPE_RESOURCE is |
| 251 // introduced. |
| 252 return NULL; |
| 253 } |
| 254 |
210 } // namespace ppapi | 255 } // namespace ppapi |
211 | 256 |
OLD | NEW |