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_process_host.h" | 5 #include "components/nacl/browser/nacl_process_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
657 IPC_MESSAGE_UNHANDLED(handled = false) | 657 IPC_MESSAGE_UNHANDLED(handled = false) |
658 IPC_END_MESSAGE_MAP() | 658 IPC_END_MESSAGE_MAP() |
659 } else { | 659 } else { |
660 IPC_BEGIN_MESSAGE_MAP(NaClProcessHost, msg) | 660 IPC_BEGIN_MESSAGE_MAP(NaClProcessHost, msg) |
661 IPC_MESSAGE_HANDLER(NaClProcessMsg_QueryKnownToValidate, | 661 IPC_MESSAGE_HANDLER(NaClProcessMsg_QueryKnownToValidate, |
662 OnQueryKnownToValidate) | 662 OnQueryKnownToValidate) |
663 IPC_MESSAGE_HANDLER(NaClProcessMsg_SetKnownToValidate, | 663 IPC_MESSAGE_HANDLER(NaClProcessMsg_SetKnownToValidate, |
664 OnSetKnownToValidate) | 664 OnSetKnownToValidate) |
665 IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClProcessMsg_ResolveFileToken, | 665 IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClProcessMsg_ResolveFileToken, |
666 OnResolveFileToken) | 666 OnResolveFileToken) |
667 IPC_MESSAGE_HANDLER(NaClProcessMsg_ResolveFileTokenAsync, | |
668 OnResolveFileTokenAsync) | |
669 | |
667 #if defined(OS_WIN) | 670 #if defined(OS_WIN) |
668 IPC_MESSAGE_HANDLER_DELAY_REPLY( | 671 IPC_MESSAGE_HANDLER_DELAY_REPLY( |
669 NaClProcessMsg_AttachDebugExceptionHandler, | 672 NaClProcessMsg_AttachDebugExceptionHandler, |
670 OnAttachDebugExceptionHandler) | 673 OnAttachDebugExceptionHandler) |
671 IPC_MESSAGE_HANDLER(NaClProcessHostMsg_DebugStubPortSelected, | 674 IPC_MESSAGE_HANDLER(NaClProcessHostMsg_DebugStubPortSelected, |
672 OnDebugStubPortSelected) | 675 OnDebugStubPortSelected) |
673 #endif | 676 #endif |
674 IPC_MESSAGE_HANDLER(NaClProcessHostMsg_PpapiChannelsCreated, | 677 IPC_MESSAGE_HANDLER(NaClProcessHostMsg_PpapiChannelsCreated, |
675 OnPpapiChannelsCreated) | 678 OnPpapiChannelsCreated) |
676 IPC_MESSAGE_UNHANDLED(handled = false) | 679 IPC_MESSAGE_UNHANDLED(handled = false) |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1041 file_path); | 1044 file_path); |
1042 } else { | 1045 } else { |
1043 NaClProcessMsg_ResolveFileToken::WriteReplyParams( | 1046 NaClProcessMsg_ResolveFileToken::WriteReplyParams( |
1044 reply_msg, | 1047 reply_msg, |
1045 IPC::InvalidPlatformFileForTransit(), | 1048 IPC::InvalidPlatformFileForTransit(), |
1046 base::FilePath()); | 1049 base::FilePath()); |
1047 } | 1050 } |
1048 Send(reply_msg); | 1051 Send(reply_msg); |
1049 } | 1052 } |
1050 | 1053 |
1054 void NaClProcessHost::FileResolvedAsync( | |
dmichael (off chromium)
2014/08/27 20:49:14
nit: the order here should match the header. Actua
teravest
2014/09/04 22:13:30
Done.
| |
1055 uint64_t file_token_lo, | |
1056 uint64_t file_token_hi, | |
1057 const base::FilePath& file_path, | |
1058 base::File file) { | |
1059 base::FilePath out_file_path; | |
1060 IPC::PlatformFileForTransit out_handle; | |
1061 if (file.IsValid()) { | |
1062 out_file_path = file_path; | |
1063 out_handle = IPC::TakeFileHandleForProcess( | |
1064 file.Pass(), | |
1065 process_->GetData().handle); | |
1066 } else { | |
1067 out_handle = IPC::InvalidPlatformFileForTransit(); | |
1068 } | |
1069 Send(new NaClProcessMsg_ResolveFileTokenAsyncReply( | |
1070 file_token_lo, | |
1071 file_token_hi, | |
1072 out_handle, | |
1073 out_file_path)); | |
dmichael (off chromium)
2014/08/27 20:49:14
nit: indent off by one
teravest
2014/09/04 22:13:30
Done.
| |
1074 } | |
1075 | |
1051 void NaClProcessHost::OnResolveFileToken(uint64 file_token_lo, | 1076 void NaClProcessHost::OnResolveFileToken(uint64 file_token_lo, |
1052 uint64 file_token_hi, | 1077 uint64 file_token_hi, |
1053 IPC::Message* reply_msg) { | 1078 IPC::Message* reply_msg) { |
1054 // Was the file registered? | 1079 // Was the file registered? |
1055 // | 1080 // |
1056 // Note that the file path cache is of bounded size, and old entries can get | 1081 // Note that the file path cache is of bounded size, and old entries can get |
1057 // evicted. If a large number of NaCl modules are being launched at once, | 1082 // evicted. If a large number of NaCl modules are being launched at once, |
1058 // resolving the file_token may fail because the path cache was thrashed | 1083 // resolving the file_token may fail because the path cache was thrashed |
1059 // while the file_token was in flight. In this case the query fails, and we | 1084 // while the file_token was in flight. In this case the query fails, and we |
1060 // need to fall back to the slower path. | 1085 // need to fall back to the slower path. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1096 file_path, | 1121 file_path, |
1097 reply_msg))) { | 1122 reply_msg))) { |
1098 NaClProcessMsg_ResolveFileToken::WriteReplyParams( | 1123 NaClProcessMsg_ResolveFileToken::WriteReplyParams( |
1099 reply_msg, | 1124 reply_msg, |
1100 IPC::InvalidPlatformFileForTransit(), | 1125 IPC::InvalidPlatformFileForTransit(), |
1101 base::FilePath()); | 1126 base::FilePath()); |
1102 Send(reply_msg); | 1127 Send(reply_msg); |
1103 } | 1128 } |
1104 } | 1129 } |
1105 | 1130 |
1131 void NaClProcessHost::OnResolveFileTokenAsync(uint64 file_token_lo, | |
1132 uint64 file_token_hi) { | |
1133 // See the comment at OnResolveFileToken() for details of the file path cache | |
1134 // behavior. | |
1135 CHECK(!uses_nonsfi_mode_); | |
1136 base::FilePath file_path; | |
1137 if (!NaClBrowser::GetInstance()->GetFilePath( | |
1138 file_token_lo, file_token_hi, &file_path)) { | |
1139 Send(new NaClProcessMsg_ResolveFileTokenAsyncReply( | |
1140 file_token_lo, | |
1141 file_token_hi, | |
1142 IPC::PlatformFileForTransit(), | |
1143 base::FilePath())); | |
1144 return; | |
1145 } | |
1146 | |
1147 // Open the file. | |
1148 if (!base::PostTaskAndReplyWithResult( | |
1149 content::BrowserThread::GetBlockingPool(), | |
1150 FROM_HERE, | |
1151 base::Bind(OpenNaClReadExecImpl, file_path, true /* is_executable */), | |
1152 base::Bind(&NaClProcessHost::FileResolvedAsync, | |
1153 weak_factory_.GetWeakPtr(), | |
1154 file_token_lo, | |
1155 file_token_hi, | |
1156 file_path))) { | |
1157 Send(new NaClProcessMsg_ResolveFileTokenAsyncReply( | |
1158 file_token_lo, | |
1159 file_token_hi, | |
1160 IPC::PlatformFileForTransit(), | |
1161 base::FilePath())); | |
1162 } | |
1163 } | |
1164 | |
1106 #if defined(OS_WIN) | 1165 #if defined(OS_WIN) |
1107 void NaClProcessHost::OnAttachDebugExceptionHandler(const std::string& info, | 1166 void NaClProcessHost::OnAttachDebugExceptionHandler(const std::string& info, |
1108 IPC::Message* reply_msg) { | 1167 IPC::Message* reply_msg) { |
1109 CHECK(!uses_nonsfi_mode_); | 1168 CHECK(!uses_nonsfi_mode_); |
1110 if (!AttachDebugExceptionHandler(info, reply_msg)) { | 1169 if (!AttachDebugExceptionHandler(info, reply_msg)) { |
1111 // Send failure message. | 1170 // Send failure message. |
1112 NaClProcessMsg_AttachDebugExceptionHandler::WriteReplyParams(reply_msg, | 1171 NaClProcessMsg_AttachDebugExceptionHandler::WriteReplyParams(reply_msg, |
1113 false); | 1172 false); |
1114 Send(reply_msg); | 1173 Send(reply_msg); |
1115 } | 1174 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1168 process_handle.Take(), info, | 1227 process_handle.Take(), info, |
1169 base::MessageLoopProxy::current(), | 1228 base::MessageLoopProxy::current(), |
1170 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1229 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
1171 weak_factory_.GetWeakPtr())); | 1230 weak_factory_.GetWeakPtr())); |
1172 return true; | 1231 return true; |
1173 } | 1232 } |
1174 } | 1233 } |
1175 #endif | 1234 #endif |
1176 | 1235 |
1177 } // namespace nacl | 1236 } // namespace nacl |
OLD | NEW |