Extract functions for refactoring 36/238236/3
authorJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 9 Jul 2020 23:40:05 +0000 (08:40 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 23 Jul 2020 04:44:27 +0000 (13:44 +0900)
Change-Id: I673b23b81661784effe2377c3fa46186e6ec07ea
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/unified/unified_installer_factory.cc
src/unified/unified_installer_factory.h

index a15964501439948801ccbb6b6fecdd463a66bb73..78b7bb4686ebd7fc50db6a9960b078e1d95551f5 100644 (file)
@@ -68,17 +68,25 @@ std::string GetPkgTypeFromFilename(const boost::filesystem::path& name) {
 
 namespace common_installer {
 
-std::unique_ptr<AppInstaller> UnifiedInstallerFactory::CreateInstaller(
-    PkgMgrPtr pkgmgr, int idx) {
-  std::string type = GetPkgTypeFromPkgid(pkgmgr->GetRequestInfo(idx),
-      pkgmgr->GetUid());
+std::string UnifiedInstallerFactory::GetPkgType(
+    const std::string& info, uid_t uid) {
+  std::string type;
+  type = GetPkgTypeFromPkgid(info, uid);
 
   if (type.empty())
-    type = GetPkgTypeFromPath(pkgmgr->GetRequestInfo(idx));
+    type = GetPkgTypeFromPath(info);
 
   if (type.empty())
     type = GetPkgTypeFromFilename(
-        boost::filesystem::path(pkgmgr->GetRequestInfo(idx)).filename());
+        boost::filesystem::path(info).filename());
+
+  return type;
+}
+
+std::unique_ptr<AppInstaller> UnifiedInstallerFactory::CreateInstaller(
+    PkgMgrPtr pkgmgr, int idx) {
+  std::string type = GetPkgType(pkgmgr->GetRequestInfo(idx),
+      pkgmgr->GetUid());
 
   if (type.empty())
     return {};
index 9e12aa8f2e189b85833d29827ad316b9296e03d4..db6df607cd86645bd54802165d7399c88384c2bb 100644 (file)
@@ -17,6 +17,9 @@ class AppInstaller;
 class UnifiedInstallerFactory : public InstallerFactory {
  public:
   std::unique_ptr<AppInstaller> CreateInstaller(PkgMgrPtr pkgmgr, int idx);
+
+ private:
+  std::string GetPkgType(const std::string& info, uid_t uid);
 };
 
 }  // namespace common_installer