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

Side by Side Diff: src/shared/ppapi_proxy/browser_instance.cc

Issue 5631003: ppapi_proxy: Make DebugPrintf more usable.... (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 10 years 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 | « no previous file | src/shared/ppapi_proxy/browser_ppp.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "native_client/src/shared/ppapi_proxy/browser_instance.h" 7 #include "native_client/src/shared/ppapi_proxy/browser_instance.h"
8 8
9 #include <stdio.h> 9 #include <stdio.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 size_t pos = 0; 60 size_t pos = 0;
61 for (int i = 0; i < argc; ++i) { 61 for (int i = 0; i < argc; ++i) {
62 size_t len = strlen(array[i]) + 1; 62 size_t len = strlen(array[i]) + 1;
63 strncpy(serial_array + pos, array[i], len); 63 strncpy(serial_array + pos, array[i], len);
64 pos += len; 64 pos += len;
65 } 65 }
66 return serial_array; 66 return serial_array;
67 } 67 }
68 68
69 PP_Bool DidCreate(PP_Instance instance, 69 PP_Bool DidCreate(PP_Instance instance,
70 uint32_t argc, 70 uint32_t argc,
71 const char* argn[], 71 const char* argn[],
72 const char* argv[]) { 72 const char* argv[]) {
73 DebugPrintf("BrowserInstance::DidCreate(%"NACL_PRId64")\n", instance); 73 DebugPrintf("Browser::PPP_Instance::DidCreate(%"NACL_PRId64")\n", instance);
74 uint32_t argn_size; 74 uint32_t argn_size;
75 scoped_array<char> argn_serial(ArgArraySerialize(argc, argn, &argn_size)); 75 scoped_array<char> argn_serial(ArgArraySerialize(argc, argn, &argn_size));
76 if (argn_serial.get() == NULL) { 76 if (argn_serial.get() == NULL) {
77 return PP_FALSE; 77 return PP_FALSE;
78 } 78 }
79 uint32_t argv_size; 79 uint32_t argv_size;
80 scoped_array<char> argv_serial(ArgArraySerialize(argc, argv, &argv_size)); 80 scoped_array<char> argv_serial(ArgArraySerialize(argc, argv, &argv_size));
81 if (argv_serial.get() == NULL) { 81 if (argv_serial.get() == NULL) {
82 return PP_FALSE; 82 return PP_FALSE;
83 } 83 }
84 NaClSrpcChannel* channel = LookupBrowserPppForInstance(instance)->channel(); 84 NaClSrpcChannel* channel = LookupBrowserPppForInstance(instance)->channel();
85 int32_t int_argc = static_cast<int32_t>(argc); 85 int32_t int_argc = static_cast<int32_t>(argc);
86 int32_t success; 86 int32_t success;
87 NaClSrpcError retval = 87 NaClSrpcError retval =
88 PppInstanceRpcClient::PPP_Instance_DidCreate(channel, 88 PppInstanceRpcClient::PPP_Instance_DidCreate(channel,
89 instance, 89 instance,
90 int_argc, 90 int_argc,
91 argn_size, 91 argn_size,
92 argn_serial.get(), 92 argn_serial.get(),
93 argv_size, 93 argv_size,
94 argv_serial.get(), 94 argv_serial.get(),
95 &success); 95 &success);
96 if (retval != NACL_SRPC_RESULT_OK) { 96 if (retval != NACL_SRPC_RESULT_OK) {
97 return PP_FALSE; 97 return PP_FALSE;
98 } 98 }
99 return static_cast<PP_Bool>(success != 0); 99 return static_cast<PP_Bool>(success != 0);
100 } 100 }
101 101
102 void DidDestroy(PP_Instance instance) { 102 void DidDestroy(PP_Instance instance) {
103 DebugPrintf("BrowserInstance::Delete(%"NACL_PRId64")\n", instance); 103 DebugPrintf("Browser::PPP_Instance::Delete(%"NACL_PRId64")\n", instance);
104 NaClSrpcChannel* channel = LookupBrowserPppForInstance(instance)->channel(); 104 NaClSrpcChannel* channel = LookupBrowserPppForInstance(instance)->channel();
105 (void) PppInstanceRpcClient::PPP_Instance_DidDestroy(channel, instance); 105 (void) PppInstanceRpcClient::PPP_Instance_DidDestroy(channel, instance);
106 } 106 }
107 107
108 void DidChangeView(PP_Instance instance, 108 void DidChangeView(PP_Instance instance,
109 const PP_Rect* position, 109 const PP_Rect* position,
110 const PP_Rect* clip) { 110 const PP_Rect* clip) {
111 DebugPrintf("BrowserInstance::DidChangeView(%"NACL_PRId64")\n", instance); 111 DebugPrintf("Browser::PPP_Instance::DidChangeView(%"NACL_PRId64")\n",
112 instance);
112 NaClSrpcChannel* channel = LookupBrowserPppForInstance(instance)->channel(); 113 NaClSrpcChannel* channel = LookupBrowserPppForInstance(instance)->channel();
113 int32_t position_array[4]; 114 int32_t position_array[4];
114 const uint32_t kPositionArraySize = NACL_ARRAY_SIZE(position_array); 115 const uint32_t kPositionArraySize = NACL_ARRAY_SIZE(position_array);
115 position_array[0] = position->point.x; 116 position_array[0] = position->point.x;
116 position_array[1] = position->point.y; 117 position_array[1] = position->point.y;
117 position_array[2] = position->size.width; 118 position_array[2] = position->size.width;
118 position_array[3] = position->size.height; 119 position_array[3] = position->size.height;
119 int32_t clip_array[4]; 120 int32_t clip_array[4];
120 const uint32_t kClipArraySize = NACL_ARRAY_SIZE(clip_array); 121 const uint32_t kClipArraySize = NACL_ARRAY_SIZE(clip_array);
121 clip_array[0] = clip->point.x; 122 clip_array[0] = clip->point.x;
122 clip_array[1] = clip->point.y; 123 clip_array[1] = clip->point.y;
123 clip_array[2] = clip->size.width; 124 clip_array[2] = clip->size.width;
124 clip_array[3] = clip->size.height; 125 clip_array[3] = clip->size.height;
125 (void) PppInstanceRpcClient::PPP_Instance_DidChangeView(channel, 126 (void) PppInstanceRpcClient::PPP_Instance_DidChangeView(channel,
126 instance, 127 instance,
127 kPositionArraySize, 128 kPositionArraySize,
128 position_array, 129 position_array,
129 kClipArraySize, 130 kClipArraySize,
130 clip_array); 131 clip_array);
131 } 132 }
132 133
133 void DidChangeFocus(PP_Instance instance, PP_Bool has_focus) { 134 void DidChangeFocus(PP_Instance instance, PP_Bool has_focus) {
134 DebugPrintf("BrowserInstance::DidChangeFocus(%"NACL_PRId64")\n", instance); 135 DebugPrintf("Browser::PPP_Instance::DidChangeFocus(%"NACL_PRId64")\n",
136 instance);
135 NaClSrpcChannel* channel = LookupBrowserPppForInstance(instance)->channel(); 137 NaClSrpcChannel* channel = LookupBrowserPppForInstance(instance)->channel();
136 // DidChangeFocus() always succeeds, no need to check the SRPC return value. 138 // DidChangeFocus() always succeeds, no need to check the SRPC return value.
137 (void) PppInstanceRpcClient::PPP_Instance_DidChangeFocus(channel, 139 (void) PppInstanceRpcClient::PPP_Instance_DidChangeFocus(channel,
138 instance, static_cast<bool>(PP_TRUE == has_focus)); 140 instance, static_cast<bool>(PP_TRUE == has_focus));
139 } 141 }
140 142
141 PP_Bool HandleInputEvent(PP_Instance instance, const PP_InputEvent* event) { 143 PP_Bool HandleInputEvent(PP_Instance instance, const PP_InputEvent* event) {
142 DebugPrintf("BrowserInstance::HandleInputEvent(%"NACL_PRId64")\n", instance); 144 DebugPrintf("Browser::PPP_Instance::HandleInputEvent(%"NACL_PRId64")\n",
145 instance);
143 NaClSrpcChannel* channel = LookupBrowserPppForInstance(instance)->channel(); 146 NaClSrpcChannel* channel = LookupBrowserPppForInstance(instance)->channel();
144 int32_t success; 147 int32_t success;
145 char* event_data = const_cast<char*>(reinterpret_cast<const char*>(event)); 148 char* event_data = const_cast<char*>(reinterpret_cast<const char*>(event));
146 NaClSrpcError retval = 149 NaClSrpcError retval =
147 PppInstanceRpcClient::PPP_Instance_HandleInputEvent(channel, 150 PppInstanceRpcClient::PPP_Instance_HandleInputEvent(channel,
148 instance, 151 instance,
149 sizeof(*event), 152 sizeof(*event),
150 event_data, 153 event_data,
151 &success); 154 &success);
152 if (retval != NACL_SRPC_RESULT_OK) { 155 if (retval != NACL_SRPC_RESULT_OK) {
153 return PP_FALSE; 156 return PP_FALSE;
154 } 157 }
155 return static_cast<PP_Bool>(success != 0); 158 return static_cast<PP_Bool>(success != 0);
156 } 159 }
157 160
158 PP_Bool HandleDocumentLoad(PP_Instance instance, PP_Resource url_loader) { 161 PP_Bool HandleDocumentLoad(PP_Instance instance, PP_Resource url_loader) {
159 DebugPrintf("BrowserInstance::HandleDocumentLoad(%"NACL_PRId64")\n", 162 DebugPrintf("Browser::PPP_Instance::HandleDocumentLoad(%"NACL_PRId64")\n",
160 instance); 163 instance);
161 // TODO(sehr): implement HandleDocumentLoad. 164 // TODO(sehr): implement HandleDocumentLoad.
162 UNREFERENCED_PARAMETER(instance); 165 UNREFERENCED_PARAMETER(instance);
163 UNREFERENCED_PARAMETER(url_loader); 166 UNREFERENCED_PARAMETER(url_loader);
164 return PP_FALSE; 167 return PP_FALSE;
165 } 168 }
166 169
167 PP_Var GetInstanceObject(PP_Instance instance) { 170 PP_Var GetInstanceObject(PP_Instance instance) {
168 DebugPrintf("BrowserInstance::GetInstanceObject(%"NACL_PRId64")\n", instance); 171 DebugPrintf("Browser::PPP_Instance::GetInstanceObject(%"NACL_PRId64")\n",
172 instance);
169 NaClSrpcChannel* channel = LookupBrowserPppForInstance(instance)->channel(); 173 NaClSrpcChannel* channel = LookupBrowserPppForInstance(instance)->channel();
170 ObjectCapability capability; 174 ObjectCapability capability;
171 uint32_t capability_bytes = static_cast<uint32_t>(sizeof(capability)); 175 uint32_t capability_bytes = static_cast<uint32_t>(sizeof(capability));
172 NaClSrpcError retval = 176 NaClSrpcError retval =
173 PppInstanceRpcClient::PPP_Instance_GetInstanceObject( 177 PppInstanceRpcClient::PPP_Instance_GetInstanceObject(
174 channel, 178 channel,
175 instance, 179 instance,
176 &capability_bytes, 180 &capability_bytes,
177 reinterpret_cast<char*>(&capability)); 181 reinterpret_cast<char*>(&capability));
178 if (retval != NACL_SRPC_RESULT_OK) { 182 if (retval != NACL_SRPC_RESULT_OK) {
(...skipping 10 matching lines...) Expand all
189 DidChangeView, 193 DidChangeView,
190 DidChangeFocus, 194 DidChangeFocus,
191 HandleInputEvent, 195 HandleInputEvent,
192 HandleDocumentLoad, 196 HandleDocumentLoad,
193 GetInstanceObject 197 GetInstanceObject
194 }; 198 };
195 return &intf; 199 return &intf;
196 } 200 }
197 201
198 } // namespace ppapi_proxy 202 } // namespace ppapi_proxy
OLDNEW
« no previous file with comments | « no previous file | src/shared/ppapi_proxy/browser_ppp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698