summaryrefslogtreecommitdiffstats
path: root/chrome/browser/internal_auth.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/internal_auth.cc')
-rw-r--r--chrome/browser/internal_auth.cc22
1 files changed, 8 insertions, 14 deletions
diff --git a/chrome/browser/internal_auth.cc b/chrome/browser/internal_auth.cc
index 76e32b4..faa44e1 100644
--- a/chrome/browser/internal_auth.cc
+++ b/chrome/browser/internal_auth.cc
@@ -16,7 +16,6 @@
#include "base/string_util.h"
#include "base/threading/thread_checker.h"
#include "base/time.h"
-#include "base/timer.h"
#include "base/values.h"
#include "content/browser/browser_thread.h"
#include "crypto/hmac.h"
@@ -342,16 +341,7 @@ class InternalAuthGenerationService : public base::ThreadChecker {
void GenerateNewKey() {
DCHECK(CalledOnValidThread());
- if (!timer_.IsRunning()) {
- timer_.Start(FROM_HERE,
- base::TimeDelta::FromMicroseconds(
- kKeyRegenerationSoftTicks * kTickUs),
- this,
- &InternalAuthGenerationService::GenerateNewKey);
- }
-
- scoped_ptr<crypto::HMAC> new_engine(
- new crypto::HMAC(crypto::HMAC::SHA256));
+ scoped_ptr<crypto::HMAC> new_engine(new crypto::HMAC(crypto::HMAC::SHA256));
std::string key = base::RandBytesAsString(kKeySizeInBytes);
if (!new_engine->Init(key))
return;
@@ -374,8 +364,13 @@ class InternalAuthGenerationService : public base::ThreadChecker {
int64 current_tick = GetCurrentTick();
if (!used_ticks_.empty() && used_ticks_.back() > current_tick)
current_tick = used_ticks_.back();
- if (current_tick > key_regeneration_tick_ + kKeyRegenerationHardTicks)
- return 0;
+ for (bool first_iteration = true;; first_iteration = false) {
+ if (current_tick < key_regeneration_tick_ + kKeyRegenerationHardTicks)
+ break;
+ if (!first_iteration)
+ return 0;
+ GenerateNewKey();
+ }
// Forget outdated ticks if any.
used_ticks_.erase(
@@ -426,7 +421,6 @@ class InternalAuthGenerationService : public base::ThreadChecker {
}
scoped_ptr<crypto::HMAC> engine_;
- base::RepeatingTimer<InternalAuthGenerationService> timer_;
int64 key_regeneration_tick_;
std::deque<int64> used_ticks_;