shill: stop passing around format strings for profiles

Prior to this CL, shill passed around format strings, to specify
where the user profiles should be stored. While this makes things
more configurable, it also a) makes things more complex, and
b) causes g++ to emit warnings that some format strings can't be
checked statically.

The location of user profiles doesn't need the full power of
printf-format style configurability. We really only need the
ability to specify which directory the user profiles are
stored in.

Note that this changes requires updating some unit tests,
which actually did take advantage of the flexibility. In
particular, some of the Manager and Profile unit tests placed
user profiles directly in a user profile directory, rather
than creating a user-specific sub-directory first. Creating
the user-specific directories seems like the right thing to
do, since that it what the normal (non-test) code does.

BUG=chromium:293668
TEST=unit tests

Change-Id: Ic1afeec84a7797105c9a49b8261a9677e17d91ee
Reviewed-on: https://chromium-review.googlesource.com/197061
Tested-by: mukesh agrawal <quiche@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: mukesh agrawal <quiche@chromium.org>
diff --git a/manager_unittest.cc b/manager_unittest.cc
index 335be36..077f3e9 100644
--- a/manager_unittest.cc
+++ b/manager_unittest.cc
@@ -198,11 +198,14 @@
   }
 
   bool CreateBackingStoreForService(ScopedTempDir *temp_dir,
+                                    const string &user_identifier,
                                     const string &profile_identifier,
                                     const string &service_name) {
     GLib glib;
     KeyFileStore store(&glib);
-    store.set_path(temp_dir->path().Append(profile_identifier + ".profile"));
+    store.set_path(temp_dir->path().Append(
+        base::StringPrintf("%s/%s.profile", user_identifier.c_str(),
+                           profile_identifier.c_str())));
     return store.Open() &&
         store.SetString(service_name, "rather", "irrelevant") &&
         store.Close();
@@ -846,6 +849,7 @@
   {
     Error error;
     string path;
+    ASSERT_TRUE(base::CreateDirectory(temp_dir.path().Append("user")));
     manager.CreateProfile(kProfile, &path, &error);
     EXPECT_EQ(Error::kSuccess, error.type());
     EXPECT_EQ("/profile_rpc", path);
@@ -870,6 +874,9 @@
                   temp_dir.path().value());
   const char kProfile0[] = "~user/profile0";
   const char kPurgedMessage[] = "This message should be purged";
+
+  ASSERT_TRUE(base::CreateDirectory(temp_dir.path().Append("user")));
+
   // Create a profile and push it on the stack, leave one uncreated
   ASSERT_EQ(Error::kSuccess, TestCreateProfile(&manager, kProfile0));
   EXPECT_EQ(Error::kSuccess, TestPushProfile(&manager, kProfile0));
@@ -935,6 +942,7 @@
 
   const char kProfile0[] = "~user/profile0";
   const char kProfile1[] = "~user/profile1";
+  ASSERT_TRUE(base::CreateDirectory(temp_dir.path().Append("user")));
 
   // Create a couple of profiles.
   ASSERT_EQ(Error::kSuccess, TestCreateProfile(&manager, kProfile0));
@@ -975,7 +983,7 @@
   ASSERT_EQ(GetEphemeralProfile(&manager), service->profile());
 
   // Create storage for a profile that contains the service storage name.
-  ASSERT_TRUE(CreateBackingStoreForService(&temp_dir, kProfile2Id,
+  ASSERT_TRUE(CreateBackingStoreForService(&temp_dir, "user", kProfile2Id,
                                            kServiceName));
 
   // When we push the profile, the service should move away from the
@@ -988,7 +996,7 @@
   // Insert another profile that should supersede ownership of the service.
   const char kProfile3Id[] = "profile3";
   const string kProfile3 = base::StringPrintf("~user/%s", kProfile3Id);
-  ASSERT_TRUE(CreateBackingStoreForService(&temp_dir, kProfile3Id,
+  ASSERT_TRUE(CreateBackingStoreForService(&temp_dir, "user", kProfile3Id,
                                            kServiceName));
   EXPECT_EQ(Error::kSuccess, TestPushProfile(&manager, kProfile3));
   EXPECT_EQ(kProfile3, "~" + service->profile()->GetFriendlyName());
@@ -4070,6 +4078,7 @@
   const char kProfile1[] = "~user/profile1";
   string profile_rpc_path;
   Error error;
+  ASSERT_TRUE(base::CreateDirectory(temp_dir.path().Append("user")));
   manager.CreateProfile(kProfile0, &profile_rpc_path, &error);
   manager.PushProfile(kProfile0, &profile_rpc_path, &error);
   manager.CreateProfile(kProfile1, &profile_rpc_path, &error);
@@ -4173,6 +4182,7 @@
   const char kProfile0[] = "~user/profile0";
   const char kProfile1[] = "~user/profile1";
   const char kProfile2[] = "~user/profile2";
+  ASSERT_TRUE(base::CreateDirectory(temp_dir.path().Append("user")));
   TestCreateProfile(manager.get(), kProfile0);
   TestCreateProfile(manager.get(), kProfile1);
   TestCreateProfile(manager.get(), kProfile2);