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

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

Issue 649603004: Non-SFI NaCl: Batch-open resource files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: code review Created 6 years, 1 month 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_host_message_filter.h" 5 #include "components/nacl/browser/nacl_host_message_filter.h"
6 6
7 #include "base/sys_info.h" 7 #include "base/sys_info.h"
8 #include "components/nacl/browser/nacl_browser.h" 8 #include "components/nacl/browser/nacl_browser.h"
9 #include "components/nacl/browser/nacl_file_host.h" 9 #include "components/nacl/browser/nacl_file_host.h"
10 #include "components/nacl/browser/nacl_process_host.h" 10 #include "components/nacl/browser/nacl_process_host.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 void NaClHostMessageFilter::LaunchNaClContinuation( 145 void NaClHostMessageFilter::LaunchNaClContinuation(
146 const nacl::NaClLaunchParams& launch_params, 146 const nacl::NaClLaunchParams& launch_params,
147 IPC::Message* reply_msg, 147 IPC::Message* reply_msg,
148 ppapi::PpapiPermissions permissions) { 148 ppapi::PpapiPermissions permissions) {
149 NaClFileToken nexe_token = { 149 NaClFileToken nexe_token = {
150 launch_params.nexe_token_lo, // lo 150 launch_params.nexe_token_lo, // lo
151 launch_params.nexe_token_hi // hi 151 launch_params.nexe_token_hi // hi
152 }; 152 };
153 153
154 base::PlatformFile nexe_file; 154 base::PlatformFile nexe_file;
155 scoped_ptr<base::File[]> resource_files;
155 #if defined(OS_WIN) 156 #if defined(OS_WIN)
156 // Duplicate the nexe file handle from the renderer process into the browser 157 // Duplicate the nexe file handle from the renderer process into the browser
157 // process. 158 // process.
158 if (!::DuplicateHandle(PeerHandle(), 159 if (!::DuplicateHandle(PeerHandle(),
159 launch_params.nexe_file, 160 launch_params.nexe_file,
160 base::GetCurrentProcessHandle(), 161 base::GetCurrentProcessHandle(),
161 &nexe_file, 162 &nexe_file,
162 0, // Unused, given DUPLICATE_SAME_ACCESS. 163 0, // Unused, given DUPLICATE_SAME_ACCESS.
163 FALSE, 164 FALSE,
164 DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) { 165 DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) {
165 NaClHostMsg_LaunchNaCl::WriteReplyParams( 166 NaClHostMsg_LaunchNaCl::WriteReplyParams(
166 reply_msg, 167 reply_msg,
167 NaClLaunchResult(), 168 NaClLaunchResult(),
168 std::string("Failed to duplicate nexe file handle")); 169 std::string("Failed to duplicate nexe file handle"));
169 Send(reply_msg); 170 Send(reply_msg);
170 return; 171 return;
171 } 172 }
173 // TODO(yusukes): Support pre-opening resource files.
174 CHECK(launch_params.resource_files.empty());
175 CHECK(launch_params.resource_keys.empty());
172 #elif defined(OS_POSIX) 176 #elif defined(OS_POSIX)
173 nexe_file = 177 nexe_file =
174 IPC::PlatformFileForTransitToPlatformFile(launch_params.nexe_file); 178 IPC::PlatformFileForTransitToPlatformFile(launch_params.nexe_file);
179 resource_files.reset(new base::File[launch_params.resource_files.size()]);
180 for (size_t i = 0; i < launch_params.resource_files.size(); ++i) {
181 resource_files[i] = base::File(IPC::PlatformFileForTransitToPlatformFile(
182 launch_params.resource_files[i]));
183 }
175 #else 184 #else
176 #error Unsupported platform. 185 #error Unsupported platform.
177 #endif 186 #endif
178 187
179 NaClProcessHost* host = new NaClProcessHost( 188 NaClProcessHost* host = new NaClProcessHost(
180 GURL(launch_params.manifest_url), 189 GURL(launch_params.manifest_url),
181 base::File(nexe_file), 190 base::File(nexe_file),
182 nexe_token, 191 nexe_token,
192 resource_files.Pass(),
193 launch_params.resource_file_tokens,
194 launch_params.resource_keys,
183 permissions, 195 permissions,
184 launch_params.render_view_id, 196 launch_params.render_view_id,
185 launch_params.permission_bits, 197 launch_params.permission_bits,
186 launch_params.uses_nonsfi_mode, 198 launch_params.uses_nonsfi_mode,
187 off_the_record_, 199 off_the_record_,
188 launch_params.process_type, 200 launch_params.process_type,
189 profile_directory_); 201 profile_directory_);
190 GURL manifest_url(launch_params.manifest_url); 202 GURL manifest_url(launch_params.manifest_url);
191 base::FilePath manifest_path; 203 base::FilePath manifest_path;
192 // We're calling MapUrlToLocalFilePath with the non-blocking API 204 // We're calling MapUrlToLocalFilePath with the non-blocking API
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 void NaClHostMessageFilter::OnTranslationFinished(int instance, bool success) { 289 void NaClHostMessageFilter::OnTranslationFinished(int instance, bool success) {
278 pnacl::PnaclHost::GetInstance()->TranslationFinished( 290 pnacl::PnaclHost::GetInstance()->TranslationFinished(
279 render_process_id_, instance, success); 291 render_process_id_, instance, success);
280 } 292 }
281 293
282 void NaClHostMessageFilter::OnMissingArchError(int render_view_id) { 294 void NaClHostMessageFilter::OnMissingArchError(int render_view_id) {
283 nacl::NaClBrowser::GetDelegate()-> 295 nacl::NaClBrowser::GetDelegate()->
284 ShowMissingArchInfobar(render_process_id_, render_view_id); 296 ShowMissingArchInfobar(render_process_id_, render_view_id);
285 } 297 }
286 298
287 void NaClHostMessageFilter::OnOpenNaClExecutable(int render_view_id, 299 void NaClHostMessageFilter::OnOpenNaClExecutable(
288 const GURL& file_url, 300 int render_view_id,
289 IPC::Message* reply_msg) { 301 const GURL& file_url,
302 const std::vector<GURL>& resource_urls,
303 IPC::Message* reply_msg) {
290 nacl_file_host::OpenNaClExecutable(this, render_view_id, file_url, 304 nacl_file_host::OpenNaClExecutable(this, render_view_id, file_url,
291 reply_msg); 305 resource_urls, reply_msg);
292 } 306 }
293 307
294 void NaClHostMessageFilter::OnNaClDebugEnabledForURL(const GURL& nmf_url, 308 void NaClHostMessageFilter::OnNaClDebugEnabledForURL(const GURL& nmf_url,
295 bool* should_debug) { 309 bool* should_debug) {
296 *should_debug = 310 *should_debug =
297 nacl::NaClBrowser::GetDelegate()->URLMatchesDebugPatterns(nmf_url); 311 nacl::NaClBrowser::GetDelegate()->URLMatchesDebugPatterns(nmf_url);
298 } 312 }
299 313
300 } // namespace nacl 314 } // namespace nacl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698