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

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

Issue 315753003: Pepper: Miscellaneous trusted plugin cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 } 799 }
800 800
801 PP_NaClReadyState GetNaClReadyState(PP_Instance instance) { 801 PP_NaClReadyState GetNaClReadyState(PP_Instance instance) {
802 NexeLoadManager* load_manager = GetNexeLoadManager(instance); 802 NexeLoadManager* load_manager = GetNexeLoadManager(instance);
803 DCHECK(load_manager); 803 DCHECK(load_manager);
804 if (load_manager) 804 if (load_manager)
805 return load_manager->nacl_ready_state(); 805 return load_manager->nacl_ready_state();
806 return PP_NACL_READY_STATE_UNSENT; 806 return PP_NACL_READY_STATE_UNSENT;
807 } 807 }
808 808
809 PP_Bool GetIsInstalled(PP_Instance instance) {
810 NexeLoadManager* load_manager = GetNexeLoadManager(instance);
811 DCHECK(load_manager);
812 if (load_manager)
813 return PP_FromBool(load_manager->is_installed());
814 return PP_FALSE;
815 }
816
817 int32_t GetExitStatus(PP_Instance instance) { 809 int32_t GetExitStatus(PP_Instance instance) {
818 NexeLoadManager* load_manager = GetNexeLoadManager(instance); 810 NexeLoadManager* load_manager = GetNexeLoadManager(instance);
819 DCHECK(load_manager); 811 DCHECK(load_manager);
820 if (load_manager) 812 if (load_manager)
821 return load_manager->exit_status(); 813 return load_manager->exit_status();
822 return -1; 814 return -1;
823 } 815 }
824 816
825 void SetExitStatus(PP_Instance instance, int32_t exit_status) { 817 void SetExitStatus(PP_Instance instance, int32_t exit_status) {
826 NexeLoadManager* load_manager = GetNexeLoadManager(instance); 818 NexeLoadManager* load_manager = GetNexeLoadManager(instance);
(...skipping 25 matching lines...) Expand all
852 } 844 }
853 845
854 void DownloadManifestToBuffer(PP_Instance instance, 846 void DownloadManifestToBuffer(PP_Instance instance,
855 struct PP_CompletionCallback callback); 847 struct PP_CompletionCallback callback);
856 848
857 bool CreateJsonManifest(PP_Instance instance, 849 bool CreateJsonManifest(PP_Instance instance,
858 const std::string& manifest_url, 850 const std::string& manifest_url,
859 const std::string& manifest_data); 851 const std::string& manifest_data);
860 852
861 void RequestNaClManifest(PP_Instance instance, 853 void RequestNaClManifest(PP_Instance instance,
862 const char* url,
863 PP_CompletionCallback callback) { 854 PP_CompletionCallback callback) {
864 NexeLoadManager* load_manager = GetNexeLoadManager(instance); 855 NexeLoadManager* load_manager = GetNexeLoadManager(instance);
865 DCHECK(load_manager); 856 DCHECK(load_manager);
866 if (!load_manager) { 857 if (!load_manager) {
867 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( 858 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask(
868 FROM_HERE, 859 FROM_HERE,
869 base::Bind(callback.func, callback.user_data, 860 base::Bind(callback.func, callback.user_data,
870 static_cast<int32_t>(PP_ERROR_FAILED))); 861 static_cast<int32_t>(PP_ERROR_FAILED)));
871 return; 862 return;
872 } 863 }
873 864
874 if (!load_manager->RequestNaClManifest(url)) { 865 std::string url = load_manager->GetManifestURLArgument();
866 if (url.empty() || !load_manager->RequestNaClManifest(url)) {
875 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( 867 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask(
876 FROM_HERE, 868 FROM_HERE,
877 base::Bind(callback.func, callback.user_data, 869 base::Bind(callback.func, callback.user_data,
878 static_cast<int32_t>(PP_ERROR_FAILED))); 870 static_cast<int32_t>(PP_ERROR_FAILED)));
879 return; 871 return;
880 } 872 }
881 873
882 const GURL& base_url = load_manager->manifest_base_url(); 874 const GURL& base_url = load_manager->manifest_base_url();
883 if (base_url.SchemeIs("data")) { 875 if (base_url.SchemeIs("data")) {
884 GURL gurl(base_url); 876 GURL gurl(base_url);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 return PP_MakeUndefined(); 908 return PP_MakeUndefined();
917 return ppapi::StringVar::StringToPPVar(gurl.spec()); 909 return ppapi::StringVar::StringToPPVar(gurl.spec());
918 } 910 }
919 911
920 void ProcessNaClManifest(PP_Instance instance, const char* program_url) { 912 void ProcessNaClManifest(PP_Instance instance, const char* program_url) {
921 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); 913 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance);
922 if (load_manager) 914 if (load_manager)
923 load_manager->ProcessNaClManifest(program_url); 915 load_manager->ProcessNaClManifest(program_url);
924 } 916 }
925 917
926 PP_Var GetManifestURLArgument(PP_Instance instance) {
927 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance);
928 if (load_manager) {
929 return ppapi::StringVar::StringToPPVar(
930 load_manager->GetManifestURLArgument());
931 }
932 return PP_MakeUndefined();
933 }
934
935 PP_Bool DevInterfacesEnabled(PP_Instance instance) { 918 PP_Bool DevInterfacesEnabled(PP_Instance instance) {
936 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); 919 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance);
937 if (load_manager) 920 if (load_manager)
938 return PP_FromBool(load_manager->DevInterfacesEnabled()); 921 return PP_FromBool(load_manager->DevInterfacesEnabled());
939 return PP_FALSE; 922 return PP_FALSE;
940 } 923 }
941 924
942 void DownloadManifestToBufferCompletion(PP_Instance instance, 925 void DownloadManifestToBufferCompletion(PP_Instance instance,
943 struct PP_CompletionCallback callback, 926 struct PP_CompletionCallback callback,
944 base::Time start_time, 927 base::Time start_time,
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 // FileDownloader deletes itself after invoking DownloadNexeCompletion. 1504 // FileDownloader deletes itself after invoking DownloadNexeCompletion.
1522 FileDownloader* file_downloader = new FileDownloader( 1505 FileDownloader* file_downloader = new FileDownloader(
1523 url_loader.Pass(), 1506 url_loader.Pass(),
1524 target_file, 1507 target_file,
1525 base::Bind(&DownloadFileCompletion, target_file, file_info, callback), 1508 base::Bind(&DownloadFileCompletion, target_file, file_info, callback),
1526 base::Bind(&ProgressEventRateLimiter::ReportProgress, 1509 base::Bind(&ProgressEventRateLimiter::ReportProgress,
1527 base::Owned(tracker), url)); 1510 base::Owned(tracker), url));
1528 file_downloader->Load(url_request); 1511 file_downloader->Load(url_request);
1529 } 1512 }
1530 1513
1514 void ReportSelLdrStatus(PP_Instance instance,
1515 int32_t load_status,
1516 int32_t max_status) {
1517 HistogramEnumerate("NaCl.LoadStatus.SelLdr", load_status, max_status);
1518 NexeLoadManager* load_manager = GetNexeLoadManager(instance);
1519 DCHECK(load_manager);
1520 if (!load_manager)
1521 return;
1522
1523 // Gather data to see if being installed changes load outcomes.
1524 const char* name = load_manager->is_installed() ?
1525 "NaCl.LoadStatus.SelLdr.InstalledApp" :
1526 "NaCl.LoadStatus.SelLdr.NotInstalledApp";
1527 HistogramEnumerate(name, load_status, max_status);
1528 }
1529
1531 const PPB_NaCl_Private nacl_interface = { 1530 const PPB_NaCl_Private nacl_interface = {
1532 &LaunchSelLdr, 1531 &LaunchSelLdr,
1533 &StartPpapiProxy, 1532 &StartPpapiProxy,
1534 &UrandomFD, 1533 &UrandomFD,
1535 &Are3DInterfacesDisabled, 1534 &Are3DInterfacesDisabled,
1536 &BrokerDuplicateHandle, 1535 &BrokerDuplicateHandle,
1537 &GetReadonlyPnaclFd, 1536 &GetReadonlyPnaclFd,
1538 &CreateTemporaryFile, 1537 &CreateTemporaryFile,
1539 &GetNumberOfProcessors, 1538 &GetNumberOfProcessors,
1540 &PPIsNonSFIModeEnabled, 1539 &PPIsNonSFIModeEnabled,
1541 &GetNexeFd, 1540 &GetNexeFd,
1542 &ReportTranslationFinished, 1541 &ReportTranslationFinished,
1543 &DispatchEvent, 1542 &DispatchEvent,
1544 &ReportLoadSuccess, 1543 &ReportLoadSuccess,
1545 &ReportLoadError, 1544 &ReportLoadError,
1546 &ReportLoadAbort, 1545 &ReportLoadAbort,
1547 &NexeDidCrash, 1546 &NexeDidCrash,
1548 &InstanceCreated, 1547 &InstanceCreated,
1549 &InstanceDestroyed, 1548 &InstanceDestroyed,
1550 &NaClDebugEnabledForURL, 1549 &NaClDebugEnabledForURL,
1551 &GetSandboxArch, 1550 &GetSandboxArch,
1552 &LogToConsole, 1551 &LogToConsole,
1553 &GetNaClReadyState, 1552 &GetNaClReadyState,
1554 &GetIsInstalled,
1555 &GetExitStatus, 1553 &GetExitStatus,
1556 &SetExitStatus, 1554 &SetExitStatus,
1557 &Vlog, 1555 &Vlog,
1558 &InitializePlugin, 1556 &InitializePlugin,
1559 &GetNexeSize, 1557 &GetNexeSize,
1560 &RequestNaClManifest, 1558 &RequestNaClManifest,
1561 &GetManifestBaseURL, 1559 &GetManifestBaseURL,
1562 &ProcessNaClManifest, 1560 &ProcessNaClManifest,
1563 &GetManifestURLArgument,
1564 &DevInterfacesEnabled, 1561 &DevInterfacesEnabled,
1565 &ManifestGetProgramURL, 1562 &ManifestGetProgramURL,
1566 &ManifestResolveKey, 1563 &ManifestResolveKey,
1567 &GetPNaClResourceInfo, 1564 &GetPNaClResourceInfo,
1568 &GetCpuFeatureAttrs, 1565 &GetCpuFeatureAttrs,
1569 &PostMessageToJavaScript, 1566 &PostMessageToJavaScript,
1570 &DownloadNexe, 1567 &DownloadNexe,
1571 &DownloadFile 1568 &DownloadFile,
1569 &ReportSelLdrStatus
1572 }; 1570 };
1573 1571
1574 } // namespace 1572 } // namespace
1575 1573
1576 const PPB_NaCl_Private* GetNaClPrivateInterface() { 1574 const PPB_NaCl_Private* GetNaClPrivateInterface() {
1577 return &nacl_interface; 1575 return &nacl_interface;
1578 } 1576 }
1579 1577
1580 } // namespace nacl 1578 } // 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