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

Side by Side Diff: components/nacl/browser/nacl_process_host.cc

Issue 418423002: Pepper: Stop using SRPC for irt_open_resource(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 3 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
« no previous file with comments | « components/nacl/browser/nacl_process_host.h ('k') | components/nacl/common/nacl_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); 1023 NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
1021 *result = nacl_browser->QueryKnownToValidate(signature, off_the_record_); 1024 *result = nacl_browser->QueryKnownToValidate(signature, off_the_record_);
1022 } 1025 }
1023 1026
1024 void NaClProcessHost::OnSetKnownToValidate(const std::string& signature) { 1027 void NaClProcessHost::OnSetKnownToValidate(const std::string& signature) {
1025 CHECK(!uses_nonsfi_mode_); 1028 CHECK(!uses_nonsfi_mode_);
1026 NaClBrowser::GetInstance()->SetKnownToValidate( 1029 NaClBrowser::GetInstance()->SetKnownToValidate(
1027 signature, off_the_record_); 1030 signature, off_the_record_);
1028 } 1031 }
1029 1032
1030 void NaClProcessHost::FileResolved(
1031 const base::FilePath& file_path,
1032 IPC::Message* reply_msg,
1033 base::File file) {
1034 if (file.IsValid()) {
1035 IPC::PlatformFileForTransit handle = IPC::TakeFileHandleForProcess(
1036 file.Pass(),
1037 process_->GetData().handle);
1038 NaClProcessMsg_ResolveFileToken::WriteReplyParams(
1039 reply_msg,
1040 handle,
1041 file_path);
1042 } else {
1043 NaClProcessMsg_ResolveFileToken::WriteReplyParams(
1044 reply_msg,
1045 IPC::InvalidPlatformFileForTransit(),
1046 base::FilePath());
1047 }
1048 Send(reply_msg);
1049 }
1050
1051 void NaClProcessHost::OnResolveFileToken(uint64 file_token_lo, 1033 void NaClProcessHost::OnResolveFileToken(uint64 file_token_lo,
1052 uint64 file_token_hi, 1034 uint64 file_token_hi,
1053 IPC::Message* reply_msg) { 1035 IPC::Message* reply_msg) {
1054 // Was the file registered? 1036 // Was the file registered?
1055 // 1037 //
1056 // Note that the file path cache is of bounded size, and old entries can get 1038 // 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, 1039 // 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 1040 // 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 1041 // while the file_token was in flight. In this case the query fails, and we
1060 // need to fall back to the slower path. 1042 // need to fall back to the slower path.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 file_path, 1078 file_path,
1097 reply_msg))) { 1079 reply_msg))) {
1098 NaClProcessMsg_ResolveFileToken::WriteReplyParams( 1080 NaClProcessMsg_ResolveFileToken::WriteReplyParams(
1099 reply_msg, 1081 reply_msg,
1100 IPC::InvalidPlatformFileForTransit(), 1082 IPC::InvalidPlatformFileForTransit(),
1101 base::FilePath()); 1083 base::FilePath());
1102 Send(reply_msg); 1084 Send(reply_msg);
1103 } 1085 }
1104 } 1086 }
1105 1087
1088 void NaClProcessHost::OnResolveFileTokenAsync(uint64 file_token_lo,
1089 uint64 file_token_hi) {
1090 // See the comment at OnResolveFileToken() for details of the file path cache
1091 // behavior.
1092 CHECK(!uses_nonsfi_mode_);
1093 base::FilePath file_path;
1094 if (!NaClBrowser::GetInstance()->GetFilePath(
1095 file_token_lo, file_token_hi, &file_path)) {
1096 Send(new NaClProcessMsg_ResolveFileTokenAsyncReply(
1097 file_token_lo,
1098 file_token_hi,
1099 IPC::PlatformFileForTransit(),
1100 base::FilePath()));
1101 return;
1102 }
1103
1104 // Open the file.
1105 if (!base::PostTaskAndReplyWithResult(
1106 content::BrowserThread::GetBlockingPool(),
1107 FROM_HERE,
1108 base::Bind(OpenNaClReadExecImpl, file_path, true /* is_executable */),
1109 base::Bind(&NaClProcessHost::FileResolvedAsync,
1110 weak_factory_.GetWeakPtr(),
1111 file_token_lo,
1112 file_token_hi,
1113 file_path))) {
1114 Send(new NaClProcessMsg_ResolveFileTokenAsyncReply(
1115 file_token_lo,
1116 file_token_hi,
1117 IPC::PlatformFileForTransit(),
1118 base::FilePath()));
1119 }
1120 }
1121
1122 void NaClProcessHost::FileResolved(
1123 const base::FilePath& file_path,
1124 IPC::Message* reply_msg,
1125 base::File file) {
1126 if (file.IsValid()) {
1127 IPC::PlatformFileForTransit handle = IPC::TakeFileHandleForProcess(
1128 file.Pass(),
1129 process_->GetData().handle);
1130 NaClProcessMsg_ResolveFileToken::WriteReplyParams(
1131 reply_msg,
1132 handle,
1133 file_path);
1134 } else {
1135 NaClProcessMsg_ResolveFileToken::WriteReplyParams(
1136 reply_msg,
1137 IPC::InvalidPlatformFileForTransit(),
1138 base::FilePath());
1139 }
1140 Send(reply_msg);
1141 }
1142
1143 void NaClProcessHost::FileResolvedAsync(
1144 uint64_t file_token_lo,
1145 uint64_t file_token_hi,
1146 const base::FilePath& file_path,
1147 base::File file) {
1148 base::FilePath out_file_path;
1149 IPC::PlatformFileForTransit out_handle;
1150 if (file.IsValid()) {
1151 out_file_path = file_path;
1152 out_handle = IPC::TakeFileHandleForProcess(
1153 file.Pass(),
1154 process_->GetData().handle);
1155 } else {
1156 out_handle = IPC::InvalidPlatformFileForTransit();
1157 }
1158 Send(new NaClProcessMsg_ResolveFileTokenAsyncReply(
1159 file_token_lo,
1160 file_token_hi,
1161 out_handle,
1162 out_file_path));
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
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
OLDNEW
« no previous file with comments | « components/nacl/browser/nacl_process_host.h ('k') | components/nacl/common/nacl_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698