Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: ppapi/proxy/ppp_instance_private_proxy_unittest.cc

Issue 400823004: gin (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/ppb_testing_proxy.cc ('k') | ppapi/shared_impl/scoped_pp_var.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/test/test_timeouts.h" 7 #include "base/test/test_timeouts.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "ppapi/c/dev/ppb_var_deprecated.h" 9 #include "ppapi/c/dev/ppb_var_deprecated.h"
10 #include "ppapi/c/dev/ppp_class_deprecated.h" 10 #include "ppapi/c/dev/ppp_class_deprecated.h"
11 #include "ppapi/c/pp_var.h" 11 #include "ppapi/c/pp_var.h"
12 #include "ppapi/c/ppb_var.h" 12 #include "ppapi/c/ppb_var.h"
13 #include "ppapi/c/ppp_instance.h" 13 #include "ppapi/c/ppp_instance.h"
14 #include "ppapi/c/private/ppp_instance_private.h" 14 #include "ppapi/c/private/ppp_instance_private.h"
15 #include "ppapi/proxy/host_dispatcher.h" 15 #include "ppapi/proxy/host_dispatcher.h"
16 #include "ppapi/proxy/interface_list.h" 16 #include "ppapi/proxy/interface_list.h"
17 #include "ppapi/proxy/ppapi_proxy_test.h" 17 #include "ppapi/proxy/ppapi_proxy_test.h"
18 #include "ppapi/shared_impl/ppapi_permissions.h" 18 #include "ppapi/shared_impl/ppapi_permissions.h"
19 #include "ppapi/shared_impl/ppb_var_shared.h" 19 #include "ppapi/shared_impl/ppb_var_shared.h"
20 #include "ppapi/shared_impl/var.h" 20 #include "ppapi/shared_impl/var.h"
21 21
22 namespace ppapi { 22 namespace ppapi {
23 23
24 // A fake version of NPObjectVar for testing. 24 // A fake version of V8ObjectVar for testing.
25 class NPObjectVar : public ppapi::Var { 25 class V8ObjectVar : public ppapi::Var {
26 public: 26 public:
27 NPObjectVar() {} 27 V8ObjectVar() {}
28 virtual ~NPObjectVar() {} 28 virtual ~V8ObjectVar() {}
29 29
30 // Var overrides. 30 // Var overrides.
31 virtual NPObjectVar* AsNPObjectVar() OVERRIDE { return this; } 31 virtual V8ObjectVar* AsV8ObjectVar() OVERRIDE { return this; }
32 virtual PP_VarType GetType() const OVERRIDE { return PP_VARTYPE_OBJECT; } 32 virtual PP_VarType GetType() const OVERRIDE { return PP_VARTYPE_OBJECT; }
33 }; 33 };
34 34
35 namespace proxy { 35 namespace proxy {
36 36
37 namespace { 37 namespace {
38 const PP_Instance kInstance = 0xdeadbeef; 38 const PP_Instance kInstance = 0xdeadbeef;
39 39
40 PP_Var GetPPVarNoAddRef(Var* var) { 40 PP_Var GetPPVarNoAddRef(Var* var) {
41 PP_Var var_to_return = var->GetPPVar(); 41 PP_Var var_to_return = var->GetPPVar();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // deleted. 104 // deleted.
105 plugin_var_deprecated_if()->Release(instance_obj); 105 plugin_var_deprecated_if()->Release(instance_obj);
106 } 106 }
107 107
108 PPP_Instance_1_0 ppp_instance_mock = { &DidCreate, &DidDestroy }; 108 PPP_Instance_1_0 ppp_instance_mock = { &DidCreate, &DidDestroy };
109 109
110 // Mock PPB_Var_Deprecated, so that we can emulate creating an Object Var. 110 // Mock PPB_Var_Deprecated, so that we can emulate creating an Object Var.
111 PP_Var CreateObject(PP_Instance /*instance*/, 111 PP_Var CreateObject(PP_Instance /*instance*/,
112 const PPP_Class_Deprecated* /*ppp_class*/, 112 const PPP_Class_Deprecated* /*ppp_class*/,
113 void* /*ppp_class_data*/) { 113 void* /*ppp_class_data*/) {
114 NPObjectVar* obj_var = new NPObjectVar; 114 V8ObjectVar* obj_var = new V8ObjectVar;
115 return obj_var->GetPPVar(); 115 return obj_var->GetPPVar();
116 } 116 }
117 117
118 const PPB_Var_Deprecated ppb_var_deprecated_mock = { 118 const PPB_Var_Deprecated ppb_var_deprecated_mock = {
119 PPB_Var_Shared::GetVarInterface1_0()->AddRef, 119 PPB_Var_Shared::GetVarInterface1_0()->AddRef,
120 PPB_Var_Shared::GetVarInterface1_0()->Release, 120 PPB_Var_Shared::GetVarInterface1_0()->Release,
121 PPB_Var_Shared::GetVarInterface1_0()->VarFromUtf8, 121 PPB_Var_Shared::GetVarInterface1_0()->VarFromUtf8,
122 PPB_Var_Shared::GetVarInterface1_0()->VarToUtf8, 122 PPB_Var_Shared::GetVarInterface1_0()->VarToUtf8,
123 NULL, // HasProperty 123 NULL, // HasProperty
124 NULL, // HasMethod 124 NULL, // HasMethod
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 // Destroy the instance. DidDestroy above decrements the reference count for 201 // Destroy the instance. DidDestroy above decrements the reference count for
202 // instance_obj, so it should also be destroyed. 202 // instance_obj, so it should also be destroyed.
203 ppp_instance->DidDestroy(kInstance); 203 ppp_instance->DidDestroy(kInstance);
204 EXPECT_EQ(-1, plugin().var_tracker().GetRefCountForObject(instance_obj)); 204 EXPECT_EQ(-1, plugin().var_tracker().GetRefCountForObject(instance_obj));
205 EXPECT_EQ(-1, host().var_tracker().GetRefCountForObject(host_pp_var)); 205 EXPECT_EQ(-1, host().var_tracker().GetRefCountForObject(host_pp_var));
206 } 206 }
207 207
208 } // namespace proxy 208 } // namespace proxy
209 } // namespace ppapi 209 } // namespace ppapi
210 210
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_testing_proxy.cc ('k') | ppapi/shared_impl/scoped_pp_var.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698