Commit a751ae0a authored by mseaborn's avatar mseaborn Committed by Commit bot

PNaCl cleanup: Reuse base::File for closing a handle/FD

This removes a dependency on the NACL_WINDOWS macro, which is defined
in non-public native_client headers.

It also gets the benefit of the error-checking that base/ does for
close()/CloseHandle().

BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=2832
TEST=e.g. NaClBrowserTestPnacl.PPAPICore (tests PNaCl translation)

Review URL: https://codereview.chromium.org/1640523002

Cr-Commit-Position: refs/heads/master@{#371692}
parent e6119aac
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <vector> #include <vector>
#include "base/files/file.h"
#include "base/logging.h" #include "base/logging.h"
#include "components/nacl/renderer/plugin/plugin.h" #include "components/nacl/renderer/plugin/plugin.h"
#include "components/nacl/renderer/plugin/utility.h" #include "components/nacl/renderer/plugin/utility.h"
...@@ -35,8 +36,7 @@ PnaclResources::PnaclResources(Plugin* plugin, bool use_subzero) ...@@ -35,8 +36,7 @@ PnaclResources::PnaclResources(Plugin* plugin, bool use_subzero)
PnaclResources::~PnaclResources() { PnaclResources::~PnaclResources() {
for (PnaclResourceEntry& entry : resources_) { for (PnaclResourceEntry& entry : resources_) {
if (entry.file_info.handle != PP_kInvalidFileHandle) base::File closer(entry.file_info.handle);
CloseFileHandle(entry.file_info.handle);
} }
} }
......
...@@ -73,12 +73,4 @@ void SetNaClInterface(const PPB_NaCl_Private* nacl_interface) { ...@@ -73,12 +73,4 @@ void SetNaClInterface(const PPB_NaCl_Private* nacl_interface) {
g_nacl_interface = nacl_interface; g_nacl_interface = nacl_interface;
} }
void CloseFileHandle(PP_FileHandle file_handle) {
#if NACL_WINDOWS
CloseHandle(file_handle);
#else
close(file_handle);
#endif
}
} // namespace plugin } // namespace plugin
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "components/nacl/renderer/ppb_nacl_private.h" #include "components/nacl/renderer/ppb_nacl_private.h"
#include "native_client/src/shared/platform/nacl_threads.h" #include "native_client/src/shared/platform/nacl_threads.h"
#include "native_client/src/shared/platform/nacl_time.h" #include "native_client/src/shared/platform/nacl_time.h"
#include "ppapi/c/private/pp_file_handle.h"
#define SRPC_PLUGIN_DEBUG 1 #define SRPC_PLUGIN_DEBUG 1
...@@ -23,8 +22,6 @@ namespace plugin { ...@@ -23,8 +22,6 @@ namespace plugin {
const PPB_NaCl_Private* GetNaClInterface(); const PPB_NaCl_Private* GetNaClInterface();
void SetNaClInterface(const PPB_NaCl_Private* nacl_interface); void SetNaClInterface(const PPB_NaCl_Private* nacl_interface);
void CloseFileHandle(PP_FileHandle file_handle);
// Debugging print utility // Debugging print utility
extern int gNaClPluginDebugPrintEnabled; extern int gNaClPluginDebugPrintEnabled;
extern int NaClPluginPrintLog(const char *format, ...); extern int NaClPluginPrintLog(const char *format, ...);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment