Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(854)

Side by Side Diff: trunk/src/chrome/browser/metrics/variations/variations_service.cc

Issue 101113004: Revert 239759 "The comment in base64.h implies that base::Base64..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 base::Base64Encode(seed_data, &base64_seed_data); 484 if (!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 }
485 489
486 local_state_->SetString(prefs::kVariationsSeed, base64_seed_data); 490 local_state_->SetString(prefs::kVariationsSeed, base64_seed_data);
487 local_state_->SetString(prefs::kVariationsSeedHash, HashSeed(seed_data)); 491 local_state_->SetString(prefs::kVariationsSeedHash, HashSeed(seed_data));
488 local_state_->SetInt64(prefs::kVariationsSeedDate, 492 local_state_->SetInt64(prefs::kVariationsSeedDate,
489 seed_date.ToInternalValue()); 493 seed_date.ToInternalValue());
490 variations_serial_number_ = seed.serial_number(); 494 variations_serial_number_ = seed.serial_number();
491 495
492 RecordLastFetchTime(); 496 RecordLastFetchTime();
493 497
494 return true; 498 return true;
(...skipping 29 matching lines...) Expand all
524 528
525 void VariationsService::RecordLastFetchTime() { 529 void VariationsService::RecordLastFetchTime() {
526 // local_state_ is NULL in tests, so check it first. 530 // local_state_ is NULL in tests, so check it first.
527 if (local_state_) { 531 if (local_state_) {
528 local_state_->SetInt64(prefs::kVariationsLastFetchTime, 532 local_state_->SetInt64(prefs::kVariationsLastFetchTime,
529 base::Time::Now().ToInternalValue()); 533 base::Time::Now().ToInternalValue());
530 } 534 }
531 } 535 }
532 536
533 } // namespace chrome_variations 537 } // namespace chrome_variations
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698