OLD | NEW |
---|---|
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/renderer/ppb_nacl_private_impl.h" | 5 #include "components/nacl/renderer/ppb_nacl_private_impl.h" |
6 | 6 |
7 #include <numeric> | 7 #include <numeric> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 | 65 |
66 namespace nacl { | 66 namespace nacl { |
67 namespace { | 67 namespace { |
68 | 68 |
69 // The pseudo-architecture used to indicate portable native client. | 69 // The pseudo-architecture used to indicate portable native client. |
70 const char* const kPortableArch = "portable"; | 70 const char* const kPortableArch = "portable"; |
71 | 71 |
72 // The base URL for resources used by the PNaCl translator processes. | 72 // The base URL for resources used by the PNaCl translator processes. |
73 const char* kPNaClTranslatorBaseUrl = "chrome://pnacl-translator/"; | 73 const char* kPNaClTranslatorBaseUrl = "chrome://pnacl-translator/"; |
74 | 74 |
75 base::LazyInstance<scoped_refptr<PnaclTranslationResourceHost> > | 75 base::LazyInstance<scoped_refptr<PnaclTranslationResourceHost> > |
Mark Seaborn
2014/08/26 18:31:52
As an aside, this use of base::LazyInstance<scoped
| |
76 g_pnacl_resource_host = LAZY_INSTANCE_INITIALIZER; | 76 g_pnacl_resource_host = LAZY_INSTANCE_INITIALIZER; |
77 | 77 |
78 bool InitializePnaclResourceHost() { | 78 bool InitializePnaclResourceHost() { |
79 // Must run on the main thread. | 79 // Must run on the main thread. |
80 content::RenderThread* render_thread = content::RenderThread::Get(); | 80 content::RenderThread* render_thread = content::RenderThread::Get(); |
81 if (!render_thread) | 81 if (!render_thread) |
82 return false; | 82 return false; |
83 if (!g_pnacl_resource_host.Get()) { | 83 if (!g_pnacl_resource_host.Get().get()) { |
84 g_pnacl_resource_host.Get() = new PnaclTranslationResourceHost( | 84 g_pnacl_resource_host.Get() = new PnaclTranslationResourceHost( |
85 render_thread->GetIOMessageLoopProxy()); | 85 render_thread->GetIOMessageLoopProxy()); |
86 render_thread->AddFilter(g_pnacl_resource_host.Get()); | 86 render_thread->AddFilter(g_pnacl_resource_host.Get().get()); |
87 } | 87 } |
88 return true; | 88 return true; |
89 } | 89 } |
90 | 90 |
91 struct InstanceInfo { | 91 struct InstanceInfo { |
92 InstanceInfo() : plugin_pid(base::kNullProcessId), plugin_child_id(0) {} | 92 InstanceInfo() : plugin_pid(base::kNullProcessId), plugin_child_id(0) {} |
93 GURL url; | 93 GURL url; |
94 ppapi::PpapiPermissions permissions; | 94 ppapi::PpapiPermissions permissions; |
95 base::ProcessId plugin_pid; | 95 base::ProcessId plugin_pid; |
96 int plugin_child_id; | 96 int plugin_child_id; |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
655 HistogramTimeTranslation("NaCl.Perf.PNaClLoadTime.TotalUncachedTime", | 655 HistogramTimeTranslation("NaCl.Perf.PNaClLoadTime.TotalUncachedTime", |
656 total_time.InMilliseconds()); | 656 total_time.InMilliseconds()); |
657 HistogramKBPerSec("NaCl.Perf.PNaClLoadTime.TotalUncachedKBPerSec", | 657 HistogramKBPerSec("NaCl.Perf.PNaClLoadTime.TotalUncachedKBPerSec", |
658 pexe_size / 1024, | 658 pexe_size / 1024, |
659 total_time.InMicroseconds()); | 659 total_time.InMicroseconds()); |
660 } | 660 } |
661 } | 661 } |
662 | 662 |
663 // If the resource host isn't initialized, don't try to do that here. | 663 // If the resource host isn't initialized, don't try to do that here. |
664 // Just return because something is already very wrong. | 664 // Just return because something is already very wrong. |
665 if (g_pnacl_resource_host.Get() == NULL) | 665 if (g_pnacl_resource_host.Get().get() == NULL) |
666 return; | 666 return; |
667 g_pnacl_resource_host.Get()->ReportTranslationFinished(instance, success); | 667 g_pnacl_resource_host.Get()->ReportTranslationFinished(instance, success); |
668 } | 668 } |
669 | 669 |
670 PP_FileHandle OpenNaClExecutable(PP_Instance instance, | 670 PP_FileHandle OpenNaClExecutable(PP_Instance instance, |
671 const char* file_url, | 671 const char* file_url, |
672 uint64_t* nonce_lo, | 672 uint64_t* nonce_lo, |
673 uint64_t* nonce_hi) { | 673 uint64_t* nonce_hi) { |
674 // Fast path only works for installed file URLs. | 674 // Fast path only works for installed file URLs. |
675 GURL gurl(file_url); | 675 GURL gurl(file_url); |
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1710 &StreamPexe | 1710 &StreamPexe |
1711 }; | 1711 }; |
1712 | 1712 |
1713 } // namespace | 1713 } // namespace |
1714 | 1714 |
1715 const PPB_NaCl_Private* GetNaClPrivateInterface() { | 1715 const PPB_NaCl_Private* GetNaClPrivateInterface() { |
1716 return &nacl_interface; | 1716 return &nacl_interface; |
1717 } | 1717 } |
1718 | 1718 |
1719 } // namespace nacl | 1719 } // namespace nacl |
OLD | NEW |