shill: Implement RemoveProfile
Also clean up the comment for Profile::set_storage()
BUG=chromium-os:24461
TEST=New unit tests; autotests to come
Change-Id: If092d09c7cc1b3312bdbece8ee00a128cc3e427b
Reviewed-on: https://gerrit.chromium.org/gerrit/19334
Reviewed-by: Darin Petkov <petkov@chromium.org>
Commit-Ready: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/profile.cc b/profile.cc
index 0533a03..f3d7dd2 100644
--- a/profile.cc
+++ b/profile.cc
@@ -9,6 +9,7 @@
#include <vector>
#include <base/file_path.h>
+#include <base/file_util.h>
#include <base/logging.h>
#include <base/stl_util.h>
#include <base/string_util.h>
@@ -100,6 +101,29 @@
return true;
}
+bool Profile::RemoveStorage(GLib *glib, Error *error) {
+ FilePath path;
+
+ CHECK(!storage_.get());
+
+ if (!GetStoragePath(&path)) {
+ Error::PopulateAndLog(
+ error, Error::kInvalidArguments,
+ base::StringPrintf("Could get the storage path for %s:%s",
+ name_.user.c_str(), name_.identifier.c_str()));
+ return false;
+ }
+
+ if (!file_util::Delete(path, false)) {
+ Error::PopulateAndLog(
+ error, Error::kOperationFailed,
+ base::StringPrintf("Could not remove path %s", path.value().c_str()));
+ return false;
+ }
+
+ return true;
+}
+
string Profile::GetFriendlyName() {
return (name_.user.empty() ? "" : name_.user + "/") + name_.identifier;
}