| 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/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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 Device* Service::GetDevice() const { | 143 Device* Service::GetDevice() const { |
| 144 return device_; | 144 return device_; |
| 145 } | 145 } |
| 146 | 146 |
| 147 DBusDataPlanList Service::GetDBusDataPlans() const { | 147 DBusDataPlanList Service::GetDBusDataPlans() const { |
| 148 DBusDataPlanList dbus_data_plans; | 148 DBusDataPlanList dbus_data_plans; |
| 149 DataPlanList::const_iterator it; | 149 DataPlanList::const_iterator it; |
| 150 for (it = data_plans_.begin(); it != data_plans_.end(); ++it) { | 150 for (it = data_plans_.begin(); it != data_plans_.end(); ++it) { |
| 151 DataPlan *plan = *it; | 151 DataPlan *plan = *it; |
| 152 DCHECK(plan != NULL); | 152 DCHECK(plan != NULL); |
| 153 dbus_data_plans.push_back(plan->ToDBusFormat()); | 153 // filter out inactive plans |
| 154 if (plan->IsActive()) { |
| 155 dbus_data_plans.push_back(plan->ToDBusFormat()); |
| 156 } else { |
| 157 DLOG(INFO) << path_ << ": GetBusDataPlans: skipping inactive plan: \"" |
| 158 << plan->GetName() << "\""; |
| 159 } |
| 154 } | 160 } |
| 155 return dbus_data_plans; | 161 return dbus_data_plans; |
| 156 } | 162 } |
| 157 | 163 |
| 158 bool Service::IsDefaultService() const { | 164 bool Service::IsDefaultService() const { |
| 159 if (is_default_service_) { | 165 if (is_default_service_) { |
| 160 // cross-check with parent's idea of default technology | 166 // cross-check with parent's idea of default technology |
| 161 if (parent_->GetDefaultTechnology() != kTypeCellular) { | 167 if (parent_->GetDefaultTechnology() != kTypeCellular) { |
| 162 DLOG(WARNING) << path_ << ": IsDefaultService: " | 168 DLOG(WARNING) << path_ << ": IsDefaultService: " |
| 163 << "service manager doesn't think default technology is cellular"; | 169 << "service manager doesn't think default technology is cellular"; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 // a negative number when assigned to |local_bytes_used| | 261 // a negative number when assigned to |local_bytes_used| |
| 256 if (local_bytes_used < 0 || | 262 if (local_bytes_used < 0 || |
| 257 static_cast<uint64>(local_bytes_used) < rx_bytes || | 263 static_cast<uint64>(local_bytes_used) < rx_bytes || |
| 258 static_cast<uint64>(local_bytes_used) < tx_bytes) { | 264 static_cast<uint64>(local_bytes_used) < tx_bytes) { |
| 259 LOG(WARNING) << path_ << ": OnByteCounterUpdate: overflow detected"; | 265 LOG(WARNING) << path_ << ": OnByteCounterUpdate: overflow detected"; |
| 260 return; | 266 return; |
| 261 } | 267 } |
| 262 active_plan->SetLocalBytesUsed(local_bytes_used); | 268 active_plan->SetLocalBytesUsed(local_bytes_used); |
| 263 DLOG(INFO) << path_ | 269 DLOG(INFO) << path_ |
| 264 << ": OnByteCounterUpdate: updated plan state: data bytes used = " | 270 << ": OnByteCounterUpdate: updated plan state: data bytes used = " |
| 265 << active_plan->GetDataBytesUsed() << ", local byes used = " | 271 << active_plan->GetDataBytesUsed() << ", local bytes used = " |
| 266 << active_plan->GetLocalBytesUsed(); | 272 << active_plan->GetLocalBytesUsed() << ", total bytes used = " |
| 273 << active_plan->GetTotalBytesUsed(); |
| 267 MaybeEmitDataPlansUpdate(); | 274 MaybeEmitDataPlansUpdate(); |
| 268 } | 275 } |
| 269 | 276 |
| 270 // DataPlanProviderDelegate methods | 277 // DataPlanProviderDelegate methods |
| 271 | 278 |
| 272 void Service::OnRequestComplete(const DataPlanProvider *provider, | 279 void Service::OnRequestComplete(const DataPlanProvider *provider, |
| 273 bool successful, | 280 bool successful, |
| 274 const Value *parsed_usage_update) { | 281 const Value *parsed_usage_update) { |
| 275 DCHECK(provider != NULL); | 282 DCHECK(provider != NULL); |
| 276 DCHECK(!successful || parsed_usage_update != NULL); | 283 DCHECK(!successful || parsed_usage_update != NULL); |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 DCHECK(policy_ != NULL); | 915 DCHECK(policy_ != NULL); |
| 909 if (policy_->ShouldEmitDataPlansUpdate(data_plans_)) { | 916 if (policy_->ShouldEmitDataPlansUpdate(data_plans_)) { |
| 910 DLOG(INFO) << path_ << ": MaybeEmitDataPlansUpdate: sending update"; | 917 DLOG(INFO) << path_ << ": MaybeEmitDataPlansUpdate: sending update"; |
| 911 parent_->EmitDataPlansUpdate(*this); | 918 parent_->EmitDataPlansUpdate(*this); |
| 912 } else { | 919 } else { |
| 913 DLOG(INFO) << path_ << ": MaybeEmitDataPlansUpdate: not sending update"; | 920 DLOG(INFO) << path_ << ": MaybeEmitDataPlansUpdate: not sending update"; |
| 914 } | 921 } |
| 915 } | 922 } |
| 916 | 923 |
| 917 } // namespace cashew | 924 } // namespace cashew |
| OLD | NEW |