+bool PackageInstaller::Reinstall(const std::string& pkgid) {
+ base::FilePath app_dir = xwalk::application::GetPackagePath(pkgid);
+
+ if (!base::DirectoryExists(app_dir)) {
+ LOG(ERROR) << "Application directory " << app_dir.value()
+ << " does not exist!";
+ return false;
+ }
+
+ RDSDeltaParser rds_parser(app_dir, pkgid);
+ if (!rds_parser.Parse())
+ return false;
+
+ if (!rds_parser.ApplyParsedData())
+ return false;
+
+ if (!PlatformReinstall(pkgid)) {
+ LOG(ERROR) << "Reinstallation of package " << pkgid
+ << " has failed due to a platform error!";
+ return false;
+ }
+
+ LOG(INFO) << "Package " << pkgid << " has been reinstalled successfully";
+ return true;