| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium 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 "content/browser/dom_storage/dom_storage_area.h" | 5 #include "content/browser/dom_storage/dom_storage_area.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 } // namespace | 42 } // namespace |
| 43 | 43 |
| 44 DOMStorageArea::RateLimiter::RateLimiter(size_t desired_rate, | 44 DOMStorageArea::RateLimiter::RateLimiter(size_t desired_rate, |
| 45 base::TimeDelta time_quantum) | 45 base::TimeDelta time_quantum) |
| 46 : rate_(desired_rate), samples_(0), time_quantum_(time_quantum) { | 46 : rate_(desired_rate), samples_(0), time_quantum_(time_quantum) { |
| 47 DCHECK_GT(desired_rate, 0ul); | 47 DCHECK_GT(desired_rate, 0ul); |
| 48 } | 48 } |
| 49 | 49 |
| 50 base::TimeDelta DOMStorageArea::RateLimiter::ComputeTimeNeeded() const { | 50 base::TimeDelta DOMStorageArea::RateLimiter::ComputeTimeNeeded() const { |
| 51 return time_quantum_.multiply_by(samples_ / rate_); | 51 return time_quantum_ * (samples_ / rate_); |
| 52 } | 52 } |
| 53 | 53 |
| 54 base::TimeDelta DOMStorageArea::RateLimiter::ComputeDelayNeeded( | 54 base::TimeDelta DOMStorageArea::RateLimiter::ComputeDelayNeeded( |
| 55 const base::TimeDelta elapsed_time) const { | 55 const base::TimeDelta elapsed_time) const { |
| 56 base::TimeDelta time_needed = ComputeTimeNeeded(); | 56 base::TimeDelta time_needed = ComputeTimeNeeded(); |
| 57 if (time_needed > elapsed_time) | 57 if (time_needed > elapsed_time) |
| 58 return time_needed - elapsed_time; | 58 return time_needed - elapsed_time; |
| 59 return base::TimeDelta(); | 59 return base::TimeDelta(); |
| 60 } | 60 } |
| 61 | 61 |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 commit_batch_->clear_all_first, | 456 commit_batch_->clear_all_first, |
| 457 commit_batch_->changed_values); | 457 commit_batch_->changed_values); |
| 458 DCHECK(success); | 458 DCHECK(success); |
| 459 } | 459 } |
| 460 commit_batch_.reset(); | 460 commit_batch_.reset(); |
| 461 backing_.reset(); | 461 backing_.reset(); |
| 462 session_storage_backing_ = NULL; | 462 session_storage_backing_ = NULL; |
| 463 } | 463 } |
| 464 | 464 |
| 465 } // namespace content | 465 } // namespace content |
| OLD | NEW |