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

Unified Diff: src/service_impl.cc

Issue 6250171: cashew: reset local counter on plan transition (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cashew.git@master
Patch Set: Created 9 years, 11 months 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 side-by-side diff with in-line comments
Download patch
Index: src/service_impl.cc
diff --git a/src/service_impl.cc b/src/service_impl.cc
index da04095e89661261ce3614a743d11a41e02bf610..1189f9317b8ac165b35e5dfa4440ab7132129f1f 100644
--- a/src/service_impl.cc
+++ b/src/service_impl.cc
@@ -259,35 +259,14 @@ void ServiceImpl::OnCarrierUpdate(const std::string& carrier) {
}
void ServiceImpl::OnByteCounterUpdate(uint64 rx_bytes, uint64 tx_bytes) {
- DCHECK(device_ != NULL);
- DCHECK(device_->ByteCounterRunning());
DLOG(INFO) << path_ << ": OnByteCounterUpdate: rx_bytes = " << rx_bytes
<< ", tx_bytes = " << tx_bytes;
- DataPlan *active_plan = DataPlan::GetActivePlan(data_plans_);
- if (active_plan == NULL) {
- DLOG(WARNING) << path_ << ": OnByteCounterUpdate: no active plan";
- return;
+ // dispatch this notification to our data plans list and consider sending
+ // out a signal if any plans were updated
+ if (DataPlan::OnByteCounterUpdate(&data_plans_, this, parent_, device_,
+ rx_bytes, tx_bytes)) {
+ MaybeEmitDataPlansUpdate();
}
- Bytes local_bytes_used = rx_bytes + tx_bytes;
- DLOG(INFO) << path_ << ": OnByteCounterUpdate: local_bytes_used = "
- << local_bytes_used;
- // try to detect two error conditions:
- // (1) overflow of the unsigned addition above prior to the assignment
- // (2) no overflow, but result has high order bit set and so is interpreted as
- // a negative number when assigned to |local_bytes_used|
- if (local_bytes_used < 0 ||
- static_cast<uint64>(local_bytes_used) < rx_bytes ||
- static_cast<uint64>(local_bytes_used) < tx_bytes) {
- LOG(WARNING) << path_ << ": OnByteCounterUpdate: overflow detected";
- return;
- }
- active_plan->SetLocalBytesUsed(local_bytes_used);
- DLOG(INFO) << path_
- << ": OnByteCounterUpdate: updated plan state: data bytes used = "
- << active_plan->GetDataBytesUsed() << ", local bytes used = "
- << active_plan->GetLocalBytesUsed() << ", total bytes used = "
- << active_plan->GetTotalBytesUsed();
- MaybeEmitDataPlansUpdate();
}
// DataPlanProviderDelegate methods
« src/device.h ('K') | « src/procfs_byte_counter.cc ('k') | src/service_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698