OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/nacl_file_host.h" | 5 #include "components/nacl/browser/nacl_file_host.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 IPC::Message* reply_msg, | 54 IPC::Message* reply_msg, |
55 WriteFileInfoReply write_reply_message) { | 55 WriteFileInfoReply write_reply_message) { |
56 // IO thread owns the NaClBrowser singleton. | 56 // IO thread owns the NaClBrowser singleton. |
57 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 57 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
58 | 58 |
59 nacl::NaClBrowser* nacl_browser = nacl::NaClBrowser::GetInstance(); | 59 nacl::NaClBrowser* nacl_browser = nacl::NaClBrowser::GetInstance(); |
60 uint64_t file_token_lo = 0; | 60 uint64_t file_token_lo = 0; |
61 uint64_t file_token_hi = 0; | 61 uint64_t file_token_hi = 0; |
62 nacl_browser->PutFilePath(file_path, &file_token_lo, &file_token_hi); | 62 nacl_browser->PutFilePath(file_path, &file_token_lo, &file_token_hi); |
63 | 63 |
64 IPC::PlatformFileForTransit file_desc = IPC::TakeFileHandleForProcess( | 64 IPC::PlatformFileForTransit file_desc = |
65 std::move(file), nacl_host_message_filter->PeerHandle()); | 65 IPC::TakePlatformFileForTransit(std::move(file)); |
66 | 66 |
67 write_reply_message(reply_msg, file_desc, file_token_lo, file_token_hi); | 67 write_reply_message(reply_msg, file_desc, file_token_lo, file_token_hi); |
68 nacl_host_message_filter->Send(reply_msg); | 68 nacl_host_message_filter->Send(reply_msg); |
69 } | 69 } |
70 | 70 |
71 void DoOpenPnaclFile( | 71 void DoOpenPnaclFile( |
72 scoped_refptr<nacl::NaClHostMessageFilter> nacl_host_message_filter, | 72 scoped_refptr<nacl::NaClHostMessageFilter> nacl_host_message_filter, |
73 const std::string& filename, | 73 const std::string& filename, |
74 bool is_executable, | 74 bool is_executable, |
75 IPC::Message* reply_msg) { | 75 IPC::Message* reply_msg) { |
(...skipping 27 matching lines...) Expand all Loading... |
103 // executable in the NaCl file_path cache. | 103 // executable in the NaCl file_path cache. |
104 if (is_executable) { | 104 if (is_executable) { |
105 BrowserThread::PostTask( | 105 BrowserThread::PostTask( |
106 BrowserThread::IO, FROM_HERE, | 106 BrowserThread::IO, FROM_HERE, |
107 base::Bind(&DoRegisterOpenedNaClExecutableFile, | 107 base::Bind(&DoRegisterOpenedNaClExecutableFile, |
108 nacl_host_message_filter, Passed(std::move(file_to_open)), | 108 nacl_host_message_filter, Passed(std::move(file_to_open)), |
109 full_filepath, reply_msg, | 109 full_filepath, reply_msg, |
110 static_cast<WriteFileInfoReply>( | 110 static_cast<WriteFileInfoReply>( |
111 NaClHostMsg_GetReadonlyPnaclFD::WriteReplyParams))); | 111 NaClHostMsg_GetReadonlyPnaclFD::WriteReplyParams))); |
112 } else { | 112 } else { |
113 IPC::PlatformFileForTransit target_desc = IPC::TakeFileHandleForProcess( | 113 IPC::PlatformFileForTransit target_desc = |
114 std::move(file_to_open), nacl_host_message_filter->PeerHandle()); | 114 IPC::TakePlatformFileForTransit(std::move(file_to_open)); |
115 uint64_t dummy_file_token = 0; | 115 uint64_t dummy_file_token = 0; |
116 NaClHostMsg_GetReadonlyPnaclFD::WriteReplyParams( | 116 NaClHostMsg_GetReadonlyPnaclFD::WriteReplyParams( |
117 reply_msg, target_desc, dummy_file_token, dummy_file_token); | 117 reply_msg, target_desc, dummy_file_token, dummy_file_token); |
118 nacl_host_message_filter->Send(reply_msg); | 118 nacl_host_message_filter->Send(reply_msg); |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 // Convert the file URL into a file descriptor. | 122 // Convert the file URL into a file descriptor. |
123 // This function is security sensitive. Be sure to check with a security | 123 // This function is security sensitive. Be sure to check with a security |
124 // person before you modify it. | 124 // person before you modify it. |
(...skipping 26 matching lines...) Expand all Loading... |
151 // This function is running on the blocking pool, but the path needs to be | 151 // This function is running on the blocking pool, but the path needs to be |
152 // registered in a structure owned by the IO thread. | 152 // registered in a structure owned by the IO thread. |
153 BrowserThread::PostTask( | 153 BrowserThread::PostTask( |
154 BrowserThread::IO, FROM_HERE, | 154 BrowserThread::IO, FROM_HERE, |
155 base::Bind(&DoRegisterOpenedNaClExecutableFile, | 155 base::Bind(&DoRegisterOpenedNaClExecutableFile, |
156 nacl_host_message_filter, Passed(std::move(file)), | 156 nacl_host_message_filter, Passed(std::move(file)), |
157 file_path, reply_msg, | 157 file_path, reply_msg, |
158 static_cast<WriteFileInfoReply>( | 158 static_cast<WriteFileInfoReply>( |
159 NaClHostMsg_OpenNaClExecutable::WriteReplyParams))); | 159 NaClHostMsg_OpenNaClExecutable::WriteReplyParams))); |
160 } else { | 160 } else { |
161 IPC::PlatformFileForTransit file_desc = IPC::TakeFileHandleForProcess( | 161 IPC::PlatformFileForTransit file_desc = |
162 std::move(file), nacl_host_message_filter->PeerHandle()); | 162 IPC::TakePlatformFileForTransit(std::move(file)); |
163 uint64_t dummy_file_token = 0; | 163 uint64_t dummy_file_token = 0; |
164 NaClHostMsg_OpenNaClExecutable::WriteReplyParams( | 164 NaClHostMsg_OpenNaClExecutable::WriteReplyParams( |
165 reply_msg, file_desc, dummy_file_token, dummy_file_token); | 165 reply_msg, file_desc, dummy_file_token, dummy_file_token); |
166 nacl_host_message_filter->Send(reply_msg); | 166 nacl_host_message_filter->Send(reply_msg); |
167 } | 167 } |
168 } else { | 168 } else { |
169 NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg); | 169 NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg); |
170 return; | 170 return; |
171 } | 171 } |
172 } | 172 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 &DoOpenNaClExecutableOnThreadPool, | 272 &DoOpenNaClExecutableOnThreadPool, |
273 nacl_host_message_filter, | 273 nacl_host_message_filter, |
274 file_url, | 274 file_url, |
275 enable_validation_caching, | 275 enable_validation_caching, |
276 reply_msg))) { | 276 reply_msg))) { |
277 NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg); | 277 NotifyRendererOfError(nacl_host_message_filter.get(), reply_msg); |
278 } | 278 } |
279 } | 279 } |
280 | 280 |
281 } // namespace nacl_file_host | 281 } // namespace nacl_file_host |
OLD | NEW |