Remove redundant CommandLine class 55/189655/2
authorws29.jung <ws29.jung@samsung.com>
Wed, 19 Sep 2018 10:59:44 +0000 (19:59 +0900)
committerjaekuk lee <juku1999@samsung.com>
Thu, 20 Sep 2018 21:19:48 +0000 (21:19 +0000)
Electron-efl had 3 different CommandLine classes which do the job
not very different and they weren't a inherited class of any other.
From this patch, common::CommandLine class is removed and only
AtomCommandLine and base::CommandLine are left.

Change-Id: Ic6a85e29a153461771f2441fc3321141f0ce3624
Signed-off-by: ws29.jung <ws29.jung@samsung.com>
atom/common/atom_command_line.cc
atom/common/atom_command_line.h
tizen/common/common.gyp
tizen/src/browser/api/wrt_api_core.cc
tizen/src/wrt_main.cc

index 08880ff..4a5bfe9 100644 (file)
@@ -11,7 +11,7 @@ namespace atom {
 
 // static
 std::vector<std::string> AtomCommandLine::argv_;
-
+int AtomCommandLine::argc_;
 #if defined(OS_WIN)
 // static
 std::vector<std::wstring> AtomCommandLine::wargv_;
@@ -20,6 +20,7 @@ std::vector<std::wstring> AtomCommandLine::wargv_;
 // static
 void AtomCommandLine::Init(int argc, const char* const* argv) {
   // Hack around with the argv pointer. Used for process.title = "blah"
+  argc_ = argc;
   char** new_argv = uv_setup_args(argc, const_cast<char**>(argv));
   for (int i = 0; i < argc; ++i) {
     argv_.push_back(new_argv[i]);
@@ -42,4 +43,20 @@ void AtomCommandLine::InitializeFromCommandLine() {
 }
 #endif
 
+std::string AtomCommandLine::GetAppIdFromCommandLine(const std::string& program) {
+  if (argc_ > 0) {
+    std::string tmp = argv_[0];
+    if (tmp == program) {
+      if (argv_.size() > 0) {
+        // Suppose that appid is at the first of arguments_
+        return argv_[0];
+      }
+    } else {
+      return tmp;
+    }
+  }
+  return std::string();
+}
+
+
 }  // namespace atom
index a834ce9..3b6d689 100644 (file)
@@ -29,9 +29,10 @@ class AtomCommandLine {
   // it is using zygote.
   static void InitializeFromCommandLine();
 #endif
-
+  static std::string GetAppIdFromCommandLine(const std::string& program);
  private:
   static std::vector<std::string> argv_;
+  static int argc_;
 
 #if defined(OS_WIN)
   static std::vector<std::wstring> wargv_;
index 637f5c4..7dbb07d 100644 (file)
@@ -7,8 +7,6 @@
       'target_name': 'wrt_common',
       'type': 'shared_library',
       'sources': [
-        'command_line.h',
-        'command_line.cc',
         'constants.h',
         'constants.cc',
         'file_utils.h',
index e58d525..c63f6b8 100755 (executable)
@@ -3,12 +3,12 @@
 #include <dlog.h>
 
 #include "atom/browser/browser.h"
+#include "atom/common/atom_command_line.h"
 #include "atom/common/node_includes.h"
 #include "base/files/file_path.h"
 #include "base/logging.h"
 #include "native_mate/dictionary.h"
 #include "tizen/common/application_data.h"
-#include "tizen/common/command_line.h"
 #include "tizen/src/browser/native_web_runtime.h"
 #include "tizen/src/browser/wrt_service.h"
 
@@ -77,10 +77,7 @@ std::string WebRuntime::GetPath() const {
 }
 
 bool WebRuntime::isTizenWebApp() const {
-  common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess();
-  if (!runtime_cmd)
-    return false;
-  std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/electron");
+  std::string appid = atom::AtomCommandLine::GetAppIdFromCommandLine("/usr/bin/electron");
   if (appid != "electron") { // TODO: Any better distinguishing feature?
     return true;
   } else {
index 38ccdfa..87fd3e8 100644 (file)
@@ -20,7 +20,6 @@
 #if defined(OS_TIZEN)
 #include "atom/app/runtime.h"
 #include "tizen/common/application_data.h"
-#include "tizen/common/command_line.h"
 #include "tizen/loader/prelauncher.h"
 #include "tizen/browser/preload_manager.h"
 #endif
@@ -42,19 +41,14 @@ int real_main(int argc, char* argv[]) {
   for (int i = 0; i < argc; ++i)
     LOG(INFO) << "argv[" << i << "] : " << argv[i];
 
-  if (!common::CommandLine::Init(argc, argv)) {
-    common::CommandLine::Reset();
-    common::CommandLine::Init(argc, argv);
-  }
-
   if (base::CommandLine::InitializedForCurrentProcess()) {
     base::CommandLine::ForCurrentProcess()->SetProgram(base::FilePath(argv[0]));
   } else {
     base::CommandLine::Init(argc, argv);
   }
 
-  common::CommandLine* runtime_cmd = common::CommandLine::ForCurrentProcess();
-  std::string appid = runtime_cmd->GetAppIdFromCommandLine("/usr/bin/wrt");
+  atom::AtomCommandLine::Init(argc, argv);
+  std::string appid = atom::AtomCommandLine::GetAppIdFromCommandLine("/usr/bin/wrt");
 
   base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
   bool is_browser_process =
@@ -100,6 +94,7 @@ int main(int argc, const char* argv[]) {
     LOG(INFO) << "run with wrt-loader";
     for (int i = 0; i < argc; ++i)
       LOG(INFO) << "argv[" << i << "] : " << argv[i];
+
     int no_argument_count = 1;
     atom::AtomCommandLine::Init(no_argument_count, argv);