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 "components/nacl/renderer/manifest_service_channel.h" | 5 #include "components/nacl/renderer/manifest_service_channel.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
9 #include "base/callback_helpers.h" | 11 #include "base/callback_helpers.h" |
10 #include "build/build_config.h" | 12 #include "build/build_config.h" |
11 #include "content/public/common/sandbox_init.h" | 13 #include "content/public/common/sandbox_init.h" |
12 #include "content/public/renderer/render_thread.h" | 14 #include "content/public/renderer/render_thread.h" |
13 #include "ipc/ipc_channel.h" | 15 #include "ipc/ipc_channel.h" |
14 #include "ipc/ipc_sync_channel.h" | 16 #include "ipc/ipc_sync_channel.h" |
15 #include "ppapi/c/pp_errors.h" | 17 #include "ppapi/c/pp_errors.h" |
16 #include "ppapi/c/ppb_file_io.h" | 18 #include "ppapi/c/ppb_file_io.h" |
17 #include "ppapi/proxy/ppapi_messages.h" | 19 #include "ppapi/proxy/ppapi_messages.h" |
18 | 20 |
19 namespace nacl { | 21 namespace nacl { |
20 | 22 |
21 ManifestServiceChannel::ManifestServiceChannel( | 23 ManifestServiceChannel::ManifestServiceChannel( |
22 const IPC::ChannelHandle& handle, | 24 const IPC::ChannelHandle& handle, |
23 const base::Callback<void(int32_t)>& connected_callback, | 25 const base::Callback<void(int32_t)>& connected_callback, |
24 scoped_ptr<Delegate> delegate, | 26 scoped_ptr<Delegate> delegate, |
25 base::WaitableEvent* waitable_event) | 27 base::WaitableEvent* waitable_event) |
26 : connected_callback_(connected_callback), | 28 : connected_callback_(connected_callback), |
27 delegate_(delegate.Pass()), | 29 delegate_(std::move(delegate)), |
28 channel_(IPC::SyncChannel::Create( | 30 channel_(IPC::SyncChannel::Create( |
29 handle, | 31 handle, |
30 IPC::Channel::MODE_CLIENT, | 32 IPC::Channel::MODE_CLIENT, |
31 this, | 33 this, |
32 content::RenderThread::Get()->GetIOMessageLoopProxy(), | 34 content::RenderThread::Get()->GetIOMessageLoopProxy(), |
33 true, | 35 true, |
34 waitable_event)), | 36 waitable_event)), |
35 peer_pid_(base::kNullProcessId), | 37 peer_pid_(base::kNullProcessId), |
36 weak_ptr_factory_(this) { | 38 weak_ptr_factory_(this) {} |
37 } | |
38 | 39 |
39 ManifestServiceChannel::~ManifestServiceChannel() { | 40 ManifestServiceChannel::~ManifestServiceChannel() { |
40 if (!connected_callback_.is_null()) | 41 if (!connected_callback_.is_null()) |
41 base::ResetAndReturn(&connected_callback_).Run(PP_ERROR_FAILED); | 42 base::ResetAndReturn(&connected_callback_).Run(PP_ERROR_FAILED); |
42 } | 43 } |
43 | 44 |
44 void ManifestServiceChannel::Send(IPC::Message* message) { | 45 void ManifestServiceChannel::Send(IPC::Message* message) { |
45 channel_->Send(message); | 46 channel_->Send(message); |
46 } | 47 } |
47 | 48 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 #if defined(OS_WIN) | 91 #if defined(OS_WIN) |
91 bool ok = content::BrokerDuplicateHandle( | 92 bool ok = content::BrokerDuplicateHandle( |
92 file.TakePlatformFile(), | 93 file.TakePlatformFile(), |
93 peer_pid_, | 94 peer_pid_, |
94 &file_for_transit, | 95 &file_for_transit, |
95 0, // desired_access is 0 since we're using DUPLICATE_SAME_ACCESS. | 96 0, // desired_access is 0 since we're using DUPLICATE_SAME_ACCESS. |
96 DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE); | 97 DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE); |
97 if (ok) | 98 if (ok) |
98 handle.set_file_handle(file_for_transit, PP_FILEOPENFLAG_READ, 0); | 99 handle.set_file_handle(file_for_transit, PP_FILEOPENFLAG_READ, 0); |
99 #else | 100 #else |
100 file_for_transit = base::FileDescriptor(file.Pass()); | 101 file_for_transit = base::FileDescriptor(std::move(file)); |
101 handle.set_file_handle(file_for_transit, PP_FILEOPENFLAG_READ, 0); | 102 handle.set_file_handle(file_for_transit, PP_FILEOPENFLAG_READ, 0); |
102 #endif | 103 #endif |
103 } | 104 } |
104 PpapiHostMsg_OpenResource::WriteReplyParams(reply, | 105 PpapiHostMsg_OpenResource::WriteReplyParams(reply, |
105 handle, | 106 handle, |
106 token_lo, | 107 token_lo, |
107 token_hi); | 108 token_hi); |
108 Send(reply); | 109 Send(reply); |
109 } | 110 } |
110 | 111 |
111 } // namespace nacl | 112 } // namespace nacl |
OLD | NEW |