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/ntp_snippets/remote/json_request.h" | 5 #include "components/ntp_snippets/remote/json_request.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 void JsonRequest::OnJsonError(const std::string& error) { | 238 void JsonRequest::OnJsonError(const std::string& error) { |
239 std::string json_string; | 239 std::string json_string; |
240 url_fetcher_->GetResponseAsString(&json_string); | 240 url_fetcher_->GetResponseAsString(&json_string); |
241 LOG(WARNING) << "Received invalid JSON (" << error << "): " << json_string; | 241 LOG(WARNING) << "Received invalid JSON (" << error << "): " << json_string; |
242 std::move(request_completed_callback_) | 242 std::move(request_completed_callback_) |
243 .Run(/*result=*/nullptr, FetchResult::JSON_PARSE_ERROR, | 243 .Run(/*result=*/nullptr, FetchResult::JSON_PARSE_ERROR, |
244 /*error_details=*/base::StringPrintf(" (error %s)", error.c_str())); | 244 /*error_details=*/base::StringPrintf(" (error %s)", error.c_str())); |
245 } | 245 } |
246 | 246 |
247 JsonRequest::Builder::Builder() | 247 JsonRequest::Builder::Builder() |
248 : fetch_api_(CHROME_READER_API), | 248 : fetch_api_(CHROME_READER_API), language_model_(nullptr) {} |
249 language_model_(nullptr) {} | |
250 JsonRequest::Builder::Builder(JsonRequest::Builder&&) = default; | 249 JsonRequest::Builder::Builder(JsonRequest::Builder&&) = default; |
251 JsonRequest::Builder::~Builder() = default; | 250 JsonRequest::Builder::~Builder() = default; |
252 | 251 |
253 std::unique_ptr<JsonRequest> JsonRequest::Builder::Build() const { | 252 std::unique_ptr<JsonRequest> JsonRequest::Builder::Build() const { |
254 DCHECK(!url_.is_empty()); | 253 DCHECK(!url_.is_empty()); |
255 DCHECK(url_request_context_getter_); | 254 DCHECK(url_request_context_getter_); |
256 DCHECK(clock_); | 255 DCHECK(clock_); |
257 auto request = base::MakeUnique<JsonRequest>(params_.exclusive_category, | 256 auto request = base::MakeUnique<JsonRequest>(params_.exclusive_category, |
258 clock_, parse_json_callback_); | 257 clock_, parse_json_callback_); |
259 std::string body = BuildBody(); | 258 std::string body = BuildBody(); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 "NewTabPage.Languages.UILanguageRatioInTwoTopLanguages", | 511 "NewTabPage.Languages.UILanguageRatioInTwoTopLanguages", |
513 ratio_ui_in_both_languages * 100); | 512 ratio_ui_in_both_languages * 100); |
514 break; | 513 break; |
515 } | 514 } |
516 } | 515 } |
517 } | 516 } |
518 | 517 |
519 } // namespace internal | 518 } // namespace internal |
520 | 519 |
521 } // namespace ntp_snippets | 520 } // namespace ntp_snippets |
OLD | NEW |