| 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 <stdint.h> |
| 6 |
| 5 #include "base/bind.h" | 7 #include "base/bind.h" |
| 6 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 7 #include "base/test/test_timeouts.h" | 9 #include "base/test/test_timeouts.h" |
| 8 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 9 #include "ppapi/c/dev/ppb_var_deprecated.h" | 11 #include "ppapi/c/dev/ppb_var_deprecated.h" |
| 10 #include "ppapi/c/dev/ppp_class_deprecated.h" | 12 #include "ppapi/c/dev/ppp_class_deprecated.h" |
| 11 #include "ppapi/c/pp_var.h" | 13 #include "ppapi/c/pp_var.h" |
| 12 #include "ppapi/c/ppb_var.h" | 14 #include "ppapi/c/ppb_var.h" |
| 13 #include "ppapi/c/ppp_instance.h" | 15 #include "ppapi/c/ppp_instance.h" |
| 14 #include "ppapi/c/private/ppp_instance_private.h" | 16 #include "ppapi/c/private/ppp_instance_private.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 PPP_INSTANCE_INTERFACE_1_1)); | 173 PPP_INSTANCE_INTERFACE_1_1)); |
| 172 | 174 |
| 173 // Initialize an Instance, so that the plugin-side machinery will work | 175 // Initialize an Instance, so that the plugin-side machinery will work |
| 174 // properly. | 176 // properly. |
| 175 EXPECT_EQ(PP_TRUE, ppp_instance->DidCreate(kInstance, 0, NULL, NULL)); | 177 EXPECT_EQ(PP_TRUE, ppp_instance->DidCreate(kInstance, 0, NULL, NULL)); |
| 176 | 178 |
| 177 // Check the plugin-side reference count. | 179 // Check the plugin-side reference count. |
| 178 EXPECT_EQ(1, plugin().var_tracker().GetRefCountForObject(instance_obj)); | 180 EXPECT_EQ(1, plugin().var_tracker().GetRefCountForObject(instance_obj)); |
| 179 // Check the host-side var exists with the expected id and has 1 refcount (the | 181 // Check the host-side var exists with the expected id and has 1 refcount (the |
| 180 // refcount on behalf of the plugin). | 182 // refcount on behalf of the plugin). |
| 181 int32 expected_host_id = | 183 int32_t expected_host_id = |
| 182 plugin().var_tracker().GetHostObject(instance_obj).value.as_id; | 184 plugin().var_tracker().GetHostObject(instance_obj).value.as_id; |
| 183 Var* host_var = host().var_tracker().GetVar(expected_host_id); | 185 Var* host_var = host().var_tracker().GetVar(expected_host_id); |
| 184 ASSERT_TRUE(host_var); | 186 ASSERT_TRUE(host_var); |
| 185 EXPECT_EQ( | 187 EXPECT_EQ( |
| 186 1, | 188 1, |
| 187 host().var_tracker().GetRefCountForObject(GetPPVarNoAddRef(host_var))); | 189 host().var_tracker().GetRefCountForObject(GetPPVarNoAddRef(host_var))); |
| 188 | 190 |
| 189 // Call from the browser side to get the instance object. | 191 // Call from the browser side to get the instance object. |
| 190 PP_Var host_pp_var = ppp_instance_private->GetInstanceObject(kInstance); | 192 PP_Var host_pp_var = ppp_instance_private->GetInstanceObject(kInstance); |
| 191 EXPECT_EQ(instance_obj.type, host_pp_var.type); | 193 EXPECT_EQ(instance_obj.type, host_pp_var.type); |
| 192 EXPECT_EQ(host_pp_var.value.as_id, expected_host_id); | 194 EXPECT_EQ(host_pp_var.value.as_id, expected_host_id); |
| 193 EXPECT_EQ(1, plugin().var_tracker().GetRefCountForObject(instance_obj)); | 195 EXPECT_EQ(1, plugin().var_tracker().GetRefCountForObject(instance_obj)); |
| 194 // A reference is passed to the browser, which we consume here. | 196 // A reference is passed to the browser, which we consume here. |
| 195 host().var_tracker().ReleaseVar(host_pp_var); | 197 host().var_tracker().ReleaseVar(host_pp_var); |
| 196 EXPECT_EQ(1, host().var_tracker().GetRefCountForObject(host_pp_var)); | 198 EXPECT_EQ(1, host().var_tracker().GetRefCountForObject(host_pp_var)); |
| 197 | 199 |
| 198 // The plugin is going away; generally, so will all references to its instance | 200 // The plugin is going away; generally, so will all references to its instance |
| 199 // object. | 201 // object. |
| 200 host().var_tracker().ReleaseVar(host_pp_var); | 202 host().var_tracker().ReleaseVar(host_pp_var); |
| 201 // Destroy the instance. DidDestroy above decrements the reference count for | 203 // Destroy the instance. DidDestroy above decrements the reference count for |
| 202 // instance_obj, so it should also be destroyed. | 204 // instance_obj, so it should also be destroyed. |
| 203 ppp_instance->DidDestroy(kInstance); | 205 ppp_instance->DidDestroy(kInstance); |
| 204 EXPECT_EQ(-1, plugin().var_tracker().GetRefCountForObject(instance_obj)); | 206 EXPECT_EQ(-1, plugin().var_tracker().GetRefCountForObject(instance_obj)); |
| 205 EXPECT_EQ(-1, host().var_tracker().GetRefCountForObject(host_pp_var)); | 207 EXPECT_EQ(-1, host().var_tracker().GetRefCountForObject(host_pp_var)); |
| 206 } | 208 } |
| 207 | 209 |
| 208 } // namespace proxy | 210 } // namespace proxy |
| 209 } // namespace ppapi | 211 } // namespace ppapi |
| 210 | 212 |
| OLD | NEW |