Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 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" |
Paul Stewart | a3c56f9 | 2011-05-26 07:08:52 -0700 | [diff] [blame] | 17 | #include "shill/rtnl_handler.h" |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 18 | |
| 19 | using std::max; |
| 20 | using std::min; |
| 21 | using std::string; |
| 22 | using std::vector; |
| 23 | |
| 24 | namespace shill { |
| 25 | |
| 26 | static const char kTaggedFilePath[] = "/var/lib/shill"; |
| 27 | |
| 28 | // Daemon: Main for connection manager. Starts main process and holds event |
| 29 | // loop. |
| 30 | |
Darin Petkov | 887f298 | 2011-07-14 16:10:17 -0700 | [diff] [blame] | 31 | Daemon::Daemon(Config *config, ControlInterface *control, GLib *glib) |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 32 | : config_(config), |
| 33 | control_(control), |
Darin Petkov | 887f298 | 2011-07-14 16:10:17 -0700 | [diff] [blame] | 34 | manager_(control_, &dispatcher_, glib) { } |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 35 | Daemon::~Daemon() {} |
| 36 | |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 37 | void Daemon::Start() { |
Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 38 | RTNLHandler::GetInstance()->Start(&dispatcher_, &sockets_); |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 39 | manager_.Start(); |
| 40 | } |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 41 | |
| 42 | void Daemon::Run() { |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 43 | Start(); |
Chris Masone | b07006b | 2011-05-14 16:10:04 -0700 | [diff] [blame] | 44 | VLOG(1) << "Running main loop."; |
Chris Masone | c5b392e | 2011-05-14 16:31:01 -0700 | [diff] [blame] | 45 | dispatcher_.DispatchForever(); |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | |
| 49 | } // namespace shill |