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/update_attempter.cc b/update_attempter.cc
index be76a8e..891cc96 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -120,47 +120,15 @@
 
 UpdateAttempter::UpdateAttempter(SystemState* system_state,
                                  DBusWrapperInterface* dbus_iface)
-    : chrome_proxy_resolver_(dbus_iface) {
-  Init(system_state, kUpdateCompletedMarker);
-}
+    : UpdateAttempter(system_state, dbus_iface, kUpdateCompletedMarker) {}
 
 UpdateAttempter::UpdateAttempter(SystemState* system_state,
                                  DBusWrapperInterface* dbus_iface,
                                  const std::string& update_completed_marker)
-    : chrome_proxy_resolver_(dbus_iface) {
-  Init(system_state, update_completed_marker);
-}
-
-
-void UpdateAttempter::Init(SystemState* system_state,
-                           const std::string& update_completed_marker) {
-  // Initialite data members.
-  processor_.reset(new ActionProcessor());
-  system_state_ = system_state;
-  dbus_service_ = NULL;
-  update_check_scheduler_ = NULL;
-  fake_update_success_ = false;
-  http_response_code_ = 0;
-  shares_ = utils::kCpuSharesNormal;
-  manage_shares_source_ = NULL;
-  download_active_ = false;
-  download_progress_ = 0.0;
-  last_checked_time_ = 0;
-  new_version_ = "0.0.0.0";
-  new_payload_size_ = 0;
-  proxy_manual_checks_ = 0;
-  obeying_proxies_ = true;
-  updated_boot_flags_ = false;
-  update_boot_flags_running_ = false;
-  start_action_processor_ = false;
-  is_using_test_url_ = false;
-  is_test_mode_ = false;
-  is_test_update_attempted_ = false;
-  update_completed_marker_ = update_completed_marker;
-
-  prefs_ = system_state->prefs();
-  omaha_request_params_ = system_state->request_params();
-
+    : processor_(new ActionProcessor()),
+      system_state_(system_state),
+      chrome_proxy_resolver_(dbus_iface),
+      update_completed_marker_(update_completed_marker) {
   if (!update_completed_marker_.empty() &&
       utils::FileExists(update_completed_marker_.c_str()))
     status_ = UPDATE_STATUS_UPDATED_NEED_REBOOT;
@@ -168,6 +136,14 @@
     status_ = UPDATE_STATUS_IDLE;
 }
 
+void UpdateAttempter::Init() {
+  // Pulling from the SystemState can only be done after construction, since
+  // this is an aggregate of various objects (such as the UpdateAttempter),
+  // which requires them all to be constructed prior to it being used.
+  prefs_ = system_state_->prefs();
+  omaha_request_params_ = system_state_->request_params();
+}
+
 UpdateAttempter::~UpdateAttempter() {
   CleanupCpuSharesManagement();
 }