OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 | 668 |
669 // Remove XSSI guard for JSON parsing. | 669 // Remove XSSI guard for JSON parsing. |
670 size_t json_start_index = json_data.find("{"); | 670 size_t json_start_index = json_data.find("{"); |
671 base::StringPiece json_data_substr(json_data); | 671 base::StringPiece json_data_substr(json_data); |
672 if (json_start_index != std::string::npos) | 672 if (json_start_index != std::string::npos) |
673 json_data_substr.remove_prefix(json_start_index); | 673 json_data_substr.remove_prefix(json_start_index); |
674 | 674 |
675 JSONStringValueDeserializer deserializer(json_data_substr); | 675 JSONStringValueDeserializer deserializer(json_data_substr); |
676 deserializer.set_allow_trailing_comma(true); | 676 deserializer.set_allow_trailing_comma(true); |
677 int error_code = 0; | 677 int error_code = 0; |
678 scoped_ptr<base::Value> doodle_json = | 678 std::unique_ptr<base::Value> doodle_json = |
679 deserializer.Deserialize(&error_code, nullptr); | 679 deserializer.Deserialize(&error_code, nullptr); |
680 | 680 |
681 base::TimeDelta recheck_delay; | 681 base::TimeDelta recheck_delay; |
682 if (error_code != 0) { | 682 if (error_code != 0) { |
683 // On failure, use expotential backoff. | 683 // On failure, use expotential backoff. |
684 backoff_entry_.InformOfRequest(false); | 684 backoff_entry_.InformOfRequest(false); |
685 recheck_delay = backoff_entry_.GetTimeUntilRelease(); | 685 recheck_delay = backoff_entry_.GetTimeUntilRelease(); |
686 } else { | 686 } else { |
687 // If we received information, even if there's no doodle, reset the backoff | 687 // If we received information, even if there's no doodle, reset the backoff |
688 // entry and start rechecking for the doodle at the maximum interval. | 688 // entry and start rechecking for the doodle at the maximum interval. |
(...skipping 10 matching lines...) Expand all Loading... |
699 | 699 |
700 // Check for a new doodle. | 700 // Check for a new doodle. |
701 content::BrowserThread::PostDelayedTask( | 701 content::BrowserThread::PostDelayedTask( |
702 content::BrowserThread::UI, FROM_HERE, | 702 content::BrowserThread::UI, FROM_HERE, |
703 base::Bind(&StartPageService::FetchDoodleJson, | 703 base::Bind(&StartPageService::FetchDoodleJson, |
704 weak_factory_.GetWeakPtr()), | 704 weak_factory_.GetWeakPtr()), |
705 recheck_delay); | 705 recheck_delay); |
706 } | 706 } |
707 | 707 |
708 } // namespace app_list | 708 } // namespace app_list |
OLD | NEW |