Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/cashew_server.cc

Issue 5380002: cashew: defer all D-Bus signal processing to main loop (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cashew.git@master
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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)
22 : DBus::ObjectAdaptor(connection, kServicePath), 23 : DBus::ObjectAdaptor(connection, kServicePath),
23 service_manager_(CHECK_NOTNULL(service_manager)) { 24 service_manager_(CHECK_NOTNULL(service_manager)),
25 main_loop_(CHECK_NOTNULL(main_loop)) {
24 service_manager_->SetCashewServer(this); 26 service_manager_->SetCashewServer(this);
25 } 27 }
26 28
27 CashewServer::~CashewServer() { 29 CashewServer::~CashewServer() {
30 DCHECK(!g_main_loop_is_running(main_loop_));
28 service_manager_->SetCashewServer(NULL); 31 service_manager_->SetCashewServer(NULL);
29 } 32 }
30 33
31 // Cashew D-Bus API methods 34 // Cashew D-Bus API methods
32 35
33 DBusDataPlanList CashewServer::GetDataPlans(const std::string& service_path, 36 DBusDataPlanList CashewServer::GetDataPlans(const std::string& service_path,
34 DBus::Error& error) { // NOLINT 37 DBus::Error& error) { // NOLINT
35 DLOG(INFO) << "GetDataPlans: service = " << service_path; 38 DLOG(INFO) << "GetDataPlans: service = " << service_path;
36 DBusDataPlanList dbus_data_plans; 39 DBusDataPlanList dbus_data_plans;
37 const Service *service = service_manager_->GetService(service_path); 40 const Service *service = service_manager_->GetService(service_path);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 81
79 void CashewServer::EmitDataPlansUpdateSignal(const Service& service) { 82 void CashewServer::EmitDataPlansUpdateSignal(const Service& service) {
80 DLOG(INFO) << "EmitDataPlansUpdateSignal: service = " << service.GetPath(); 83 DLOG(INFO) << "EmitDataPlansUpdateSignal: service = " << service.GetPath();
81 DBusDataPlanList dbus_data_plans = service.GetDBusDataPlans(); 84 DBusDataPlanList dbus_data_plans = service.GetDBusDataPlans();
82 85
83 // send out the signal 86 // send out the signal
84 DataPlansUpdate(service.GetPath(), dbus_data_plans); 87 DataPlansUpdate(service.GetPath(), dbus_data_plans);
85 } 88 }
86 89
87 } // namespace cashew 90 } // namespace cashew
OLDNEW
« no previous file with comments | « src/cashew_server.h ('k') | src/device.h » ('j') | src/property_changed_handler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698