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

Side by Side Diff: tests/fake_browser_ppapi/fake_file_io_trusted.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 "native_client/tests/fake_browser_ppapi/fake_file_io_trusted.h" 7 #include "native_client/tests/fake_browser_ppapi/fake_file_io_trusted.h"
8 8
9 #include "native_client/src/include/nacl_macros.h" 9 #include "native_client/src/include/nacl_macros.h"
10 #include "native_client/src/include/portability.h" 10 #include "native_client/src/include/portability.h"
11 11
12 #include "native_client/tests/fake_browser_ppapi/fake_file_io.h" 12 #include "native_client/tests/fake_browser_ppapi/fake_file_io.h"
13 #include "native_client/tests/fake_browser_ppapi/fake_resource.h" 13 #include "native_client/tests/fake_browser_ppapi/fake_resource.h"
14 #include "native_client/tests/fake_browser_ppapi/utility.h" 14 #include "native_client/tests/fake_browser_ppapi/utility.h"
15 15
16 #include "ppapi/c/pp_errors.h" 16 #include "ppapi/c/pp_errors.h"
17 #include "ppapi/c/pp_completion_callback.h" 17 #include "ppapi/c/pp_completion_callback.h"
18 #include "ppapi/c/pp_resource.h" 18 #include "ppapi/c/pp_resource.h"
19 19
20 using fake_browser_ppapi::DebugPrintf; 20 using fake_browser_ppapi::DebugPrintf;
21 21
22 namespace fake_browser_ppapi { 22 namespace fake_browser_ppapi {
23 23
24 namespace { 24 namespace {
25 25
26 int32_t GetOSFileDescriptor(PP_Resource file_io_id) { 26 int32_t GetOSFileDescriptor(PP_Resource file_io_id) {
27 DebugPrintf("FileIOTrusted::GetOSFileDescriptor: file_io_id=%"NACL_PRId64"\n", 27 DebugPrintf("FileIOTrusted::GetOSFileDescriptor: file_io_id=%"NACL_PRId32"\n",
28 file_io_id); 28 file_io_id);
29 FileIO* file_io = GetResource(file_io_id)->AsFileIO(); 29 FileIO* file_io = GetResource(file_io_id)->AsFileIO();
30 if (file_io == NULL) 30 if (file_io == NULL)
31 return NACL_NO_FILE_DESC; 31 return NACL_NO_FILE_DESC;
32 32
33 int32_t posix_file_desc = file_io->file_desc(); 33 int32_t posix_file_desc = file_io->file_desc();
34 34
35 #if NACL_WINDOWS 35 #if NACL_WINDOWS
36 // On Windows, return the underlying HANDLE to mimic the behavior 36 // On Windows, return the underlying HANDLE to mimic the behavior
37 // of PPAPI in Chrome. Windows HANDLEs can be safely trunated to int32_t. 37 // of PPAPI in Chrome. Windows HANDLEs can be safely trunated to int32_t.
38 posix_file_desc = static_cast<int32_t>(_get_osfhandle(posix_file_desc)); 38 posix_file_desc = static_cast<int32_t>(_get_osfhandle(posix_file_desc));
39 #endif 39 #endif
40 40
41 return posix_file_desc; 41 return posix_file_desc;
42 } 42 }
43 43
44 int32_t WillWrite(PP_Resource file_io_id, 44 int32_t WillWrite(PP_Resource file_io_id,
45 int64_t offset, 45 int64_t offset,
46 int32_t bytes_to_write, 46 int32_t bytes_to_write,
47 struct PP_CompletionCallback callback) { 47 struct PP_CompletionCallback callback) {
48 DebugPrintf("FileIOTrusted::WillWrite: file_io_id=%"NACL_PRId64"\n", 48 DebugPrintf("FileIOTrusted::WillWrite: file_io_id=%"NACL_PRId32"\n",
49 file_io_id); 49 file_io_id);
50 UNREFERENCED_PARAMETER(offset); 50 UNREFERENCED_PARAMETER(offset);
51 UNREFERENCED_PARAMETER(bytes_to_write); 51 UNREFERENCED_PARAMETER(bytes_to_write);
52 UNREFERENCED_PARAMETER(callback); 52 UNREFERENCED_PARAMETER(callback);
53 NACL_UNIMPLEMENTED(); 53 NACL_UNIMPLEMENTED();
54 return PP_ERROR_FAILED; 54 return PP_ERROR_FAILED;
55 } 55 }
56 56
57 int32_t WillSetLength(PP_Resource file_io_id, 57 int32_t WillSetLength(PP_Resource file_io_id,
58 int64_t length, 58 int64_t length,
59 struct PP_CompletionCallback callback) { 59 struct PP_CompletionCallback callback) {
60 DebugPrintf("FileIOTrusted::WillSetLength: file_io_id=%"NACL_PRId64"\n", 60 DebugPrintf("FileIOTrusted::WillSetLength: file_io_id=%"NACL_PRId32"\n",
61 file_io_id); 61 file_io_id);
62 UNREFERENCED_PARAMETER(length); 62 UNREFERENCED_PARAMETER(length);
63 UNREFERENCED_PARAMETER(callback); 63 UNREFERENCED_PARAMETER(callback);
64 NACL_UNIMPLEMENTED(); 64 NACL_UNIMPLEMENTED();
65 return PP_ERROR_FAILED; 65 return PP_ERROR_FAILED;
66 } 66 }
67 67
68 } // namespace 68 } // namespace
69 69
70 70
71 const PPB_FileIOTrusted_Dev* FileIOTrusted::GetInterface() { 71 const PPB_FileIOTrusted_Dev* FileIOTrusted::GetInterface() {
72 static const PPB_FileIOTrusted_Dev file_io_trusted_interface = { 72 static const PPB_FileIOTrusted_Dev file_io_trusted_interface = {
73 GetOSFileDescriptor, 73 GetOSFileDescriptor,
74 WillWrite, 74 WillWrite,
75 WillSetLength 75 WillSetLength
76 }; 76 };
77 return &file_io_trusted_interface; 77 return &file_io_trusted_interface;
78 } 78 }
79 79
80 } // namespace fake_browser_ppapi 80 } // namespace fake_browser_ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698