OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/internal_auth.h" | 5 #include "chrome/browser/internal_auth.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 | 336 |
337 class InternalAuthGenerationService : public base::ThreadChecker { | 337 class InternalAuthGenerationService : public base::ThreadChecker { |
338 public: | 338 public: |
339 InternalAuthGenerationService() : key_regeneration_tick_(0) { | 339 InternalAuthGenerationService() : key_regeneration_tick_(0) { |
340 GenerateNewKey(); | 340 GenerateNewKey(); |
341 } | 341 } |
342 | 342 |
343 void GenerateNewKey() { | 343 void GenerateNewKey() { |
344 DCHECK(CalledOnValidThread()); | 344 DCHECK(CalledOnValidThread()); |
345 if (!timer_.IsRunning()) { | 345 if (!timer_.IsRunning()) { |
346 timer_.Start(FROM_HERE, | 346 timer_.Start( |
347 base::TimeDelta::FromMicroseconds( | 347 base::TimeDelta::FromMicroseconds( |
348 kKeyRegenerationSoftTicks * kTickUs), | 348 kKeyRegenerationSoftTicks * kTickUs), |
349 this, | 349 this, |
350 &InternalAuthGenerationService::GenerateNewKey); | 350 &InternalAuthGenerationService::GenerateNewKey); |
351 } | 351 } |
352 | 352 |
353 scoped_ptr<crypto::HMAC> new_engine( | 353 scoped_ptr<crypto::HMAC> new_engine( |
354 new crypto::HMAC(crypto::HMAC::SHA256)); | 354 new crypto::HMAC(crypto::HMAC::SHA256)); |
355 std::string key = base::RandBytesAsString(kKeySizeInBytes); | 355 std::string key = base::RandBytesAsString(kKeySizeInBytes); |
356 if (!new_engine->Init(key)) | 356 if (!new_engine->Init(key)) |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 return g_generation_service.Get().GeneratePassport(domain, var_value_map, 0); | 477 return g_generation_service.Get().GeneratePassport(domain, var_value_map, 0); |
478 } | 478 } |
479 | 479 |
480 // static | 480 // static |
481 void InternalAuthGeneration::GenerateNewKey() { | 481 void InternalAuthGeneration::GenerateNewKey() { |
482 g_generation_service.Get().GenerateNewKey(); | 482 g_generation_service.Get().GenerateNewKey(); |
483 } | 483 } |
484 | 484 |
485 } // namespace browser | 485 } // namespace browser |
486 | 486 |
OLD | NEW |