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

Unified Diff: ppapi/nacl_irt/manifest_service.cc

Issue 249183004: Implement open_resource in non-SFI mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/nacl_irt/manifest_service.h ('k') | ppapi/native_client/src/trusted/plugin/nacl_entry_points.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/nacl_irt/manifest_service.cc
diff --git a/ppapi/nacl_irt/manifest_service.cc b/ppapi/nacl_irt/manifest_service.cc
index ed7c4ebf969ffe9d337780ad426831abfcb3f4a0..0afa217e2897a142a1dfefe555384a3c02565fec 100644
--- a/ppapi/nacl_irt/manifest_service.cc
+++ b/ppapi/nacl_irt/manifest_service.cc
@@ -8,10 +8,15 @@
#include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_channel_proxy.h"
#include "ipc/ipc_sync_message_filter.h"
+#include "native_client/src/trusted/service_runtime/include/sys/errno.h"
+#include "ppapi/nacl_irt/irt_manifest.h"
+#include "ppapi/nacl_irt/plugin_startup.h"
#include "ppapi/proxy/ppapi_messages.h"
namespace ppapi {
+const char kFilePrefix[] = "files/";
+
ManifestService::ManifestService(
const IPC::ChannelHandle& handle,
scoped_refptr<base::MessageLoopProxy> io_message_loop,
@@ -19,7 +24,7 @@ ManifestService::ManifestService(
filter_ = new IPC::SyncMessageFilter(shutdown_event);
channel_.reset(new IPC::ChannelProxy(handle,
IPC::Channel::MODE_SERVER,
- NULL, // Listener
+ NULL, // Listener
io_message_loop));
channel_->AddFilter(filter_.get());
}
@@ -31,4 +36,34 @@ void ManifestService::StartupInitializationComplete() {
filter_->Send(new PpapiHostMsg_StartupInitializationComplete);
}
+bool ManifestService::OpenResource(const char* file, int* fd) {
+ // OpenResource will return INVALID SerializedHandle, if it is not supported.
+ // Specifically, PNaCl doesn't support open resource.
+ ppapi::proxy::SerializedHandle ipc_fd;
+ if (!filter_->Send(new PpapiHostMsg_OpenResource(
+ std::string(kFilePrefix) + file, &ipc_fd)) ||
+ !ipc_fd.is_file()) {
+ LOG(ERROR) << "ManifestService::OpenResource failed:" << file;
+ *fd = -1;
+ return false;
+ }
+
+ *fd = ipc_fd.descriptor().fd;
+ return true;
+}
+
+int IrtOpenResource(const char* file, int* fd) {
+ // Remove leading '/' character.
+ if (file[0] == '/')
+ ++file;
+
+ ManifestService* manifest_service = GetManifestService();
+ if (manifest_service == NULL ||
+ !manifest_service->OpenResource(file, fd)) {
+ return NACL_ABI_EIO;
+ }
+
+ return (*fd == -1) ? NACL_ABI_ENOENT : 0;
+}
+
} // namespace ppapi
« no previous file with comments | « ppapi/nacl_irt/manifest_service.h ('k') | ppapi/native_client/src/trusted/plugin/nacl_entry_points.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698