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

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: Updated as per review comments. Created 5 years, 10 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 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 void StartPageService::OnURLFetchComplete(const net::URLFetcher* source) { 630 void StartPageService::OnURLFetchComplete(const net::URLFetcher* source) {
631 std::string json_data; 631 std::string json_data;
632 source->GetResponseAsString(&json_data); 632 source->GetResponseAsString(&json_data);
633 633
634 // Remove XSSI guard for JSON parsing. 634 // Remove XSSI guard for JSON parsing.
635 size_t json_start_index = json_data.find("{"); 635 size_t json_start_index = json_data.find("{");
636 base::StringPiece json_data_substr(json_data); 636 base::StringPiece json_data_substr(json_data);
637 if (json_start_index != std::string::npos) 637 if (json_start_index != std::string::npos)
638 json_data_substr.remove_prefix(json_start_index); 638 json_data_substr.remove_prefix(json_start_index);
639 639
640 JSONStringValueSerializer deserializer(json_data_substr); 640 JSONStringValueDeserializer deserializer(json_data_substr);
641 deserializer.set_allow_trailing_comma(true); 641 deserializer.set_allow_trailing_comma(true);
642 int error_code = 0; 642 int error_code = 0;
643 scoped_ptr<base::Value> doodle_json( 643 scoped_ptr<base::Value> doodle_json(
644 deserializer.Deserialize(&error_code, nullptr)); 644 deserializer.Deserialize(&error_code, nullptr));
645 645
646 base::TimeDelta recheck_delay = 646 base::TimeDelta recheck_delay =
647 base::TimeDelta::FromMinutes(kDefaultDoodleRecheckDelayMinutes); 647 base::TimeDelta::FromMinutes(kDefaultDoodleRecheckDelayMinutes);
648 648
649 if (error_code == 0) { 649 if (error_code == 0) {
650 base::DictionaryValue* doodle_dictionary = nullptr; 650 base::DictionaryValue* doodle_dictionary = nullptr;
(...skipping 16 matching lines...) Expand all
667 667
668 // Check for a new doodle. 668 // Check for a new doodle.
669 content::BrowserThread::PostDelayedTask( 669 content::BrowserThread::PostDelayedTask(
670 content::BrowserThread::UI, FROM_HERE, 670 content::BrowserThread::UI, FROM_HERE,
671 base::Bind(&StartPageService::FetchDoodleJson, 671 base::Bind(&StartPageService::FetchDoodleJson,
672 weak_factory_.GetWeakPtr()), 672 weak_factory_.GetWeakPtr()),
673 recheck_delay); 673 recheck_delay);
674 } 674 }
675 675
676 } // namespace app_list 676 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698