Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/nacl_irt/manifest_service.h" | 5 #include "ppapi/nacl_irt/manifest_service.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop_proxy.h" | 7 #include "base/message_loop/message_loop_proxy.h" |
| 8 #include "ipc/ipc_channel_handle.h" | 8 #include "ipc/ipc_channel_handle.h" |
| 9 #include "ipc/ipc_channel_proxy.h" | 9 #include "ipc/ipc_channel_proxy.h" |
| 10 #include "ipc/ipc_sync_message_filter.h" | 10 #include "ipc/ipc_sync_message_filter.h" |
| 11 #include "ppapi/proxy/ppapi_messages.h" | 11 #include "ppapi/proxy/ppapi_messages.h" |
| 12 | 12 |
| 13 namespace ppapi { | 13 namespace ppapi { |
| 14 | 14 |
| 15 const char kFilePrefix[] = "files/"; | |
| 16 | |
| 15 ManifestService::ManifestService( | 17 ManifestService::ManifestService( |
| 16 const IPC::ChannelHandle& handle, | 18 const IPC::ChannelHandle& handle, |
| 17 scoped_refptr<base::MessageLoopProxy> io_message_loop, | 19 scoped_refptr<base::MessageLoopProxy> io_message_loop, |
| 18 base::WaitableEvent* shutdown_event) { | 20 base::WaitableEvent* shutdown_event) { |
| 19 filter_ = new IPC::SyncMessageFilter(shutdown_event); | 21 filter_ = new IPC::SyncMessageFilter(shutdown_event); |
| 20 channel_.reset(new IPC::ChannelProxy(handle, | 22 channel_.reset(new IPC::ChannelProxy(handle, |
| 21 IPC::Channel::MODE_SERVER, | 23 IPC::Channel::MODE_SERVER, |
| 22 NULL, // Listener | 24 NULL, // Listener |
| 23 io_message_loop)); | 25 io_message_loop)); |
| 24 channel_->AddFilter(filter_.get()); | 26 channel_->AddFilter(filter_.get()); |
| 25 } | 27 } |
| 26 | 28 |
| 27 ManifestService::~ManifestService() { | 29 ManifestService::~ManifestService() { |
| 28 } | 30 } |
| 29 | 31 |
| 30 void ManifestService::StartupInitializationComplete() { | 32 void ManifestService::StartupInitializationComplete() { |
| 31 filter_->Send(new PpapiHostMsg_StartupInitializationComplete); | 33 filter_->Send(new PpapiHostMsg_StartupInitializationComplete); |
| 32 } | 34 } |
| 33 | 35 |
| 36 bool ManifestService::OpenResource(const char* file, int* fd) { | |
| 37 ppapi::proxy::SerializedHandle ipc_fd; | |
| 38 if (!filter_->Send(new PpapiHostMsg_OpenResource( | |
| 39 std::string(kFilePrefix) + file, &ipc_fd))) { | |
| 40 LOG(ERROR) << "ManifestService::OpenResource failed:" << file; | |
| 41 *fd = -1; | |
| 42 return false; | |
| 43 } | |
| 44 | |
| 45 *fd = IPC::PlatformFileForTransitToPlatformFile(ipc_fd.descriptor()); | |
|
Mark Seaborn
2014/04/30 21:20:58
This can just be "ipc_fd.descriptor().fd", I think
hidehiko
2014/05/01 05:20:31
Done.
| |
| 46 return true; | |
| 47 } | |
| 48 | |
| 34 } // namespace ppapi | 49 } // namespace ppapi |
| OLD | NEW |