Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include <stdio.h> |
| 6 | #include <glib.h> |
| 7 | |
| 8 | #include <algorithm> |
| 9 | #include <string> |
| 10 | #include <vector> |
| 11 | |
Chris Masone | ee929b7 | 2011-05-10 10:02:18 -0700 | [diff] [blame] | 12 | #include <base/logging.h> |
| 13 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 14 | #include "shill/shill_daemon.h" |
| 15 | #include "shill/control_interface.h" |
| 16 | #include "shill/dbus_control.h" |
| 17 | |
| 18 | using std::max; |
| 19 | using std::min; |
| 20 | using std::string; |
| 21 | using std::vector; |
| 22 | |
| 23 | namespace shill { |
| 24 | |
| 25 | static const char kTaggedFilePath[] = "/var/lib/shill"; |
| 26 | |
| 27 | // Daemon: Main for connection manager. Starts main process and holds event |
| 28 | // loop. |
| 29 | |
| 30 | Daemon::Daemon(Config *config, ControlInterface *control) |
| 31 | : config_(config), |
| 32 | control_(control), |
| 33 | manager_(control_, &dispatcher_) { } |
| 34 | Daemon::~Daemon() {} |
| 35 | |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 36 | void Daemon::Start() { |
| 37 | manager_.Start(); |
| 38 | } |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 39 | |
| 40 | void Daemon::Run() { |
| 41 | GMainLoop* loop = g_main_loop_new(NULL, false); |
Chris Masone | ee929b7 | 2011-05-10 10:02:18 -0700 | [diff] [blame] | 42 | // TODO(cmasone): change this to VLOG(1) once we have it. |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 43 | Start(); |
Chris Masone | ee929b7 | 2011-05-10 10:02:18 -0700 | [diff] [blame] | 44 | LOG(INFO) << "Running main loop."; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 45 | g_main_loop_run(loop); |
| 46 | } |
| 47 | |
| 48 | |
| 49 | } // namespace shill |