[WRTjs][VD] Refactors WRTContentMain and its delegate 92/289492/8
authorDongHyun Song <dh81.song@samsung.com>
Thu, 9 Mar 2023 00:14:02 +0000 (09:14 +0900)
committerBot Blink <blinkbot@samsung.com>
Mon, 13 Mar 2023 05:38:58 +0000 (05:38 +0000)
Refactors usage of delegate and remove TV profile guard.

Change-Id: I4fbbf8b60caf228c36ebccdda704b81c0a12306c
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
wrt/src/app/tv/wrt_main_delegate_tv.cc
wrt/src/app/tv/wrt_main_delegate_tv.h
wrt/src/app/wrt_content_main.cc
wrt/src/app/wrt_content_main.h
wrt/src/app/wrt_main_delegate.h

index 2789844..e5e6042 100644 (file)
@@ -225,7 +225,9 @@ void WRTMainDelegateTV::LoaderTerminated() {
   reallaunch_mutex.unlock();
 }
 
-void WRTMainDelegateTV::PrelaunchOnLoader(const std::string& pkg_id) {
+void WRTMainDelegateTV::PrelaunchOnLoader(const std::string& app_path,
+                                          const std::string& pkg_id) {
+  base::CommandLine::ForCurrentProcess()->SetProgram(base::FilePath(app_path));
   prelaunch_pkg_id = pkg_id;
   prelaunch_mutex.unlock();
 }
index 9f6e274..f543f41 100644 (file)
@@ -21,7 +21,8 @@ class WRTMainDelegateTV : public WRTMainDelegate {
   bool CheckPlatformReady(int argc, char** argv) override;
   void LoaderCreated() override;
   void LoaderTerminated() override;
-  void PrelaunchOnLoader(const std::string& pkg_id) override;
+  void PrelaunchOnLoader(const std::string& app_path,
+                         const std::string& pkg_id) override;
   bool PreSetup() override;
   absl::optional<int> PostEarlyInitialization(InvokedIn invoked_in) override;
 
index b6c0fcc..cf7f7ad 100644 (file)
@@ -60,7 +60,7 @@ class WRTContentMain::Loader {
             LOG(INFO) << "ContentMain will be initialized in idler.";
             auto* content_main = static_cast<WRTContentMain*>(data);
             content_main->Initialize();
-            content_main->main_delegate_->LoaderCreated();
+            content_main->LoaderCreated();
             return ECORE_CALLBACK_CANCEL;
           }, static_cast<Loader*>(user_data)->content_main_);
     };
@@ -69,12 +69,8 @@ class WRTContentMain::Loader {
                             const char* appid, const char* pkgid,
                             const char* pkg_type, void* user_data) {
       LOG(INFO) << "loader prelaunch";
-#if BUILDFLAG(IS_TIZEN_TV)
-      base::CommandLine::ForCurrentProcess()->SetProgram(
-          base::FilePath(app_path));
       auto* content_main = static_cast<Loader*>(user_data)->content_main_;
-      content_main->main_delegate_->PrelaunchOnLoader(pkgid);
-#endif
+      content_main->PrelaunchOnLoader(app_path, pkgid);
       return 0;
     };
 #endif
@@ -175,6 +171,17 @@ void WRTContentMain::Initialize() {
     LOG(FATAL) << "Fail to initialize content main runner";
 }
 
+void WRTContentMain::LoaderCreated() {
+  if (main_delegate_)
+    main_delegate_->LoaderCreated();
+}
+
+void WRTContentMain::PrelaunchOnLoader(const std::string& app_path,
+                                       const std::string& pkg_id) {
+  if (main_delegate_)
+    main_delegate_->PrelaunchOnLoader(app_path, pkg_id);
+}
+
 int WRTContentMain::Main(int argc, char** argv) {
 #if BUILDFLAG(USE_ALLOCATOR_SHIM)
   heap_profiling::InitTLSSlot();
index 37ad18b..ca09c2a 100755 (executable)
@@ -19,9 +19,13 @@ class WRTContentMain {
   int Main(int argc, char** argv);
 
  private:
-  void Initialize();
   int Run(int argc, char** argv);
 
+  void Initialize();
+  void LoaderCreated();
+  void PrelaunchOnLoader(const std::string& app_path,
+                         const std::string& pkg_id);
+
   class Loader;
 
   std::unique_ptr<WRTMainDelegate> main_delegate_;
index 2545c0e..9d75927 100644 (file)
@@ -20,7 +20,8 @@ class WRTMainDelegate : public electron::ElectronMainDelegate {
   virtual bool CheckPlatformReady(int argc, char** argv) { return true; }
   virtual void LoaderCreated() {}
   virtual void LoaderTerminated() {}
-  virtual void PrelaunchOnLoader(const std::string& pkg_id) {}
+  virtual void PrelaunchOnLoader(const std::string& app_path,
+                                 const std::string& pkg_id) {}
   virtual bool PreSetup();
 
   WRTProfileDelegate* GetRuntimeDelegate() { return runtime_delegate_; }