cashew: reset local counter on plan transition
The local counter fails to estimate data usage correctly if it is active
during a transition from one plan to another. This CL is the first of
two that will resolve this issue. It addresses plan transitions due to
data quota exhaustion. The subsequent CL will address plan transitions
due to the expiration time having passed.
Changes:
- Add the ability to reset the local byte counter.
- Update OnByteCounterUpdate event handler to iterate over all active
plans and assign measured data traffic appropriately to each plan in
turn. If a plan is consumed, any overage is applied to the next active
plan and the local byte counter is reset accordingly. This continues
until we're either out of data to assign or out of active plans.
- Move the bulk of the ServiceImpl::OnByteCounterUpdate logic to the
DataPlan class to isolate it for unit testing.
BUG=chromium-os:9860
TEST=unit tests, manual testing on device
Change-Id: Ibfe2ee15eb6b79cb4f6575f289629be8388e12f7
Review URL: http://codereview.chromium.org/6250171
15 files changed