| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/metrics/variations/variations_service.h" | 5 #include "chrome/browser/metrics/variations/variations_service.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/build_time.h" | 10 #include "base/build_time.h" |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 | 474 |
| 475 // Only store the seed data if it parses correctly. | 475 // Only store the seed data if it parses correctly. |
| 476 VariationsSeed seed; | 476 VariationsSeed seed; |
| 477 if (!seed.ParseFromString(seed_data)) { | 477 if (!seed.ParseFromString(seed_data)) { |
| 478 VLOG(1) << "Variations Seed data from server is not in valid proto format, " | 478 VLOG(1) << "Variations Seed data from server is not in valid proto format, " |
| 479 << "rejecting the seed."; | 479 << "rejecting the seed."; |
| 480 return false; | 480 return false; |
| 481 } | 481 } |
| 482 | 482 |
| 483 std::string base64_seed_data; | 483 std::string base64_seed_data; |
| 484 if (!base::Base64Encode(seed_data, &base64_seed_data)) { | 484 base::Base64Encode(seed_data, &base64_seed_data); |
| 485 VLOG(1) << "Variations Seed data from server fails Base64Encode, rejecting " | |
| 486 << "the seed."; | |
| 487 return false; | |
| 488 } | |
| 489 | 485 |
| 490 local_state_->SetString(prefs::kVariationsSeed, base64_seed_data); | 486 local_state_->SetString(prefs::kVariationsSeed, base64_seed_data); |
| 491 local_state_->SetString(prefs::kVariationsSeedHash, HashSeed(seed_data)); | 487 local_state_->SetString(prefs::kVariationsSeedHash, HashSeed(seed_data)); |
| 492 local_state_->SetInt64(prefs::kVariationsSeedDate, | 488 local_state_->SetInt64(prefs::kVariationsSeedDate, |
| 493 seed_date.ToInternalValue()); | 489 seed_date.ToInternalValue()); |
| 494 variations_serial_number_ = seed.serial_number(); | 490 variations_serial_number_ = seed.serial_number(); |
| 495 | 491 |
| 496 RecordLastFetchTime(); | 492 RecordLastFetchTime(); |
| 497 | 493 |
| 498 return true; | 494 return true; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 528 | 524 |
| 529 void VariationsService::RecordLastFetchTime() { | 525 void VariationsService::RecordLastFetchTime() { |
| 530 // local_state_ is NULL in tests, so check it first. | 526 // local_state_ is NULL in tests, so check it first. |
| 531 if (local_state_) { | 527 if (local_state_) { |
| 532 local_state_->SetInt64(prefs::kVariationsLastFetchTime, | 528 local_state_->SetInt64(prefs::kVariationsLastFetchTime, |
| 533 base::Time::Now().ToInternalValue()); | 529 base::Time::Now().ToInternalValue()); |
| 534 } | 530 } |
| 535 } | 531 } |
| 536 | 532 |
| 537 } // namespace chrome_variations | 533 } // namespace chrome_variations |
| OLD | NEW |