OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_tiles/popular_sites.h" | 5 #include "components/ntp_tiles/popular_sites.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 OnJsonParseFailed("previously-fetched JSON was no longer parseable"); | 272 OnJsonParseFailed("previously-fetched JSON was no longer parseable"); |
273 } | 273 } |
274 } else { | 274 } else { |
275 // File didn't exist, or couldn't be read for some other reason. | 275 // File didn't exist, or couldn't be read for some other reason. |
276 FetchPopularSites(); | 276 FetchPopularSites(); |
277 } | 277 } |
278 } | 278 } |
279 | 279 |
280 void PopularSites::FetchPopularSites() { | 280 void PopularSites::FetchPopularSites() { |
281 fetcher_ = URLFetcher::Create(pending_url_, URLFetcher::GET, this); | 281 fetcher_ = URLFetcher::Create(pending_url_, URLFetcher::GET, this); |
282 // TODO(sfiera): Count the downloaded bytes of icons fetched by popular sites. | |
283 data_use_measurement::DataUseUserData::AttachToFetcher( | 282 data_use_measurement::DataUseUserData::AttachToFetcher( |
284 fetcher_.get(), data_use_measurement::DataUseUserData::NTP_TILES); | 283 fetcher_.get(), data_use_measurement::DataUseUserData::NTP_TILES); |
285 fetcher_->SetRequestContext(download_context_); | 284 fetcher_->SetRequestContext(download_context_); |
286 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 285 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
287 net::LOAD_DO_NOT_SAVE_COOKIES); | 286 net::LOAD_DO_NOT_SAVE_COOKIES); |
288 fetcher_->SetAutomaticallyRetryOnNetworkChanges(1); | 287 fetcher_->SetAutomaticallyRetryOnNetworkChanges(1); |
289 fetcher_->Start(); | 288 fetcher_->Start(); |
290 } | 289 } |
291 | 290 |
292 void PopularSites::OnURLFetchComplete(const net::URLFetcher* source) { | 291 void PopularSites::OnURLFetchComplete(const net::URLFetcher* source) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 pending_url_ = GetPopularSitesURL(kPopularSitesDefaultCountryCode, | 376 pending_url_ = GetPopularSitesURL(kPopularSitesDefaultCountryCode, |
378 kPopularSitesDefaultVersion); | 377 kPopularSitesDefaultVersion); |
379 FetchPopularSites(); | 378 FetchPopularSites(); |
380 } else { | 379 } else { |
381 DLOG(WARNING) << "Download fallback site list failed"; | 380 DLOG(WARNING) << "Download fallback site list failed"; |
382 callback_.Run(false); | 381 callback_.Run(false); |
383 } | 382 } |
384 } | 383 } |
385 | 384 |
386 } // namespace ntp_tiles | 385 } // namespace ntp_tiles |
OLD | NEW |