Revise the SystemState hierarchy.

* Removed all #includes from SystemState; added includes in .cc files
  that use the various objects (MetricsLibrary, DevicePolicy, etc).

* MockSystemState:

  - Regulated the set of getters/setters: foo() returns the current Foo
    object interface; this object can be overridden by set_foo();
    mock_foo() or fake_foo() returns the default (internal) mock/fake
    equivalent, and fails if it is different from foo() (safety).

  - Make member declaration order consistent with that of API.

  - Removed MOCK_METHOD declarations for two methods and replaced them
    with fake getter/setter. This means that MockSystemState is now
    reduced to a fake, and can be renamed (separate CL). This also means
    that a few tests have a slightly different semantics now.

* All virtual overrides are qualified as such. However, removed the
  'const' method qualified from all getters: it made little sense,
  especially when considering that getters are handing addresses of
  internal mock members.

* Made the UpdateAttempter a contained member of both
  {Real,Mock}SystemState, resolving initialization dependencies. In
  general, the invariant is that all members of the SystemState that
  rely on it being fully populated by the time of their initialization,
  need to export a separate Init() method, that will be called (by the
  SystemState implementation constructor or Init() method) only after
  all members are set.

* Made the mock GPIO handler and connection manager contained members of
  MockSystemState; the destructor could safely be moved.

* Cleanup in UpdateAttempter (part of resolving dependencies):

  - Ordinary member initialization done via default initializers
    (constants) or initializer list in the constructor (parameters).

  - Init() method only does work that cannot be done during
    construction, with appropriate comment documenting the need for it.

  - Better reuse via constructor delegation.

BUG=chromium:358278
TEST=Unit tests.

Change-Id: I96ff6fc7e7400b0a9feb6cc8d4ffe97a51000f91
Reviewed-on: https://chromium-review.googlesource.com/193587
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc
index b73209c..ea0b4c2 100644
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -2243,7 +2243,7 @@
   // If there is no prefs and OOBE is not complete, we should not
   // report anything to Omaha.
   {
-    NiceMock<MockSystemState> system_state;
+    MockSystemState system_state;
     system_state.set_prefs(&prefs);
     EXPECT_EQ(OmahaRequestAction::GetInstallDate(&system_state), -1);
     EXPECT_FALSE(prefs.Exists(kPrefsInstallDateDays));
@@ -2254,11 +2254,11 @@
   // prefs. However, first try with an invalid date and check we do
   // nothing.
   {
-    NiceMock<MockSystemState> mock_system_state;
+    MockSystemState mock_system_state;
     mock_system_state.set_prefs(&prefs);
 
     Time oobe_date = Time::FromTimeT(42); // Dec 31, 1969 16:00:42 PST.
-    mock_system_state.get_fake_hardware()->SetIsOOBEComplete(oobe_date);
+    mock_system_state.fake_hardware()->SetIsOOBEComplete(oobe_date);
     EXPECT_EQ(OmahaRequestAction::GetInstallDate(&mock_system_state), -1);
     EXPECT_FALSE(prefs.Exists(kPrefsInstallDateDays));
   }
@@ -2266,11 +2266,11 @@
   // Then check with a valid date. The date Jan 20, 2007 0:00 PST
   // should yield an InstallDate of 14.
   {
-    NiceMock<MockSystemState> mock_system_state;
+    MockSystemState mock_system_state;
     mock_system_state.set_prefs(&prefs);
 
     Time oobe_date = Time::FromTimeT(1169280000); // Jan 20, 2007 0:00 PST.
-    mock_system_state.get_fake_hardware()->SetIsOOBEComplete(oobe_date);
+    mock_system_state.fake_hardware()->SetIsOOBEComplete(oobe_date);
     EXPECT_EQ(OmahaRequestAction::GetInstallDate(&mock_system_state), 14);
     EXPECT_TRUE(prefs.Exists(kPrefsInstallDateDays));
 
@@ -2284,11 +2284,11 @@
   // 2007 0:00 PST should yield an InstallDate of 28... but since
   // there's a prefs file, we should still get 14.
   {
-    NiceMock<MockSystemState> mock_system_state;
+    MockSystemState mock_system_state;
     mock_system_state.set_prefs(&prefs);
 
     Time oobe_date = Time::FromTimeT(1170144000); // Jan 30, 2007 0:00 PST.
-    mock_system_state.get_fake_hardware()->SetIsOOBEComplete(oobe_date);
+    mock_system_state.fake_hardware()->SetIsOOBEComplete(oobe_date);
     EXPECT_EQ(OmahaRequestAction::GetInstallDate(&mock_system_state), 14);
 
     int64_t prefs_days;