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

Side by Side Diff: chrome/browser/ui/app_list/start_page_service.cc

Issue 925783002: Split ValueSerializer into separate Serializer and Deserializer classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed cpplint warnings. Created 5 years, 9 months 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
OLDNEW
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 "chrome/browser/ui/app_list/start_page_service.h" 5 #include "chrome/browser/ui/app_list/start_page_service.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 void StartPageService::OnURLFetchComplete(const net::URLFetcher* source) { 643 void StartPageService::OnURLFetchComplete(const net::URLFetcher* source) {
644 std::string json_data; 644 std::string json_data;
645 source->GetResponseAsString(&json_data); 645 source->GetResponseAsString(&json_data);
646 646
647 // Remove XSSI guard for JSON parsing. 647 // Remove XSSI guard for JSON parsing.
648 size_t json_start_index = json_data.find("{"); 648 size_t json_start_index = json_data.find("{");
649 base::StringPiece json_data_substr(json_data); 649 base::StringPiece json_data_substr(json_data);
650 if (json_start_index != std::string::npos) 650 if (json_start_index != std::string::npos)
651 json_data_substr.remove_prefix(json_start_index); 651 json_data_substr.remove_prefix(json_start_index);
652 652
653 JSONStringValueSerializer deserializer(json_data_substr); 653 JSONStringValueDeserializer deserializer(json_data_substr);
654 deserializer.set_allow_trailing_comma(true); 654 deserializer.set_allow_trailing_comma(true);
655 int error_code = 0; 655 int error_code = 0;
656 scoped_ptr<base::Value> doodle_json( 656 scoped_ptr<base::Value> doodle_json(
657 deserializer.Deserialize(&error_code, nullptr)); 657 deserializer.Deserialize(&error_code, nullptr));
658 658
659 base::TimeDelta recheck_delay = 659 base::TimeDelta recheck_delay =
660 base::TimeDelta::FromMinutes(kDefaultDoodleRecheckDelayMinutes); 660 base::TimeDelta::FromMinutes(kDefaultDoodleRecheckDelayMinutes);
661 661
662 if (error_code == 0) { 662 if (error_code == 0) {
663 base::DictionaryValue* doodle_dictionary = nullptr; 663 base::DictionaryValue* doodle_dictionary = nullptr;
(...skipping 16 matching lines...) Expand all
680 680
681 // Check for a new doodle. 681 // Check for a new doodle.
682 content::BrowserThread::PostDelayedTask( 682 content::BrowserThread::PostDelayedTask(
683 content::BrowserThread::UI, FROM_HERE, 683 content::BrowserThread::UI, FROM_HERE,
684 base::Bind(&StartPageService::FetchDoodleJson, 684 base::Bind(&StartPageService::FetchDoodleJson,
685 weak_factory_.GetWeakPtr()), 685 weak_factory_.GetWeakPtr()),
686 recheck_delay); 686 recheck_delay);
687 } 687 }
688 688
689 } // namespace app_list 689 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698