| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/quirks/quirks_client.h" | 5 #include "components/quirks/quirks_client.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 146 |
| 147 VLOG(1) << "Schedule next Quirks download attempt in " << delay.InSecondsF() | 147 VLOG(1) << "Schedule next Quirks download attempt in " << delay.InSecondsF() |
| 148 << " seconds (retry = " << backoff_entry_.failure_count() << ")."; | 148 << " seconds (retry = " << backoff_entry_.failure_count() << ")."; |
| 149 request_scheduled_.Start(FROM_HERE, delay, this, | 149 request_scheduled_.Start(FROM_HERE, delay, this, |
| 150 &QuirksClient::StartDownload); | 150 &QuirksClient::StartDownload); |
| 151 } | 151 } |
| 152 | 152 |
| 153 bool QuirksClient::ParseResult(const std::string& result, std::string* data) { | 153 bool QuirksClient::ParseResult(const std::string& result, std::string* data) { |
| 154 std::string data64; | 154 std::string data64; |
| 155 const base::DictionaryValue* dict; | 155 const base::DictionaryValue* dict; |
| 156 scoped_ptr<base::Value> json = base::JSONReader::Read(result); | 156 std::unique_ptr<base::Value> json = base::JSONReader::Read(result); |
| 157 if (!json || !json->GetAsDictionary(&dict) || | 157 if (!json || !json->GetAsDictionary(&dict) || |
| 158 !dict->GetString("icc", &data64)) { | 158 !dict->GetString("icc", &data64)) { |
| 159 VLOG(1) << "Failed to parse JSON icc data"; | 159 VLOG(1) << "Failed to parse JSON icc data"; |
| 160 return false; | 160 return false; |
| 161 } | 161 } |
| 162 | 162 |
| 163 if (!base::Base64Decode(data64, data)) { | 163 if (!base::Base64Decode(data64, data)) { |
| 164 VLOG(1) << "Failed to decode Base64 icc data"; | 164 VLOG(1) << "Failed to decode Base64 icc data"; |
| 165 return false; | 165 return false; |
| 166 } | 166 } |
| 167 | 167 |
| 168 return true; | 168 return true; |
| 169 } | 169 } |
| 170 | 170 |
| 171 } // namespace quirks | 171 } // namespace quirks |
| OLD | NEW |