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

Side by Side Diff: components/nacl/renderer/ppb_nacl_private_impl.cc

Issue 270863006: Pepper: Miscellaneous trusted plugin cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | « no previous file | ppapi/api/private/ppb_nacl_private.idl » ('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 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "third_party/WebKit/public/web/WebLocalFrame.h" 53 #include "third_party/WebKit/public/web/WebLocalFrame.h"
54 #include "third_party/WebKit/public/web/WebPluginContainer.h" 54 #include "third_party/WebKit/public/web/WebPluginContainer.h"
55 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" 55 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
56 #include "third_party/WebKit/public/web/WebURLLoaderOptions.h" 56 #include "third_party/WebKit/public/web/WebURLLoaderOptions.h"
57 #include "third_party/jsoncpp/source/include/json/reader.h" 57 #include "third_party/jsoncpp/source/include/json/reader.h"
58 #include "third_party/jsoncpp/source/include/json/value.h" 58 #include "third_party/jsoncpp/source/include/json/value.h"
59 59
60 namespace nacl { 60 namespace nacl {
61 namespace { 61 namespace {
62 62
63 // The pseudo-architecture used to indicate portable native client.
64 const char* const kPortableArch = "portable";
65
63 base::LazyInstance<scoped_refptr<PnaclTranslationResourceHost> > 66 base::LazyInstance<scoped_refptr<PnaclTranslationResourceHost> >
64 g_pnacl_resource_host = LAZY_INSTANCE_INITIALIZER; 67 g_pnacl_resource_host = LAZY_INSTANCE_INITIALIZER;
65 68
66 bool InitializePnaclResourceHost() { 69 bool InitializePnaclResourceHost() {
67 // Must run on the main thread. 70 // Must run on the main thread.
68 content::RenderThread* render_thread = content::RenderThread::Get(); 71 content::RenderThread* render_thread = content::RenderThread::Get();
69 if (!render_thread) 72 if (!render_thread)
70 return false; 73 return false;
71 if (!g_pnacl_resource_host.Get()) { 74 if (!g_pnacl_resource_host.Get()) {
72 g_pnacl_resource_host.Get() = new PnaclTranslationResourceHost( 75 g_pnacl_resource_host.Get() = new PnaclTranslationResourceHost(
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 897
895 PP_Var GetManifestURLArgument(PP_Instance instance) { 898 PP_Var GetManifestURLArgument(PP_Instance instance) {
896 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); 899 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance);
897 if (load_manager) { 900 if (load_manager) {
898 return ppapi::StringVar::StringToPPVar( 901 return ppapi::StringVar::StringToPPVar(
899 load_manager->GetManifestURLArgument()); 902 load_manager->GetManifestURLArgument());
900 } 903 }
901 return PP_MakeUndefined(); 904 return PP_MakeUndefined();
902 } 905 }
903 906
904 PP_Bool IsPNaCl(PP_Instance instance) {
905 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance);
906 if (load_manager)
907 return PP_FromBool(load_manager->IsPNaCl());
908 return PP_FALSE;
909 }
910
911 PP_Bool DevInterfacesEnabled(PP_Instance instance) { 907 PP_Bool DevInterfacesEnabled(PP_Instance instance) {
912 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); 908 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance);
913 if (load_manager) 909 if (load_manager)
914 return PP_FromBool(load_manager->DevInterfacesEnabled()); 910 return PP_FromBool(load_manager->DevInterfacesEnabled());
915 return PP_FALSE; 911 return PP_FALSE;
916 } 912 }
917 913
918 void DownloadManifestToBufferCompletion(PP_Instance instance, 914 void DownloadManifestToBufferCompletion(PP_Instance instance,
919 struct PP_CompletionCallback callback, 915 struct PP_CompletionCallback callback,
920 struct PP_Var* out_data, 916 struct PP_Var* out_data,
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 } 1014 }
1019 callback.func(callback.user_data, pp_error); 1015 callback.func(callback.user_data, pp_error);
1020 } 1016 }
1021 1017
1022 int32_t CreatePNaClManifest(PP_Instance /* instance */) { 1018 int32_t CreatePNaClManifest(PP_Instance /* instance */) {
1023 return GetPNaClManifestId(); 1019 return GetPNaClManifestId();
1024 } 1020 }
1025 1021
1026 int32_t CreateJsonManifest(PP_Instance instance, 1022 int32_t CreateJsonManifest(PP_Instance instance,
1027 const char* manifest_url, 1023 const char* manifest_url,
1028 const char* isa_type,
1029 const char* manifest_data) { 1024 const char* manifest_data) {
1025 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance);
1026 if (!load_manager)
1027 return -1;
1030 int32_t manifest_id = g_next_manifest_id.Get(); 1028 int32_t manifest_id = g_next_manifest_id.Get();
1031 g_next_manifest_id.Get()++; 1029 g_next_manifest_id.Get()++;
1032 1030
1031 const char* isa_type;
1032 if (load_manager->IsPNaCl())
1033 isa_type = kPortableArch;
1034 else
1035 isa_type = GetSandboxArch();
1036
1033 scoped_ptr<nacl::JsonManifest> j( 1037 scoped_ptr<nacl::JsonManifest> j(
1034 new nacl::JsonManifest( 1038 new nacl::JsonManifest(
1035 manifest_url, 1039 manifest_url,
1036 isa_type, 1040 isa_type,
1037 PP_ToBool(IsNonSFIModeEnabled()), 1041 PP_ToBool(IsNonSFIModeEnabled()),
1038 PP_ToBool(NaClDebugEnabledForURL(manifest_url)))); 1042 PP_ToBool(NaClDebugEnabledForURL(manifest_url))));
1039 JsonManifest::ErrorInfo error_info; 1043 JsonManifest::ErrorInfo error_info;
1040 if (j->Init(manifest_data, &error_info)) { 1044 if (j->Init(manifest_data, &error_info)) {
1041 g_manifest_map.Get().add(manifest_id, j.Pass()); 1045 g_manifest_map.Get().add(manifest_id, j.Pass());
1042 return manifest_id; 1046 return manifest_id;
1043 } 1047 }
1044 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); 1048 load_manager->ReportLoadError(error_info.error, error_info.string);
1045 if (load_manager)
1046 load_manager->ReportLoadError(error_info.error, error_info.string);
1047 return -1; 1049 return -1;
1048 } 1050 }
1049 1051
1050 void DestroyManifest(PP_Instance /* instance */, 1052 void DestroyManifest(PP_Instance /* instance */,
1051 int32_t manifest_id) { 1053 int32_t manifest_id) {
1052 if (manifest_id == GetPNaClManifestId()) 1054 if (manifest_id == GetPNaClManifestId())
1053 return; 1055 return;
1054 g_manifest_map.Get().erase(manifest_id); 1056 g_manifest_map.Get().erase(manifest_id);
1055 } 1057 }
1056 1058
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 &SetExitStatus, 1290 &SetExitStatus,
1289 &Vlog, 1291 &Vlog,
1290 &InitializePlugin, 1292 &InitializePlugin,
1291 &GetNexeSize, 1293 &GetNexeSize,
1292 &RequestNaClManifest, 1294 &RequestNaClManifest,
1293 &GetManifestBaseURL, 1295 &GetManifestBaseURL,
1294 &ResolvesRelativeToPluginBaseURL, 1296 &ResolvesRelativeToPluginBaseURL,
1295 &ParseDataURL, 1297 &ParseDataURL,
1296 &ProcessNaClManifest, 1298 &ProcessNaClManifest,
1297 &GetManifestURLArgument, 1299 &GetManifestURLArgument,
1298 &IsPNaCl,
1299 &DevInterfacesEnabled, 1300 &DevInterfacesEnabled,
1300 &DownloadManifestToBuffer, 1301 &DownloadManifestToBuffer,
1301 &CreatePNaClManifest, 1302 &CreatePNaClManifest,
1302 &CreateJsonManifest, 1303 &CreateJsonManifest,
1303 &DestroyManifest, 1304 &DestroyManifest,
1304 &ManifestGetProgramURL, 1305 &ManifestGetProgramURL,
1305 &ManifestResolveKey, 1306 &ManifestResolveKey,
1306 &GetPNaClResourceInfo, 1307 &GetPNaClResourceInfo,
1307 &GetCpuFeatureAttrs, 1308 &GetCpuFeatureAttrs,
1308 &PostMessageToJavaScript 1309 &PostMessageToJavaScript
1309 }; 1310 };
1310 1311
1311 } // namespace 1312 } // namespace
1312 1313
1313 const PPB_NaCl_Private* GetNaClPrivateInterface() { 1314 const PPB_NaCl_Private* GetNaClPrivateInterface() {
1314 return &nacl_interface; 1315 return &nacl_interface;
1315 } 1316 }
1316 1317
1317 } // namespace nacl 1318 } // namespace nacl
OLDNEW
« no previous file with comments | « no previous file | ppapi/api/private/ppb_nacl_private.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698