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

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

Issue 5581011: Resource tracking done right. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Updated for CoreInterface->PPBCoreInterface rename 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/plugin_resource.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) 2010 The Native Client Authors. All rights reserved. 1 // Copyright (c) 2010 The Native Client 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 "native_client/src/include/portability.h" 5 #include "native_client/src/include/portability.h"
6 #include "native_client/src/shared/ppapi_proxy/browser_globals.h"
6 #include "srpcgen/ppb_rpc.h" 7 #include "srpcgen/ppb_rpc.h"
7 8
8 // 9 //
9 // The following methods are the SRPC dispatchers for ppapi/c/ppb_core.h. 10 // The following methods are the SRPC dispatchers for ppapi/c/ppb_core.h.
10 // 11 //
11 12
12 void PpbCoreRpcServer::PPB_Core_AddRefResource(NaClSrpcRpc* rpc, 13 void PpbCoreRpcServer::PPB_Core_AddRefResource(NaClSrpcRpc* rpc,
13 NaClSrpcClosure* done, 14 NaClSrpcClosure* done,
14 int64_t resource) { 15 int64_t resource) {
15 NaClSrpcClosureRunner runner(done); 16 NaClSrpcClosureRunner runner(done);
16 rpc->result = NACL_SRPC_RESULT_APP_ERROR; 17 ppapi_proxy::PPBCoreInterface()->AddRefResource(resource);
17 // TODO(sehr): implement AddRefResource.
18 UNREFERENCED_PARAMETER(resource);
19 rpc->result = NACL_SRPC_RESULT_OK; 18 rpc->result = NACL_SRPC_RESULT_OK;
20 } 19 }
21 20
22 void PpbCoreRpcServer::PPB_Core_ReleaseResource(NaClSrpcRpc* rpc, 21 void PpbCoreRpcServer::PPB_Core_ReleaseResource(NaClSrpcRpc* rpc,
23 NaClSrpcClosure* done, 22 NaClSrpcClosure* done,
24 int64_t resource) { 23 int64_t resource) {
25 NaClSrpcClosureRunner runner(done); 24 NaClSrpcClosureRunner runner(done);
26 rpc->result = NACL_SRPC_RESULT_APP_ERROR; 25 ppapi_proxy::PPBCoreInterface()->ReleaseResource(resource);
27 // TODO(sehr): implement ReleaseResource.
28 UNREFERENCED_PARAMETER(resource);
29 rpc->result = NACL_SRPC_RESULT_OK; 26 rpc->result = NACL_SRPC_RESULT_OK;
30 } 27 }
31 28
32 // MemAlloc and MemFree are handled locally to the plugin, and do not need a 29 // MemAlloc and MemFree are handled locally to the plugin, and do not need a
33 // browser stub. 30 // browser stub.
34 31
35 void PpbCoreRpcServer::PPB_Core_GetTime(NaClSrpcRpc* rpc, 32 void PpbCoreRpcServer::PPB_Core_GetTime(NaClSrpcRpc* rpc,
36 NaClSrpcClosure* done, 33 NaClSrpcClosure* done,
37 double* time) { 34 double* time) {
38 NaClSrpcClosureRunner runner(done); 35 NaClSrpcClosureRunner runner(done);
39 rpc->result = NACL_SRPC_RESULT_APP_ERROR; 36 *time = ppapi_proxy::PPBCoreInterface()->GetTime();
40 // TODO(sehr): implement time.
41 *time = 0.0;
42 rpc->result = NACL_SRPC_RESULT_OK; 37 rpc->result = NACL_SRPC_RESULT_OK;
43 } 38 }
44 39
40 // Release multiple references at once.
41 void PpbCoreRpcServer::ReleaseResourceMultipleTimes(NaClSrpcRpc* rpc,
42 NaClSrpcClosure* done,
43 int64_t resource,
44 int32_t count) {
45 NaClSrpcClosureRunner runner(done);
46 while (count--)
47 ppapi_proxy::PPBCoreInterface()->ReleaseResource(resource);
48 rpc->result = NACL_SRPC_RESULT_OK;
49 }
50
51
45 // CallOnMainThread is handled on the upcall thread, where another RPC service 52 // CallOnMainThread is handled on the upcall thread, where another RPC service
46 // is exported. 53 // is exported.
47 // 54 //
48 // IsMainThread is handled locally to the plugin, and does not need a browser 55 // IsMainThread is handled locally to the plugin, and does not need a browser
49 // stub. 56 // stub.
OLDNEW
« no previous file with comments | « no previous file | src/shared/ppapi_proxy/plugin_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698