shill: improve out-of-disk handlng

At present, shill deals poorly with the case where no default profile
exists, and no default profile can be created. In particular, it aborts
in this case. Consequently if the disk is full, and no default profile
is present, shill gets in to a crash loop.

Remedy this by adding a StubStorage class, and using this to back
the DefaultProfile, if we can't back the DefaultProfile with a file
on disk.

One of the alternatives considered was to back the DefaultProfile
using a file in /tmp. This approach seems simpler, in that we don't
need to worry about securing the file in /tmp, or about the
possibility that /tmp is also full.

While there:
- Add DISALLOW_COPY_AND_ASSIGN to the Manager class.
- Make Manager::LoadProperties and Profile::LoadManagerProperties
  return void instead of bool. Previously, Profile::LoadManagerProperties
  would always return true. That would cause Manager::LoadProperties
  to always return true. Seems simpler to return void.
- Fix a grammar nit in profile.cc.
- Fix a typo in profile.h.

BUG=chromium:355140
TEST=network_DiskFull, unit tests

Note that the network_DiskFull may report failures due to
metrics_daemon not running. However, the test should not show
any errors related to shill or flimflam.

Change-Id: Ic081a40d7680ce035ead1459a08bf63e7989f0d6
Reviewed-on: https://chromium-review.googlesource.com/193693
Tested-by: mukesh agrawal <quiche@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: mukesh agrawal <quiche@chromium.org>
diff --git a/profile.cc b/profile.cc
index b28fbb3..911be12 100644
--- a/profile.cc
+++ b/profile.cc
@@ -24,6 +24,7 @@
 #include "shill/property_accessor.h"
 #include "shill/service.h"
 #include "shill/store_interface.h"
+#include "shill/stub_storage.h"
 
 using base::FilePath;
 using std::set;
@@ -94,7 +95,7 @@
         base::StringPrintf("Could not open profile storage for %s:%s",
                            name_.user.c_str(), name_.identifier.c_str()));
     if (already_exists) {
-      // The profile contents is corrupt, or we do not have access to
+      // The profile contents are corrupt, or we do not have access to
       // this file.  Move this file out of the way so a future open attempt
       // will succeed, assuming the failure reason was the former.
       storage->MarkAsCorrupted();
@@ -115,6 +116,10 @@
   return true;
 }
 
+void Profile::InitStubStorage() {
+  set_storage(new StubStorage());
+}
+
 bool Profile::RemoveStorage(GLib *glib, Error *error) {
   FilePath path;