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

Side by Side Diff: tests/fake_browser_ppapi/fake_instance.cc

Issue 6218004: Resource64->32, NaCl side. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: First Created 9 years, 11 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
OLDNEW
1 /* 1 /*
2 * Copyright 2010 The Native Client Authors. All rights reserved. 2 * Copyright 2010 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can 3 * Use of this source code is governed by a BSD-style license that can
4 * be found in the LICENSE file. 4 * be found in the LICENSE file.
5 */ 5 */
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include "native_client/tests/fake_browser_ppapi/fake_instance.h" 8 #include "native_client/tests/fake_browser_ppapi/fake_instance.h"
9 9
10 #include "native_client/src/include/nacl_macros.h" 10 #include "native_client/src/include/nacl_macros.h"
11 #include "native_client/src/include/portability.h" 11 #include "native_client/src/include/portability.h"
12 #include "native_client/tests/fake_browser_ppapi/fake_window.h" 12 #include "native_client/tests/fake_browser_ppapi/fake_window.h"
13 #include "native_client/tests/fake_browser_ppapi/utility.h" 13 #include "native_client/tests/fake_browser_ppapi/utility.h"
14 #include "ppapi/c/ppb_instance.h" 14 #include "ppapi/c/ppb_instance.h"
15 15
16 using fake_browser_ppapi::DebugPrintf; 16 using fake_browser_ppapi::DebugPrintf;
17 17
18 namespace fake_browser_ppapi { 18 namespace fake_browser_ppapi {
19 19
20 namespace { 20 namespace {
21 21
22 static Instance* GetInstancePointer(PP_Instance instance) {
23 return reinterpret_cast<Instance*>(static_cast<uintptr_t>(instance));
24 }
25
26 static PP_Var GetWindowObject(PP_Instance instance) { 22 static PP_Var GetWindowObject(PP_Instance instance) {
27 return GetInstancePointer(instance)->GetWindowObject(); 23 return GetInstance(instance)->GetWindowObject();
28 } 24 }
29 25
30 static PP_Var GetOwnerElementObject(PP_Instance instance) { 26 static PP_Var GetOwnerElementObject(PP_Instance instance) {
31 return GetInstancePointer(instance)->GetOwnerElementObject(); 27 return GetInstance(instance)->GetOwnerElementObject();
32 } 28 }
33 29
34 static PP_Bool BindGraphics(PP_Instance instance, PP_Resource device) { 30 static PP_Bool BindGraphics(PP_Instance instance, PP_Resource device) {
35 return 31 return static_cast<PP_Bool>(GetInstance(instance)->BindGraphics(device));
36 static_cast<PP_Bool>(GetInstancePointer(instance)->BindGraphics(device));
37 } 32 }
38 33
39 static PP_Bool IsFullFrame(PP_Instance instance) { 34 static PP_Bool IsFullFrame(PP_Instance instance) {
40 return static_cast<PP_Bool>(GetInstancePointer(instance)->IsFullFrame()); 35 return static_cast<PP_Bool>(GetInstance(instance)->IsFullFrame());
41 } 36 }
42 37
43 static PP_Var ExecuteScript(PP_Instance instance, 38 static PP_Var ExecuteScript(PP_Instance instance,
44 PP_Var script, 39 PP_Var script,
45 PP_Var* exception) { 40 PP_Var* exception) {
46 return GetInstancePointer(instance)->ExecuteScript(script, exception); 41 return GetInstance(instance)->ExecuteScript(script, exception);
47 } 42 }
48 43
49 } // namespace 44 } // namespace
50 45
46 Instance Instance::kInvalidInstance;
47
51 PP_Var Instance::GetWindowObject() { 48 PP_Var Instance::GetWindowObject() {
52 DebugPrintf("Instance::GetWindowObject: instance=%p\n", 49 DebugPrintf("Instance::GetWindowObject: instance=%"NACL_PRId32"\n",
53 reinterpret_cast<void*>(this)); 50 instance_id_);
54 return window_->FakeWindowObject(); 51 if (window_)
52 return window_->FakeWindowObject();
53 else
54 return PP_MakeUndefined();
55 } 55 }
56 56
57 PP_Var Instance::GetOwnerElementObject() { 57 PP_Var Instance::GetOwnerElementObject() {
58 DebugPrintf("Instance::GetOwnerElementObject: instance=%p\n", 58 DebugPrintf("Instance::GetOwnerElementObject: instance=%"NACL_PRId32"\n",
59 reinterpret_cast<void*>(this)); 59 instance_id_);
60 NACL_UNIMPLEMENTED(); 60 NACL_UNIMPLEMENTED();
61 return PP_MakeUndefined(); 61 return PP_MakeUndefined();
62 } 62 }
63 63
64 bool Instance::BindGraphics(PP_Resource device) { 64 bool Instance::BindGraphics(PP_Resource device) {
65 DebugPrintf("Instance::BindGraphicsDeviceContext: instance=%p" 65 DebugPrintf("Instance::BindGraphicsDeviceContext: instance=%"NACL_PRId32"\n",
66 ", device=%"NACL_PRIu64"\n", 66 ", device=%"NACL_PRIu32"\n",
67 reinterpret_cast<void*>(this), device); 67 instance_id_,
68 device);
68 NACL_UNIMPLEMENTED(); 69 NACL_UNIMPLEMENTED();
69 return false; 70 return false;
70 } 71 }
71 72
72 bool Instance::IsFullFrame() { 73 bool Instance::IsFullFrame() {
73 DebugPrintf("Instance::IsFullFrame: instance=%p\n", 74 DebugPrintf("Instance::IsFullFrame: instance=%"NACL_PRId32"\n",
74 reinterpret_cast<void*>(this)); 75 instance_id_);
75 NACL_UNIMPLEMENTED(); 76 NACL_UNIMPLEMENTED();
76 return false; 77 return false;
77 } 78 }
78 79
79 PP_Var Instance::ExecuteScript(PP_Var script, 80 PP_Var Instance::ExecuteScript(PP_Var script,
80 PP_Var* exception) { 81 PP_Var* exception) {
81 DebugPrintf("Instance::ExecuteScript: instance=%p\n", 82 DebugPrintf("Instance::ExecuteScript: instance=%"NACL_PRId32"\n",
82 reinterpret_cast<void*>(this)); 83 instance_id_);
83 NACL_UNIMPLEMENTED(); 84 NACL_UNIMPLEMENTED();
84 UNREFERENCED_PARAMETER(script); 85 UNREFERENCED_PARAMETER(script);
85 UNREFERENCED_PARAMETER(exception); 86 UNREFERENCED_PARAMETER(exception);
86 return PP_MakeUndefined(); 87 return PP_MakeUndefined();
87 } 88 }
88 89
89 const PPB_Instance* Instance::GetInterface() { 90 const PPB_Instance* Instance::GetInterface() {
90 static const PPB_Instance instance_interface = { 91 static const PPB_Instance instance_interface = {
91 fake_browser_ppapi::GetWindowObject, 92 fake_browser_ppapi::GetWindowObject,
92 fake_browser_ppapi::GetOwnerElementObject, 93 fake_browser_ppapi::GetOwnerElementObject,
93 fake_browser_ppapi::BindGraphics, 94 fake_browser_ppapi::BindGraphics,
94 fake_browser_ppapi::IsFullFrame, 95 fake_browser_ppapi::IsFullFrame,
95 fake_browser_ppapi::ExecuteScript 96 fake_browser_ppapi::ExecuteScript
96 }; 97 };
97 return &instance_interface; 98 return &instance_interface;
98 } 99 }
99 100
100 } // namespace fake_browser_ppapi 101 } // namespace fake_browser_ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698