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 #include <gflags/gflags.h> | 8 #include <gflags/gflags.h> |
9 #include <glib.h> | 9 #include <glib.h> |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 using std::string; | 23 using std::string; |
24 using std::tr1::shared_ptr; | 24 using std::tr1::shared_ptr; |
25 using std::vector; | 25 using std::vector; |
26 | 26 |
27 namespace chromeos_update_engine { | 27 namespace chromeos_update_engine { |
28 | 28 |
29 gboolean SetupInMainLoop(void* arg) { | 29 gboolean SetupInMainLoop(void* arg) { |
30 // TODO(adlr): Tell update_attempter to start working. | 30 // TODO(adlr): Tell update_attempter to start working. |
31 // Comment this in for that: | 31 // Comment this in for that: |
32 //UpdateAttempter* update_attempter = reinterpret_cast<UpdateAttempter*>(arg); | 32 UpdateAttempter* update_attempter = reinterpret_cast<UpdateAttempter*>(arg); |
| 33 LOG(INFO) << "Starting update!"; |
| 34 update_attempter->Update(false); |
33 | 35 |
34 return FALSE; // Don't call this callback function again | 36 return FALSE; // Don't call this callback function again |
35 } | 37 } |
36 | 38 |
37 void SetupDbusService(UpdateEngineService* service) { | 39 void SetupDbusService(UpdateEngineService* service) { |
38 DBusGConnection *bus; | 40 DBusGConnection *bus; |
39 DBusGProxy *proxy; | 41 DBusGProxy *proxy; |
40 GError *error = NULL; | 42 GError *error = NULL; |
41 | 43 |
42 bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error); | 44 bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error); |
43 if (!bus) { | 45 if (!bus) { |
44 LOG(FATAL) << "Failed to get bus"; | 46 LOG(FATAL) << "Failed to get bus"; |
45 } | 47 } |
46 proxy = dbus_g_proxy_new_for_name(bus, | 48 proxy = dbus_g_proxy_new_for_name(bus, |
47 DBUS_SERVICE_DBUS, | 49 DBUS_SERVICE_DBUS, |
48 DBUS_PATH_DBUS, | 50 DBUS_PATH_DBUS, |
49 DBUS_INTERFACE_DBUS); | 51 DBUS_INTERFACE_DBUS); |
50 | 52 |
51 guint32 request_name_ret; | 53 guint32 request_name_ret; |
52 if (!org_freedesktop_DBus_request_name(proxy, | 54 if (!org_freedesktop_DBus_request_name(proxy, |
53 kUpdateEngineServiceName, | 55 kUpdateEngineServiceName, |
54 0, | 56 0, |
55 &request_name_ret, | 57 &request_name_ret, |
56 &error)) { | 58 &error)) { |
57 LOG(FATAL) << "Failed to get name: " << error->message; | 59 LOG(FATAL) << "Failed to get name: " << error->message; |
58 } | 60 } |
59 if (request_name_ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { | 61 if (request_name_ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { |
60 g_warning("Got result code %u from requesting name", request_name_ret); | 62 g_warning("Got result code %u from requesting name", request_name_ret); |
61 g_error_free(error); | 63 g_error_free(error); |
62 exit(1); | |
63 LOG(FATAL) << "Got result code " << request_name_ret | 64 LOG(FATAL) << "Got result code " << request_name_ret |
64 << " from requesting name, but expected " | 65 << " from requesting name, but expected " |
65 << DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER; | 66 << DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER; |
66 } | 67 } |
67 dbus_g_connection_register_g_object(bus, | 68 dbus_g_connection_register_g_object(bus, |
68 "/org/chromium/UpdateEngine", | 69 "/org/chromium/UpdateEngine", |
69 G_OBJECT(service)); | 70 G_OBJECT(service)); |
70 } | 71 } |
71 | 72 |
72 } // namespace chromeos_update_engine | 73 } // namespace chromeos_update_engine |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 // Run the main loop until exit time: | 109 // Run the main loop until exit time: |
109 g_main_loop_run(loop); | 110 g_main_loop_run(loop); |
110 | 111 |
111 // Cleanup: | 112 // Cleanup: |
112 g_main_loop_unref(loop); | 113 g_main_loop_unref(loop); |
113 g_object_unref(G_OBJECT(service)); | 114 g_object_unref(G_OBJECT(service)); |
114 | 115 |
115 LOG(INFO) << "Chrome OS Update Engine terminating"; | 116 LOG(INFO) << "Chrome OS Update Engine terminating"; |
116 return 0; | 117 return 0; |
117 } | 118 } |
OLD | NEW |