OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 // A collection of debugging related interfaces. | 7 // A collection of debugging related interfaces. |
8 | 8 |
9 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_UTILITY_H_ | 9 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_UTILITY_H_ |
10 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_UTILITY_H_ | 10 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_UTILITY_H_ |
11 | 11 |
12 #include "native_client/src/include/nacl_macros.h" | 12 #include "native_client/src/include/nacl_macros.h" |
13 #include "native_client/src/include/portability.h" | 13 #include "native_client/src/include/portability.h" |
14 #include "native_client/src/shared/platform/nacl_threads.h" | 14 #include "native_client/src/shared/platform/nacl_threads.h" |
15 #include "native_client/src/shared/platform/nacl_time.h" | 15 #include "native_client/src/shared/platform/nacl_time.h" |
| 16 #include "ppapi/c/private/pp_file_handle.h" |
16 #include "ppapi/c/private/ppb_nacl_private.h" | 17 #include "ppapi/c/private/ppb_nacl_private.h" |
17 | 18 |
18 #define SRPC_PLUGIN_DEBUG 1 | 19 #define SRPC_PLUGIN_DEBUG 1 |
19 | 20 |
20 namespace plugin { | 21 namespace plugin { |
21 | 22 |
22 // Tests that a string is a valid JavaScript identifier. According to the | 23 // Tests that a string is a valid JavaScript identifier. According to the |
23 // ECMAScript spec, this should be done in terms of unicode character | 24 // ECMAScript spec, this should be done in terms of unicode character |
24 // categories. For now, we are simply limiting identifiers to the ASCII | 25 // categories. For now, we are simply limiting identifiers to the ASCII |
25 // subset of that spec. If successful, it returns the length of the | 26 // subset of that spec. If successful, it returns the length of the |
26 // identifier in the location pointed to by length (if it is not NULL). | 27 // identifier in the location pointed to by length (if it is not NULL). |
27 // TODO(sehr): add Unicode identifier support. | 28 // TODO(sehr): add Unicode identifier support. |
28 bool IsValidIdentifierString(const char* strval, uint32_t* length); | 29 bool IsValidIdentifierString(const char* strval, uint32_t* length); |
29 | 30 |
30 const PPB_NaCl_Private* GetNaClInterface(); | 31 const PPB_NaCl_Private* GetNaClInterface(); |
31 void SetNaClInterface(const PPB_NaCl_Private* nacl_interface); | 32 void SetNaClInterface(const PPB_NaCl_Private* nacl_interface); |
32 | 33 |
| 34 void CloseFileHandle(PP_FileHandle file_handle); |
| 35 |
| 36 // Converts a PP_FileHandle to a POSIX file descriptor. |
| 37 int32_t ConvertFileDescriptor(PP_FileHandle handle, bool read_only); |
| 38 |
33 // Debugging print utility | 39 // Debugging print utility |
34 extern int gNaClPluginDebugPrintEnabled; | 40 extern int gNaClPluginDebugPrintEnabled; |
35 extern int NaClPluginPrintLog(const char *format, ...); | 41 extern int NaClPluginPrintLog(const char *format, ...); |
36 extern int NaClPluginDebugPrintCheckEnv(); | 42 extern int NaClPluginDebugPrintCheckEnv(); |
37 #if SRPC_PLUGIN_DEBUG | 43 #if SRPC_PLUGIN_DEBUG |
38 #define INIT_PLUGIN_LOGGING() do { \ | 44 #define INIT_PLUGIN_LOGGING() do { \ |
39 if (-1 == ::plugin::gNaClPluginDebugPrintEnabled) { \ | 45 if (-1 == ::plugin::gNaClPluginDebugPrintEnabled) { \ |
40 ::plugin::gNaClPluginDebugPrintEnabled = \ | 46 ::plugin::gNaClPluginDebugPrintEnabled = \ |
41 ::plugin::NaClPluginDebugPrintCheckEnv(); \ | 47 ::plugin::NaClPluginDebugPrintCheckEnv(); \ |
42 } \ | 48 } \ |
(...skipping 19 matching lines...) Expand all Loading... |
62 } while (0) | 68 } while (0) |
63 #else | 69 #else |
64 # define PLUGIN_PRINTF(args) do { if (0) { printf args; } } while (0) | 70 # define PLUGIN_PRINTF(args) do { if (0) { printf args; } } while (0) |
65 # define MODULE_PRINTF(args) do { if (0) { printf args; } } while (0) | 71 # define MODULE_PRINTF(args) do { if (0) { printf args; } } while (0) |
66 /* allows DCE but compiler can still do format string checks */ | 72 /* allows DCE but compiler can still do format string checks */ |
67 #endif | 73 #endif |
68 | 74 |
69 } // namespace plugin | 75 } // namespace plugin |
70 | 76 |
71 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_UTILITY_H_ | 77 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_UTILITY_H_ |
OLD | NEW |