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

Side by Side Diff: chrome/renderer/pepper/ppb_nacl_private_impl.cc

Issue 19863003: PNaCl on-demand installs: Make a separate async IPC to check if PNaCl is installed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: take out progress IPC for now Created 7 years, 4 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
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 "chrome/renderer/pepper/ppb_nacl_private_impl.h" 5 #include "chrome/renderer/pepper/ppb_nacl_private_impl.h"
6 6
7 #ifndef DISABLE_NACL 7 #ifndef DISABLE_NACL
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 23 matching lines...) Expand all
34 #include "third_party/WebKit/public/web/WebFrame.h" 34 #include "third_party/WebKit/public/web/WebFrame.h"
35 #include "third_party/WebKit/public/web/WebPluginContainer.h" 35 #include "third_party/WebKit/public/web/WebPluginContainer.h"
36 #include "third_party/WebKit/public/web/WebView.h" 36 #include "third_party/WebKit/public/web/WebView.h"
37 37
38 namespace { 38 namespace {
39 39
40 base::LazyInstance<scoped_refptr<PnaclTranslationResourceHost> > 40 base::LazyInstance<scoped_refptr<PnaclTranslationResourceHost> >
41 g_pnacl_resource_host = LAZY_INSTANCE_INITIALIZER; 41 g_pnacl_resource_host = LAZY_INSTANCE_INITIALIZER;
42 42
43 static bool InitializePnaclResourceHost() { 43 static bool InitializePnaclResourceHost() {
44 // Must run on the main thread.
45 content::RenderThread* render_thread = content::RenderThread::Get();
46 if (!render_thread)
47 return false;
44 if (!g_pnacl_resource_host.Get()) { 48 if (!g_pnacl_resource_host.Get()) {
45 content::RenderThread* render_thread = content::RenderThread::Get();
46 if (!render_thread)
47 return false;
48 g_pnacl_resource_host.Get() = new PnaclTranslationResourceHost( 49 g_pnacl_resource_host.Get() = new PnaclTranslationResourceHost(
49 render_thread->GetIOMessageLoopProxy()); 50 render_thread->GetIOMessageLoopProxy());
50 render_thread->AddFilter(g_pnacl_resource_host.Get()); 51 render_thread->AddFilter(g_pnacl_resource_host.Get());
51 } 52 }
52 return true; 53 return true;
53 } 54 }
54 55
55 struct InstanceInfo { 56 struct InstanceInfo {
56 InstanceInfo() : plugin_pid(base::kNullProcessId), plugin_child_id(0) {} 57 InstanceInfo() : plugin_pid(base::kNullProcessId), plugin_child_id(0) {}
57 GURL url; 58 GURL url;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 uint32_t options) { 195 uint32_t options) {
195 #if defined(OS_WIN) 196 #if defined(OS_WIN)
196 return content::BrokerDuplicateHandle(source_handle, process_id, 197 return content::BrokerDuplicateHandle(source_handle, process_id,
197 target_handle, desired_access, 198 target_handle, desired_access,
198 options); 199 options);
199 #else 200 #else
200 return 0; 201 return 0;
201 #endif 202 #endif
202 } 203 }
203 204
205 int32_t EnsurePnaclInstalled(PP_Instance instance,
206 PP_CompletionCallback callback) {
207 ppapi::thunk::EnterInstance enter(instance, callback);
208 if (enter.failed())
209 return enter.retval();
210 if (!InitializePnaclResourceHost())
211 return enter.SetResult(PP_ERROR_FAILED);
212 g_pnacl_resource_host.Get()->EnsurePnaclInstalled(
213 instance,
214 enter.callback());
215 return enter.SetResult(PP_OK_COMPLETIONPENDING);
216 }
217
204 PP_FileHandle GetReadonlyPnaclFD(const char* filename) { 218 PP_FileHandle GetReadonlyPnaclFD(const char* filename) {
205 IPC::PlatformFileForTransit out_fd = IPC::InvalidPlatformFileForTransit(); 219 IPC::PlatformFileForTransit out_fd = IPC::InvalidPlatformFileForTransit();
206 IPC::Sender* sender = content::RenderThread::Get(); 220 IPC::Sender* sender = content::RenderThread::Get();
207 DCHECK(sender); 221 DCHECK(sender);
208 if (!sender->Send(new NaClHostMsg_GetReadonlyPnaclFD( 222 if (!sender->Send(new NaClHostMsg_GetReadonlyPnaclFD(
209 std::string(filename), 223 std::string(filename),
210 &out_fd))) { 224 &out_fd))) {
211 return base::kInvalidPlatformFileValue; 225 return base::kInvalidPlatformFileValue;
212 } 226 }
213
214 if (out_fd == IPC::InvalidPlatformFileForTransit()) { 227 if (out_fd == IPC::InvalidPlatformFileForTransit()) {
215 return base::kInvalidPlatformFileValue; 228 return base::kInvalidPlatformFileValue;
216 } 229 }
217
218 base::PlatformFile handle = 230 base::PlatformFile handle =
219 IPC::PlatformFileForTransitToPlatformFile(out_fd); 231 IPC::PlatformFileForTransitToPlatformFile(out_fd);
220 return handle; 232 return handle;
221 } 233 }
222 234
223 PP_FileHandle CreateTemporaryFile(PP_Instance instance) { 235 PP_FileHandle CreateTemporaryFile(PP_Instance instance) {
224 IPC::PlatformFileForTransit transit_fd = IPC::InvalidPlatformFileForTransit(); 236 IPC::PlatformFileForTransit transit_fd = IPC::InvalidPlatformFileForTransit();
225 IPC::Sender* sender = content::RenderThread::Get(); 237 IPC::Sender* sender = content::RenderThread::Get();
226 DCHECK(sender); 238 DCHECK(sender);
227 if (!sender->Send(new NaClHostMsg_NaClCreateTemporaryFile( 239 if (!sender->Send(new NaClHostMsg_NaClCreateTemporaryFile(
(...skipping 20 matching lines...) Expand all
248 PP_FileHandle* handle, 260 PP_FileHandle* handle,
249 struct PP_CompletionCallback callback) { 261 struct PP_CompletionCallback callback) {
250 ppapi::thunk::EnterInstance enter(instance, callback); 262 ppapi::thunk::EnterInstance enter(instance, callback);
251 if (enter.failed()) 263 if (enter.failed())
252 return enter.retval(); 264 return enter.retval();
253 if (!pexe_url || !last_modified || !etag || !is_hit || !handle) 265 if (!pexe_url || !last_modified || !etag || !is_hit || !handle)
254 return enter.SetResult(PP_ERROR_BADARGUMENT); 266 return enter.SetResult(PP_ERROR_BADARGUMENT);
255 if (!InitializePnaclResourceHost()) 267 if (!InitializePnaclResourceHost())
256 return enter.SetResult(PP_ERROR_FAILED); 268 return enter.SetResult(PP_ERROR_FAILED);
257 269
258 IPC::Sender* sender = content::RenderThread::Get();
259 DCHECK(sender);
260 base::Time last_modified_time; 270 base::Time last_modified_time;
261 // If FromString fails, it doesn't touch last_modified_time and we just send 271 // If FromString fails, it doesn't touch last_modified_time and we just send
262 // the default-constructed null value. 272 // the default-constructed null value.
263 base::Time::FromString(last_modified, &last_modified_time); 273 base::Time::FromString(last_modified, &last_modified_time);
264 274
265 nacl::PnaclCacheInfo cache_info; 275 nacl::PnaclCacheInfo cache_info;
266 cache_info.pexe_url = GURL(pexe_url); 276 cache_info.pexe_url = GURL(pexe_url);
267 cache_info.abi_version = abi_version; 277 cache_info.abi_version = abi_version;
268 cache_info.opt_level = opt_level; 278 cache_info.opt_level = opt_level;
269 cache_info.last_modified = last_modified_time; 279 cache_info.last_modified = last_modified_time;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 IPC::PlatformFileForTransitToPlatformFile(out_fd); 349 IPC::PlatformFileForTransitToPlatformFile(out_fd);
340 return handle; 350 return handle;
341 } 351 }
342 352
343 const PPB_NaCl_Private nacl_interface = { 353 const PPB_NaCl_Private nacl_interface = {
344 &LaunchSelLdr, 354 &LaunchSelLdr,
345 &StartPpapiProxy, 355 &StartPpapiProxy,
346 &UrandomFD, 356 &UrandomFD,
347 &Are3DInterfacesDisabled, 357 &Are3DInterfacesDisabled,
348 &BrokerDuplicateHandle, 358 &BrokerDuplicateHandle,
359 &EnsurePnaclInstalled,
349 &GetReadonlyPnaclFD, 360 &GetReadonlyPnaclFD,
350 &CreateTemporaryFile, 361 &CreateTemporaryFile,
351 &GetNexeFd, 362 &GetNexeFd,
352 &ReportTranslationFinished, 363 &ReportTranslationFinished,
353 &IsOffTheRecord, 364 &IsOffTheRecord,
354 &IsPnaclEnabled, 365 &IsPnaclEnabled,
355 &ReportNaClError, 366 &ReportNaClError,
356 &OpenNaClExecutable 367 &OpenNaClExecutable
357 }; 368 };
358 369
359 } // namespace 370 } // namespace
360 371
361 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { 372 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() {
362 return &nacl_interface; 373 return &nacl_interface;
363 } 374 }
364 375
365 #endif // DISABLE_NACL 376 #endif // DISABLE_NACL
OLDNEW
« no previous file with comments | « chrome/renderer/pepper/pnacl_translation_resource_host.cc ('k') | components/nacl/common/nacl_browser_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698