| 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/cpp/dev/var_resource_dev.h" | 5 #include "ppapi/cpp/var_resource.h" |
| 6 | 6 |
| 7 #include "ppapi/c/dev/ppb_var_resource_dev.h" | 7 #include "ppapi/c/ppb_var_resource.h" |
| 8 #include "ppapi/cpp/logging.h" | 8 #include "ppapi/cpp/logging.h" |
| 9 #include "ppapi/cpp/module_impl.h" | 9 #include "ppapi/cpp/module_impl.h" |
| 10 | 10 |
| 11 namespace pp { | 11 namespace pp { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 template <> const char* interface_name<PPB_VarResource_Dev_0_1>() { | 15 template <> const char* interface_name<PPB_VarResource_1_0>() { |
| 16 return PPB_VAR_RESOURCE_DEV_INTERFACE_0_1; | 16 return PPB_VAR_RESOURCE_INTERFACE_1_0; |
| 17 } | 17 } |
| 18 | 18 |
| 19 } // namespace | 19 } // namespace |
| 20 | 20 |
| 21 VarResource_Dev::VarResource_Dev(const pp::Resource& resource) : Var(Null()) { | 21 VarResource::VarResource(const pp::Resource& resource) : Var(Null()) { |
| 22 if (!has_interface<PPB_VarResource_Dev_0_1>()) { | 22 if (!has_interface<PPB_VarResource_1_0>()) { |
| 23 PP_NOTREACHED(); | 23 PP_NOTREACHED(); |
| 24 return; | 24 return; |
| 25 } | 25 } |
| 26 | 26 |
| 27 // Note: Var(Null()) sets is_managed_ to true, so |var_| will be properly | 27 // Note: Var(Null()) sets is_managed_ to true, so |var_| will be properly |
| 28 // released upon destruction. | 28 // released upon destruction. |
| 29 var_ = get_interface<PPB_VarResource_Dev_0_1>()->VarFromResource( | 29 var_ = get_interface<PPB_VarResource_1_0>()->VarFromResource( |
| 30 resource.pp_resource()); | 30 resource.pp_resource()); |
| 31 } | 31 } |
| 32 | 32 |
| 33 VarResource_Dev::VarResource_Dev(const Var& var) : Var(var) { | 33 VarResource::VarResource(const Var& var) : Var(var) { |
| 34 if (!var.is_resource()) { | 34 if (!var.is_resource()) { |
| 35 PP_NOTREACHED(); | 35 PP_NOTREACHED(); |
| 36 | 36 |
| 37 // This takes care of releasing the reference that this object holds. | 37 // This takes care of releasing the reference that this object holds. |
| 38 Var::operator=(Var(Null())); | 38 Var::operator=(Var(Null())); |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 | 41 |
| 42 VarResource_Dev::VarResource_Dev(const VarResource_Dev& other) : Var(other) {} | 42 VarResource::VarResource(const VarResource& other) : Var(other) {} |
| 43 | 43 |
| 44 VarResource_Dev::~VarResource_Dev() {} | 44 VarResource::~VarResource() {} |
| 45 | 45 |
| 46 VarResource_Dev& VarResource_Dev::operator=(const VarResource_Dev& other) { | 46 VarResource& VarResource::operator=(const VarResource& other) { |
| 47 Var::operator=(other); | 47 Var::operator=(other); |
| 48 return *this; | 48 return *this; |
| 49 } | 49 } |
| 50 | 50 |
| 51 Var& VarResource_Dev::operator=(const Var& other) { | 51 Var& VarResource::operator=(const Var& other) { |
| 52 if (other.is_resource()) { | 52 if (other.is_resource()) { |
| 53 Var::operator=(other); | 53 Var::operator=(other); |
| 54 } else { | 54 } else { |
| 55 PP_NOTREACHED(); | 55 PP_NOTREACHED(); |
| 56 Var::operator=(Var(Null())); | 56 Var::operator=(Var(Null())); |
| 57 } | 57 } |
| 58 return *this; | 58 return *this; |
| 59 } | 59 } |
| 60 | 60 |
| 61 pp::Resource VarResource_Dev::AsResource() { | 61 pp::Resource VarResource::AsResource() { |
| 62 if (!has_interface<PPB_VarResource_Dev_0_1>()) | 62 if (!has_interface<PPB_VarResource_1_0>()) |
| 63 return pp::Resource(); | 63 return pp::Resource(); |
| 64 | 64 |
| 65 return pp::Resource( | 65 return pp::Resource( |
| 66 pp::PASS_REF, | 66 pp::PASS_REF, |
| 67 get_interface<PPB_VarResource_Dev_0_1>()->VarToResource(var_)); | 67 get_interface<PPB_VarResource_1_0>()->VarToResource(var_)); |
| 68 } | 68 } |
| 69 | 69 |
| 70 } // namespace pp | 70 } // namespace pp |
| OLD | NEW |