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

Side by Side Diff: ppapi/native_client/src/shared/ppapi_proxy/plugin_nacl_file.cc

Issue 7740013: Cloning a bunch of stuff from the native_client repository at r6528 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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
OLDNEW
(Empty)
1 /*
2 Copyright (c) 2011 The Native Client Authors. All rights reserved.
3 Use of this source code is governed by a BSD-style license that can be
4 found in the LICENSE file.
5 */
6
7 #include "native_client/src/include/nacl_macros.h"
8 #include "native_client/src/shared/ppapi_proxy/plugin_callback.h"
9 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h"
10 #include "native_client/src/shared/ppapi_proxy/plugin_nacl_file.h"
11 #include "native_client/src/shared/ppapi_proxy/utility.h"
12 #include "native_client/src/shared/srpc/nacl_srpc.h"
13 #include "ppapi/c/pp_errors.h"
14 #include "srpcgen/ppb_rpc.h"
15
16 namespace ppapi_proxy {
17
18 int32_t StreamAsFile(PP_Instance instance,
19 const char* url,
20 struct PP_CompletionCallback callback) {
21 DebugPrintf("NaClFile::StreamAsFile: instance=%"NACL_PRIu32" url=%s\n",
22 instance, url);
23
24 int32_t callback_id =
25 CompletionCallbackTable::Get()->AddCallback(callback);
26 if (callback_id == 0)
27 return PP_ERROR_BADARGUMENT;
28
29 NaClSrpcError srpc_result = NaClFileRpcClient::StreamAsFile(
30 GetMainSrpcChannel(), instance, const_cast<char*>(url), callback_id);
31 DebugPrintf("NaClFile::StreamAsFile: %s\n", NaClSrpcErrorString(srpc_result));
32
33 if (srpc_result == NACL_SRPC_RESULT_OK)
34 return PP_OK_COMPLETIONPENDING;
35 return MayForceCallback(callback, PP_ERROR_FAILED);
36 }
37
38
39 int GetFileDesc(PP_Instance instance, const char* url) {
40 DebugPrintf("NaClFile::GetFileDesc: instance=%"NACL_PRIu32" url=%s\n",
41 instance, url);
42
43 int file_desc;
44 NaClSrpcError srpc_result = NaClFileRpcClient::GetFileDesc(
45 GetMainSrpcChannel(), instance, const_cast<char*>(url), &file_desc);
46 DebugPrintf("NaClFile::GetFileDesc: %s\n", NaClSrpcErrorString(srpc_result));
47
48 if (srpc_result == NACL_SRPC_RESULT_OK)
49 return file_desc;
50 return NACL_NO_FILE_DESC;
51 }
52
53 } // namespace ppapi_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698