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/main.cc b/main.cc
index c956278..cd51995 100644
--- a/main.cc
+++ b/main.cc
@@ -21,11 +21,11 @@
 #include "update_engine/dbus_constants.h"
 #include "update_engine/dbus_interface.h"
 #include "update_engine/dbus_service.h"
+#include "update_engine/real_system_state.h"
 #include "update_engine/subprocess.h"
 #include "update_engine/terminator.h"
 #include "update_engine/update_attempter.h"
 #include "update_engine/update_check_scheduler.h"
-#include "update_engine/system_state.h"
 #include "update_engine/utils.h"
 
 extern "C" {
@@ -171,6 +171,9 @@
   // protocol for testing of MP-signed images (chromium-os:25400).
   LOG_IF(ERROR, !real_system_state.Initialize(false))
       << "Failed to initialize system state.";
+  chromeos_update_engine::UpdateAttempter *update_attempter =
+      real_system_state.update_attempter();
+  CHECK(update_attempter);
 
   // Sets static members for the certificate checker.
   chromeos_update_engine::CertificateChecker::set_system_state(
@@ -179,40 +182,35 @@
   chromeos_update_engine::CertificateChecker::set_openssl_wrapper(
       &openssl_wrapper);
 
-  // Create the update attempter:
-  chromeos_update_engine::ConcreteDbusGlib dbus;
-  chromeos_update_engine::UpdateAttempter update_attempter(&real_system_state,
-                                                           &dbus);
-
   // Create the dbus service object:
   dbus_g_object_type_install_info(UPDATE_ENGINE_TYPE_SERVICE,
                                   &dbus_glib_update_engine_service_object_info);
   UpdateEngineService* service =
       UPDATE_ENGINE_SERVICE(g_object_new(UPDATE_ENGINE_TYPE_SERVICE, NULL));
-  service->update_attempter_ = &update_attempter;
-  update_attempter.set_dbus_service(service);
+  service->update_attempter_ = update_attempter;
+  update_attempter->set_dbus_service(service);
   chromeos_update_engine::SetupDbusService(service);
 
   // Schedule periodic update checks.
-  chromeos_update_engine::UpdateCheckScheduler scheduler(&update_attempter,
+  chromeos_update_engine::UpdateCheckScheduler scheduler(update_attempter,
                                                          &real_system_state);
   scheduler.Run();
 
   // Update boot flags after 45 seconds.
   g_timeout_add_seconds(45,
                         &chromeos_update_engine::UpdateBootFlags,
-                        &update_attempter);
+                        update_attempter);
 
   // Broadcast the update engine status on startup to ensure consistent system
   // state on crashes.
-  g_idle_add(&chromeos_update_engine::BroadcastStatus, &update_attempter);
+  g_idle_add(&chromeos_update_engine::BroadcastStatus, update_attempter);
 
   // Run the main loop until exit time:
   g_main_loop_run(loop);
 
   // Cleanup:
   g_main_loop_unref(loop);
-  update_attempter.set_dbus_service(NULL);
+  update_attempter->set_dbus_service(NULL);
   g_object_unref(G_OBJECT(service));
 
   LOG(INFO) << "Chrome OS Update Engine terminating";