| 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 "src/cashew_server.h" | 5 #include "src/cashew_server.h" |
| 6 | 6 |
| 7 #include <glog/logging.h> | 7 #include <glog/logging.h> |
| 8 | 8 |
| 9 #include "src/service_manager.h" | 9 #include "src/service_manager.h" |
| 10 | 10 |
| 11 namespace cashew { | 11 namespace cashew { |
| 12 | 12 |
| 13 const char* CashewServer::kServiceName = "org.chromium.Cashew"; | 13 const char* CashewServer::kServiceName = "org.chromium.Cashew"; |
| 14 const char* CashewServer::kServicePath = "/org/chromium/Cashew"; | 14 const char* CashewServer::kServicePath = "/org/chromium/Cashew"; |
| 15 | 15 |
| 16 // Cashew D-Bus errors | 16 // Cashew D-Bus errors |
| 17 const char* kCashewErrorServiceUnknown = | 17 const char* kCashewErrorServiceUnknown = |
| 18 "org.chromium.Cashew.Error.ServiceUnknown"; | 18 "org.chromium.Cashew.Error.ServiceUnknown"; |
| 19 | 19 |
| 20 CashewServer::CashewServer(DBus::Connection& connection, // NOLINT | 20 CashewServer::CashewServer(DBus::Connection& connection, // NOLINT |
| 21 ServiceManager * const service_manager, | 21 ServiceManager * const service_manager) |
| 22 GMainLoop * const main_loop) | |
| 23 : DBus::ObjectAdaptor(connection, kServicePath), | 22 : DBus::ObjectAdaptor(connection, kServicePath), |
| 24 service_manager_(CHECK_NOTNULL(service_manager)), | 23 service_manager_(CHECK_NOTNULL(service_manager)) { |
| 25 main_loop_(CHECK_NOTNULL(main_loop)) { | |
| 26 service_manager_->SetCashewServer(this); | 24 service_manager_->SetCashewServer(this); |
| 27 } | 25 } |
| 28 | 26 |
| 29 CashewServer::~CashewServer() { | 27 CashewServer::~CashewServer() { |
| 30 DCHECK(!g_main_loop_is_running(main_loop_)); | |
| 31 service_manager_->SetCashewServer(NULL); | 28 service_manager_->SetCashewServer(NULL); |
| 32 } | 29 } |
| 33 | 30 |
| 34 // Cashew D-Bus API methods | 31 // Cashew D-Bus API methods |
| 35 | 32 |
| 36 DBusDataPlanList CashewServer::GetDataPlans(const std::string& service_path, | 33 DBusDataPlanList CashewServer::GetDataPlans(const std::string& service_path, |
| 37 DBus::Error& error) { // NOLINT | 34 DBus::Error& error) { // NOLINT |
| 38 DLOG(INFO) << "GetDataPlans: service = " << service_path; | 35 DLOG(INFO) << "GetDataPlans: service = " << service_path; |
| 39 DBusDataPlanList dbus_data_plans; | 36 DBusDataPlanList dbus_data_plans; |
| 40 const Service *service = service_manager_->GetService(service_path); | 37 const Service *service = service_manager_->GetService(service_path); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 78 |
| 82 void CashewServer::EmitDataPlansUpdateSignal(const Service& service) { | 79 void CashewServer::EmitDataPlansUpdateSignal(const Service& service) { |
| 83 DLOG(INFO) << "EmitDataPlansUpdateSignal: service = " << service.GetPath(); | 80 DLOG(INFO) << "EmitDataPlansUpdateSignal: service = " << service.GetPath(); |
| 84 DBusDataPlanList dbus_data_plans = service.GetDBusDataPlans(); | 81 DBusDataPlanList dbus_data_plans = service.GetDBusDataPlans(); |
| 85 | 82 |
| 86 // send out the signal | 83 // send out the signal |
| 87 DataPlansUpdate(service.GetPath(), dbus_data_plans); | 84 DataPlansUpdate(service.GetPath(), dbus_data_plans); |
| 88 } | 85 } |
| 89 | 86 |
| 90 } // namespace cashew | 87 } // namespace cashew |
| OLD | NEW |