| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string> | 5 #include <string> |
| 6 #include <tr1/memory> | 6 #include <tr1/memory> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include <gflags/gflags.h> | 9 #include <gflags/gflags.h> |
| 10 #include <glib.h> | 10 #include <glib.h> |
| 11 | 11 |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "chromeos/obsolete_logging.h" | 13 #include "chromeos/obsolete_logging.h" |
| 14 #include "metrics/metrics_library.h" | 14 #include "metrics/metrics_library.h" |
| 15 #include "update_engine/dbus_constants.h" | 15 #include "update_engine/dbus_constants.h" |
| 16 #include "update_engine/dbus_service.h" | 16 #include "update_engine/dbus_service.h" |
| 17 #include "update_engine/prefs.h" |
| 17 #include "update_engine/update_attempter.h" | 18 #include "update_engine/update_attempter.h" |
| 18 | 19 |
| 19 extern "C" { | 20 extern "C" { |
| 20 #include "update_engine/update_engine.dbusserver.h" | 21 #include "update_engine/update_engine.dbusserver.h" |
| 21 } | 22 } |
| 22 | 23 |
| 23 DEFINE_bool(logtostderr, false, | 24 DEFINE_bool(logtostderr, false, |
| 24 "Write logs to stderr instead of to a file in log_dir."); | 25 "Write logs to stderr instead of to a file in log_dir."); |
| 25 DEFINE_bool(foreground, false, | 26 DEFINE_bool(foreground, false, |
| 26 "Don't daemon()ize; run in foreground."); | 27 "Don't daemon()ize; run in foreground."); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 logging::DONT_LOCK_LOG_FILE, | 99 logging::DONT_LOCK_LOG_FILE, |
| 99 logging::APPEND_TO_OLD_LOG_FILE); | 100 logging::APPEND_TO_OLD_LOG_FILE); |
| 100 if (!FLAGS_foreground) | 101 if (!FLAGS_foreground) |
| 101 PLOG_IF(FATAL, daemon(0, 0) == 1) << "daemon() failed"; | 102 PLOG_IF(FATAL, daemon(0, 0) == 1) << "daemon() failed"; |
| 102 | 103 |
| 103 LOG(INFO) << "Chrome OS Update Engine starting"; | 104 LOG(INFO) << "Chrome OS Update Engine starting"; |
| 104 | 105 |
| 105 // Create the single GMainLoop | 106 // Create the single GMainLoop |
| 106 GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE); | 107 GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE); |
| 107 | 108 |
| 109 chromeos_update_engine::Prefs prefs; |
| 110 LOG_IF(ERROR, !prefs.Init(FilePath("/var/lib/update_engine/prefs"))) |
| 111 << "Failed to initialize preferences."; |
| 112 |
| 108 MetricsLibrary metrics_lib; | 113 MetricsLibrary metrics_lib; |
| 109 metrics_lib.Init(); | 114 metrics_lib.Init(); |
| 110 | 115 |
| 111 // Create the update attempter: | 116 // Create the update attempter: |
| 112 chromeos_update_engine::UpdateAttempter update_attempter(&metrics_lib); | 117 chromeos_update_engine::UpdateAttempter update_attempter(&prefs, |
| 118 &metrics_lib); |
| 113 | 119 |
| 114 // Create the dbus service object: | 120 // Create the dbus service object: |
| 115 dbus_g_object_type_install_info(UPDATE_ENGINE_TYPE_SERVICE, | 121 dbus_g_object_type_install_info(UPDATE_ENGINE_TYPE_SERVICE, |
| 116 &dbus_glib_update_engine_service_object_info); | 122 &dbus_glib_update_engine_service_object_info); |
| 117 UpdateEngineService* service = | 123 UpdateEngineService* service = |
| 118 UPDATE_ENGINE_SERVICE(g_object_new(UPDATE_ENGINE_TYPE_SERVICE, NULL)); | 124 UPDATE_ENGINE_SERVICE(g_object_new(UPDATE_ENGINE_TYPE_SERVICE, NULL)); |
| 119 service->update_attempter_ = &update_attempter; | 125 service->update_attempter_ = &update_attempter; |
| 120 update_attempter.set_dbus_service(service); | 126 update_attempter.set_dbus_service(service); |
| 121 chromeos_update_engine::SetupDbusService(service); | 127 chromeos_update_engine::SetupDbusService(service); |
| 122 | 128 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 138 g_main_loop_run(loop); | 144 g_main_loop_run(loop); |
| 139 | 145 |
| 140 // Cleanup: | 146 // Cleanup: |
| 141 g_main_loop_unref(loop); | 147 g_main_loop_unref(loop); |
| 142 update_attempter.set_dbus_service(NULL); | 148 update_attempter.set_dbus_service(NULL); |
| 143 g_object_unref(G_OBJECT(service)); | 149 g_object_unref(G_OBJECT(service)); |
| 144 | 150 |
| 145 LOG(INFO) << "Chrome OS Update Engine terminating"; | 151 LOG(INFO) << "Chrome OS Update Engine terminating"; |
| 146 return 0; | 152 return 0; |
| 147 } | 153 } |
| OLD | NEW |