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

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 comment. 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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 void StartPageService::OnURLFetchComplete(const net::URLFetcher* source) { 574 void StartPageService::OnURLFetchComplete(const net::URLFetcher* source) {
575 std::string json_data; 575 std::string json_data;
576 source->GetResponseAsString(&json_data); 576 source->GetResponseAsString(&json_data);
577 577
578 // Remove XSSI guard for JSON parsing. 578 // Remove XSSI guard for JSON parsing.
579 size_t json_start_index = json_data.find("{"); 579 size_t json_start_index = json_data.find("{");
580 base::StringPiece json_data_substr(json_data); 580 base::StringPiece json_data_substr(json_data);
581 if (json_start_index != std::string::npos) 581 if (json_start_index != std::string::npos)
582 json_data_substr.remove_prefix(json_start_index); 582 json_data_substr.remove_prefix(json_start_index);
583 583
584 JSONStringValueSerializer deserializer(json_data_substr); 584 JSONStringValueDeserializer deserializer(json_data_substr);
585 deserializer.set_allow_trailing_comma(true); 585 deserializer.set_allow_trailing_comma(true);
586 int error_code = 0; 586 int error_code = 0;
587 scoped_ptr<base::Value> doodle_json( 587 scoped_ptr<base::Value> doodle_json(
588 deserializer.Deserialize(&error_code, nullptr)); 588 deserializer.Deserialize(&error_code, nullptr));
589 589
590 base::TimeDelta recheck_delay = 590 base::TimeDelta recheck_delay =
591 base::TimeDelta::FromMinutes(kDefaultDoodleRecheckDelayMinutes); 591 base::TimeDelta::FromMinutes(kDefaultDoodleRecheckDelayMinutes);
592 592
593 if (error_code == 0) { 593 if (error_code == 0) {
594 base::DictionaryValue* doodle_dictionary = nullptr; 594 base::DictionaryValue* doodle_dictionary = nullptr;
(...skipping 14 matching lines...) Expand all
609 609
610 // Check for a new doodle. 610 // Check for a new doodle.
611 content::BrowserThread::PostDelayedTask( 611 content::BrowserThread::PostDelayedTask(
612 content::BrowserThread::UI, FROM_HERE, 612 content::BrowserThread::UI, FROM_HERE,
613 base::Bind(&StartPageService::FetchDoodleJson, 613 base::Bind(&StartPageService::FetchDoodleJson,
614 weak_factory_.GetWeakPtr()), 614 weak_factory_.GetWeakPtr()),
615 recheck_delay); 615 recheck_delay);
616 } 616 }
617 617
618 } // namespace app_list 618 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698