Segregate UMA metrics for production scenarios from test scenarios.

Currently we separate the UMA metrics only by one category: whether the
device is in dev mode or not. In addition, we need to exclude the noise
from these two categories:
1. Most of our testing on MP-signed images which are performed
with autest.
2. All our hwlab tests run in non-dev mode but they use dev-signed images
with dev-firmware keys.

So this CL defines additional bit fields to represent these states and
if any of these three flags are set, the UMA metric is sent to a
DevModeErrorCodes bucket. Thus the NormalErrorCodes bucket will have only
the production errors and thus we can monitor more effectively.

BUG=chromium-os:37613
TEST=Updated unit tests, ran on ZGB for all scenarios.
Change-Id: Id9cce33f09d1cc50cb15e67c731f7548940cbc24
Reviewed-on: https://gerrit.chromium.org/gerrit/41103
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Queue: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
diff --git a/system_state.h b/system_state.h
index 772205c..20e11a7 100644
--- a/system_state.h
+++ b/system_state.h
@@ -9,13 +9,17 @@
 #include <policy/device_policy.h>
 #include <policy/libpolicy.h>
 
-#include <update_engine/connection_manager.h>
-#include <update_engine/gpio_handler.h>
-#include <update_engine/payload_state.h>
-#include <update_engine/prefs.h>
-
 namespace chromeos_update_engine {
 
+// SystemState is the root class within the update engine. So we should avoid
+// any circular references in header file inclusion. Hence forward-declaring
+// the required classes.
+class ConnectionManager;
+class PrefsInterface;
+class PayloadStateInterface;
+class GpioHandler;
+class UpdateAttempter;
+
 // An interface to global system context, including platform resources,
 // the current state of the system, high-level objects whose lifetime is same
 // as main, system interfaces, etc.
@@ -50,78 +54,11 @@
 
   // Returns a pointer to the GPIO handler.
   virtual GpioHandler* gpio_handler() const = 0;
-};
 
-// A real implementation of the SystemStateInterface which is
-// used by the actual product code.
-class RealSystemState : public SystemState {
-public:
-  // Constructors and destructors.
-  RealSystemState();
-  virtual ~RealSystemState() {}
-
-  virtual bool IsOOBEComplete();
-
-  virtual inline void set_device_policy(
-      const policy::DevicePolicy* device_policy) {
-    device_policy_ = device_policy;
-  }
-
-  virtual inline const policy::DevicePolicy* device_policy() const {
-    return device_policy_;
-  }
-
-  virtual inline ConnectionManager* connection_manager() {
-    return &connection_manager_;
-  }
-
-  virtual inline MetricsLibraryInterface* metrics_lib() {
-    return &metrics_lib_;
-  }
-
-  virtual inline PrefsInterface* prefs() {
-    return &prefs_;
-  }
-
-  virtual inline PayloadStateInterface* payload_state() {
-    return &payload_state_;
-  }
-
-  // Returns a pointer to the GPIO handler.
-  virtual inline GpioHandler* gpio_handler() const {
-    return gpio_handler_.get();
-  }
-
-  // Initializs this concrete object. Other methods should be invoked only
-  // if the object has been initialized successfully.
-  bool Initialize(bool enable_gpio);
-
-private:
-  // The latest device policy object from the policy provider.
-  const policy::DevicePolicy* device_policy_;
-
-  // The connection manager object that makes download
-  // decisions depending on the current type of connection.
-  ConnectionManager connection_manager_;
-
-  // The Metrics Library interface for reporting UMA stats.
-  MetricsLibrary metrics_lib_;
-
-  // Interface for persisted store.
-  Prefs prefs_;
-
-  // All state pertaining to payload state such as
-  // response, URL, backoff states.
-  PayloadState payload_state_;
-
-  // Pointer to a GPIO handler and other needed modules (note that the order of
-  // declaration significant for destruction, as the latter depends on the
-  // former).
-  scoped_ptr<UdevInterface> udev_iface_;
-  scoped_ptr<FileDescriptor> file_descriptor_;
-  scoped_ptr<GpioHandler> gpio_handler_;
+  // Returns a pointer to the update attempter object.
+  virtual UpdateAttempter* update_attempter() = 0;
 };
 
 }  // namespace chromeos_update_engine
 
-#endif  // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H_
+#endif  // CHROMEOS_PLATFORM_UPDATE_ENGINE_SYSTEM_STATE_H_