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

Side by Side Diff: components/nacl/renderer/manifest_service_channel.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, 7 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 // 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 "components/nacl/renderer/manifest_service_channel.h" 5 #include "components/nacl/renderer/manifest_service_channel.h"
6 6
7 #include "base/bind.h"
7 #include "base/callback.h" 8 #include "base/callback.h"
8 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
9 #include "content/public/renderer/render_thread.h" 10 #include "content/public/renderer/render_thread.h"
10 #include "ipc/ipc_channel.h" 11 #include "ipc/ipc_channel.h"
11 #include "ipc/ipc_sync_channel.h" 12 #include "ipc/ipc_sync_channel.h"
12 #include "ppapi/c/pp_errors.h" 13 #include "ppapi/c/pp_errors.h"
13 #include "ppapi/proxy/ppapi_messages.h" 14 #include "ppapi/proxy/ppapi_messages.h"
14 15
15 namespace nacl { 16 namespace nacl {
16 17
17 ManifestServiceChannel::ManifestServiceChannel( 18 ManifestServiceChannel::ManifestServiceChannel(
18 const IPC::ChannelHandle& handle, 19 const IPC::ChannelHandle& handle,
19 const base::Callback<void(int32_t)>& connected_callback, 20 const base::Callback<void(int32_t)>& connected_callback,
20 scoped_ptr<Delegate> delegate, 21 scoped_ptr<Delegate> delegate,
21 base::WaitableEvent* waitable_event) 22 base::WaitableEvent* waitable_event)
22 : connected_callback_(connected_callback), 23 : connected_callback_(connected_callback),
23 delegate_(delegate.Pass()), 24 delegate_(delegate.Pass()),
24 channel_(new IPC::SyncChannel( 25 channel_(new IPC::SyncChannel(
25 handle, IPC::Channel::MODE_CLIENT, this, 26 handle, IPC::Channel::MODE_CLIENT, this,
26 content::RenderThread::Get()->GetIOMessageLoopProxy(), 27 content::RenderThread::Get()->GetIOMessageLoopProxy(),
27 true, waitable_event)) { 28 true, waitable_event)),
29 weak_ptr_factory_(this) {
28 } 30 }
29 31
30 ManifestServiceChannel::~ManifestServiceChannel() { 32 ManifestServiceChannel::~ManifestServiceChannel() {
31 if (!connected_callback_.is_null()) 33 if (!connected_callback_.is_null())
32 base::ResetAndReturn(&connected_callback_).Run(PP_ERROR_FAILED); 34 base::ResetAndReturn(&connected_callback_).Run(PP_ERROR_FAILED);
33 } 35 }
34 36
37 void ManifestServiceChannel::Send(IPC::Message* message) {
38 channel_->Send(message);
39 }
40
35 bool ManifestServiceChannel::OnMessageReceived(const IPC::Message& message) { 41 bool ManifestServiceChannel::OnMessageReceived(const IPC::Message& message) {
36 // TODO(hidehiko): Implement OpenResource.
37 bool handled = true; 42 bool handled = true;
38 IPC_BEGIN_MESSAGE_MAP(ManifestServiceChannel, message) 43 IPC_BEGIN_MESSAGE_MAP(ManifestServiceChannel, message)
39 IPC_MESSAGE_HANDLER(PpapiHostMsg_StartupInitializationComplete, 44 IPC_MESSAGE_HANDLER(PpapiHostMsg_StartupInitializationComplete,
40 OnStartupInitializationComplete) 45 OnStartupInitializationComplete)
46 IPC_MESSAGE_HANDLER_DELAY_REPLY(PpapiHostMsg_OpenResource,
47 OnOpenResource)
41 IPC_MESSAGE_UNHANDLED(handled = false) 48 IPC_MESSAGE_UNHANDLED(handled = false)
42 IPC_END_MESSAGE_MAP() 49 IPC_END_MESSAGE_MAP()
43 return handled; 50 return handled;
44 } 51 }
45 52
46 void ManifestServiceChannel::OnChannelConnected(int32 peer_pid) { 53 void ManifestServiceChannel::OnChannelConnected(int32 peer_pid) {
47 if (!connected_callback_.is_null()) 54 if (!connected_callback_.is_null())
48 base::ResetAndReturn(&connected_callback_).Run(PP_OK); 55 base::ResetAndReturn(&connected_callback_).Run(PP_OK);
49 } 56 }
50 57
51 void ManifestServiceChannel::OnChannelError() { 58 void ManifestServiceChannel::OnChannelError() {
52 if (!connected_callback_.is_null()) 59 if (!connected_callback_.is_null())
53 base::ResetAndReturn(&connected_callback_).Run(PP_ERROR_FAILED); 60 base::ResetAndReturn(&connected_callback_).Run(PP_ERROR_FAILED);
54 } 61 }
55 62
56 void ManifestServiceChannel::OnStartupInitializationComplete() { 63 void ManifestServiceChannel::OnStartupInitializationComplete() {
57 delegate_->StartupInitializationComplete(); 64 delegate_->StartupInitializationComplete();
58 } 65 }
59 66
67 void ManifestServiceChannel::OnOpenResource(
68 const std::string& key, IPC::Message* reply) {
69 // Currently this is used only for non-SFI mode, which is not supported on
70 // windows.
71 #if !defined(OS_WIN)
72 delegate_->OpenResource(
73 key,
74 base::Bind(&ManifestServiceChannel::DidOpenResource,
75 weak_ptr_factory_.GetWeakPtr(), reply));
76 #else
77 PpapiHostMsg_OpenResource::WriteReplyParams(
78 reply, ppapi::proxy::SerializedHandle());
79 Send(reply);
80 #endif
81 }
82
83 #if !defined(OS_WIN)
84 void ManifestServiceChannel::DidOpenResource(
85 IPC::Message* reply, const base::PlatformFile& platform_file) {
86 // Here, PlatformFileForTransit is alias of base::FileDescriptor.
87 PpapiHostMsg_OpenResource::WriteReplyParams(
88 reply,
89 ppapi::proxy::SerializedHandle(
90 ppapi::proxy::SerializedHandle::FILE,
91 base::FileDescriptor(platform_file, true)));
92 Send(reply);
93 }
94 #endif
95
60 } // namespace nacl 96 } // namespace nacl
OLDNEW
« no previous file with comments | « components/nacl/renderer/manifest_service_channel.h ('k') | components/nacl/renderer/ppb_nacl_private_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698