| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/resource_var.h" | 5 #include "ppapi/shared_impl/resource_var.h" |
| 6 | 6 |
| 7 #include "ppapi/shared_impl/ppapi_globals.h" |
| 8 #include "ppapi/shared_impl/var_tracker.h" |
| 9 |
| 7 namespace ppapi { | 10 namespace ppapi { |
| 8 | 11 |
| 9 ResourceVar::ResourceVar() : pp_resource_(0) {} | 12 ResourceVar::ResourceVar() : pp_resource_(0) {} |
| 10 | 13 |
| 11 ResourceVar::ResourceVar(PP_Resource pp_resource) : pp_resource_(pp_resource) {} | 14 ResourceVar::ResourceVar(PP_Resource pp_resource) : pp_resource_(pp_resource) {} |
| 12 | 15 |
| 13 ResourceVar::ResourceVar(const IPC::Message& creation_message) | 16 ResourceVar::ResourceVar(const IPC::Message& creation_message) |
| 14 : pp_resource_(0), | 17 : pp_resource_(0), |
| 15 creation_message_(creation_message) {} | 18 creation_message_(creation_message) {} |
| 16 | 19 |
| 17 ResourceVar::~ResourceVar() {} | 20 ResourceVar::~ResourceVar() {} |
| 18 | 21 |
| 19 ResourceVar* ResourceVar::AsResourceVar() { | 22 ResourceVar* ResourceVar::AsResourceVar() { |
| 20 return this; | 23 return this; |
| 21 } | 24 } |
| 22 | 25 |
| 23 PP_VarType ResourceVar::GetType() const { | 26 PP_VarType ResourceVar::GetType() const { |
| 24 // TODO(mgiuca): Return PP_VARTYPE_RESOURCE, once that is a valid enum value. | 27 return PP_VARTYPE_RESOURCE; |
| 25 NOTREACHED(); | |
| 26 return PP_VARTYPE_UNDEFINED; | |
| 27 } | 28 } |
| 28 | 29 |
| 29 // static | 30 // static |
| 30 ResourceVar* ResourceVar::FromPPVar(PP_Var var) { | 31 ResourceVar* ResourceVar::FromPPVar(PP_Var var) { |
| 31 // TODO(mgiuca): Implement this function, once PP_VARTYPE_RESOURCE is | 32 if (var.type != PP_VARTYPE_RESOURCE) |
| 32 // introduced. | 33 return NULL; |
| 33 return NULL; | 34 scoped_refptr<Var> var_object( |
| 35 PpapiGlobals::Get()->GetVarTracker()->GetVar(var)); |
| 36 if (!var_object.get()) |
| 37 return NULL; |
| 38 return var_object->AsResourceVar(); |
| 34 } | 39 } |
| 35 | 40 |
| 36 } // namespace ppapi | 41 } // namespace ppapi |
| OLD | NEW |