[M120 Migration][NaCl][PPFWK] Change plugin process name 72/308472/2
authorjinbei09 <jinbei09.dai@samsung.com>
Tue, 26 Mar 2024 07:23:06 +0000 (15:23 +0800)
committerBot Blink <blinkbot@samsung.com>
Tue, 26 Mar 2024 19:03:50 +0000 (19:03 +0000)
Migrated from tizen 8.0:
https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/297941/

Change-Id: I59ba9d24bcc42c721fa35ff05c5f204d3d1e4f47
Signed-off-by: jinbei09 <jinbei09.dai@samsung.com>
content/ppapi_plugin/ppapi_thread.cc
packaging/chromium-efl.spec

index 524a255..de959d9 100644 (file)
 #include "sandbox/win/src/sandbox.h"
 #endif
 
+#if defined(TIZEN_PEPPER_EXTENSIONS)
+#include <sys/prctl.h>
+#include "base/files/file_path.h"
+#include "content/common/set_process_title_linux.h"
+#endif
+
 #if BUILDFLAG(IS_MAC)
 #include "sandbox/mac/seatbelt_exec.h"
 #endif
@@ -73,6 +79,33 @@ static void WarmupWindowsLocales(const ppapi::PpapiPermissions& permissions) {
 
 namespace content {
 
+#if defined(TIZEN_PEPPER_EXTENSIONS)
+namespace {
+
+void UpdateProcessTitle(const std::u16string& plugin_name) {
+  constexpr char kPepperPluginProcessName[] = "efl_pluginprocess";
+  constexpr char kLibPrefix[] = "lib";
+  constexpr int kLibPrefixLength = sizeof(kLibPrefix) - 1;
+
+  auto command_line = base::CommandLine::ForCurrentProcess();
+  auto program_dir = command_line->GetProgram().DirName();
+  auto updated_program_path = program_dir.Append(kPepperPluginProcessName);
+
+  auto plugin_name_utf8 = base::UTF16ToUTF8(plugin_name);
+  if (plugin_name_utf8.length() > kLibPrefixLength &&
+      plugin_name_utf8.compare(0, kLibPrefixLength, kLibPrefix) == 0) {
+    plugin_name_utf8 = plugin_name_utf8.substr(kLibPrefixLength);
+  }
+
+  prctl(PR_SET_NAME, plugin_name_utf8.c_str());
+  setproctitle("-%s %s %s", updated_program_path.value().c_str(),
+               plugin_name_utf8.c_str(),
+               command_line->GetArgumentsString().c_str());
+}
+
+}  // namespace
+#endif
+
 PpapiThread::PpapiThread(base::RepeatingClosure quit_closure,
                          const base::CommandLine& command_line)
     : ChildThreadImpl(std::move(quit_closure)),
@@ -379,6 +412,10 @@ bool PpapiThread::SetupChannel(base::ProcessId renderer_pid,
 void PpapiThread::SavePluginName(const base::FilePath& path) {
   ppapi::proxy::PluginGlobals::Get()->set_plugin_name(
       path.BaseName().AsUTF8Unsafe());
+
+#if defined(TIZEN_PEPPER_EXTENSIONS)
+  UpdateProcessTitle(path.BaseName().RemoveExtension().LossyDisplayName());
+#endif
 }
 
 }  // namespace content
index aace036..cf4502c 100644 (file)
@@ -1231,10 +1231,6 @@ rm -rf %{CHROMIUM_TPK_DIR}/%{_tpk_file_name}.tpk
 /opt/usr/resources/*
 %endif
 
-%if "%{chromium_efl_tizen_profile}" == "tv"
-ln -s %{CHROMIUM_EXE_DIR}/efl_webprocess %{buildroot}%{CHROMIUM_EXE_DIR}/efl_pluginprocess
-%endif
-
 %if 0%{?build_tizen_ppapi_extension_unittests}
 %files tizen_ppapi_extension_unittests
 %defattr(-,root,root,-)