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

Side by Side Diff: src/service.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/service.h" 5 #include "src/service.h"
6 6
7 #include <glog/logging.h> 7 #include <glog/logging.h>
8 8
9 #include "src/data_plan_provider.h" 9 #include "src/data_plan_provider.h"
10 #include "src/device.h" 10 #include "src/device.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 retrying_get_properties_(false), 85 retrying_get_properties_(false),
86 connectivity_state_(kConnectivityStateUnknown) { 86 connectivity_state_(kConnectivityStateUnknown) {
87 // schedule a GetProperties() call to our Flimflam service path to init state 87 // schedule a GetProperties() call to our Flimflam service path to init state
88 // we'll keep trying periodically until we succeed 88 // we'll keep trying periodically until we succeed
89 // we'll subsequently update this state by monitoring PropertyChanged signals 89 // we'll subsequently update this state by monitoring PropertyChanged signals
90 get_properties_source_id_ = 90 get_properties_source_id_ =
91 g_idle_add(StaticGetServicePropertiesCallback, this); 91 g_idle_add(StaticGetServicePropertiesCallback, this);
92 if (get_properties_source_id_ == 0) { 92 if (get_properties_source_id_ == 0) {
93 LOG(ERROR) << path_ << ": ctor: g_idle_add failed"; 93 LOG(ERROR) << path_ << ": ctor: g_idle_add failed";
94 } 94 }
95 property_changed_handler_.delegate(this);
95 } 96 }
96 97
97 Service::~Service() { 98 Service::~Service() {
98 DeleteCarrierState(); 99 DeleteCarrierState();
99 DeleteDataPlans(&data_plans_); 100 DeleteDataPlans(&data_plans_);
100 if (device_ != NULL) { 101 if (device_ != NULL) {
101 DLOG(INFO) << path_ << ": deleting device " << device_->GetPath(); 102 DLOG(INFO) << path_ << ": deleting device " << device_->GetPath();
102 delete device_; 103 delete device_;
103 device_ = NULL; 104 device_ = NULL;
104 } 105 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 176
176 Service::ConnectivityState Service::GetConnectivityState() const { 177 Service::ConnectivityState Service::GetConnectivityState() const {
177 return connectivity_state_; 178 return connectivity_state_;
178 } 179 }
179 180
180 // Flimflam Service D-Bus Proxy methods 181 // Flimflam Service D-Bus Proxy methods
181 182
182 void Service::PropertyChanged(const std::string& property_name, 183 void Service::PropertyChanged(const std::string& property_name,
183 const DBus::Variant& new_value) { 184 const DBus::Variant& new_value) {
184 DLOG(INFO) << path_ << ": PropertyChanged: property_name = " << property_name; 185 DLOG(INFO) << path_ << ": PropertyChanged: property_name = " << property_name;
186 // Queue a tuple representing this signal for later processing from the glib
187 // main loop. We do this to avoid libdbus-c++ deadlocks that can occur when
188 // sending a dbus message from within a dbus callback like this one.
189 PropertyChangedSignal signal(property_name, new_value);
190 property_changed_handler_.EnqueueSignal(signal);
191 }
192
193 // PropertyChangedDelegate methods
194
195 void Service::OnPropertyChanged(const PropertyChangedHandler *handler,
196 const std::string& property_name,
197 const DBus::Variant& new_value) {
198 DCHECK(handler == &property_changed_handler_);
199 DLOG(INFO) << path_ << ": OnPropertyChanged: property_name = "
200 << property_name;
185 if (property_name == kFlimflamServiceDeviceProperty) { 201 if (property_name == kFlimflamServiceDeviceProperty) {
186 OnDeviceUpdate(new_value.reader().get_path()); 202 OnDeviceUpdate(new_value.reader().get_path());
187 } else if (property_name == kFlimflamServiceStateProperty) { 203 } else if (property_name == kFlimflamServiceStateProperty) {
188 OnStateUpdate(new_value.reader().get_string()); 204 OnStateUpdate(new_value.reader().get_string());
189 } else if (property_name == kFlimflamServiceTypeProperty) { 205 } else if (property_name == kFlimflamServiceTypeProperty) {
190 OnTypeUpdate(new_value.reader().get_string()); 206 OnTypeUpdate(new_value.reader().get_string());
191 } else if (property_name == kFlimflamServiceUsageUrlProperty) { 207 } else if (property_name == kFlimflamServiceUsageUrlProperty) {
192 OnUsageUrlUpdate(new_value.reader().get_string()); 208 OnUsageUrlUpdate(new_value.reader().get_string());
193 } else if (property_name == kFlimflamServiceConnectivityStateProperty) { 209 } else if (property_name == kFlimflamServiceConnectivityStateProperty) {
194 OnConnectivityStateUpdate(new_value.reader().get_string()); 210 OnConnectivityStateUpdate(new_value.reader().get_string());
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 DCHECK(policy_ != NULL); 931 DCHECK(policy_ != NULL);
916 if (policy_->ShouldEmitDataPlansUpdate(data_plans_)) { 932 if (policy_->ShouldEmitDataPlansUpdate(data_plans_)) {
917 DLOG(INFO) << path_ << ": MaybeEmitDataPlansUpdate: sending update"; 933 DLOG(INFO) << path_ << ": MaybeEmitDataPlansUpdate: sending update";
918 parent_->EmitDataPlansUpdate(*this); 934 parent_->EmitDataPlansUpdate(*this);
919 } else { 935 } else {
920 DLOG(INFO) << path_ << ": MaybeEmitDataPlansUpdate: not sending update"; 936 DLOG(INFO) << path_ << ": MaybeEmitDataPlansUpdate: not sending update";
921 } 937 }
922 } 938 }
923 939
924 } // namespace cashew 940 } // namespace cashew
OLDNEW
« src/property_changed_handler.cc ('K') | « src/service.h ('k') | src/service_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698