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

Side by Side Diff: components/ntp_tiles/popular_sites.cc

Issue 2276113002: Add data usage tracking for NTP tiles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « components/ntp_tiles/DEPS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/files/important_file_writer.h" 13 #include "base/files/important_file_writer.h"
14 #include "base/json/json_reader.h" 14 #include "base/json/json_reader.h"
15 #include "base/json/json_writer.h" 15 #include "base/json/json_writer.h"
16 #include "base/path_service.h" 16 #include "base/path_service.h"
17 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
18 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
19 #include "base/task_runner_util.h" 19 #include "base/task_runner_util.h"
20 #include "base/time/time.h" 20 #include "base/time/time.h"
21 #include "base/values.h" 21 #include "base/values.h"
22 #include "components/data_use_measurement/core/data_use_user_data.h"
22 #include "components/google/core/browser/google_util.h" 23 #include "components/google/core/browser/google_util.h"
23 #include "components/ntp_tiles/constants.h" 24 #include "components/ntp_tiles/constants.h"
24 #include "components/ntp_tiles/pref_names.h" 25 #include "components/ntp_tiles/pref_names.h"
25 #include "components/ntp_tiles/switches.h" 26 #include "components/ntp_tiles/switches.h"
26 #include "components/pref_registry/pref_registry_syncable.h" 27 #include "components/pref_registry/pref_registry_syncable.h"
27 #include "components/prefs/pref_service.h" 28 #include "components/prefs/pref_service.h"
28 #include "components/search_engines/search_engine_type.h" 29 #include "components/search_engines/search_engine_type.h"
29 #include "components/search_engines/template_url_service.h" 30 #include "components/search_engines/template_url_service.h"
30 #include "components/variations/service/variations_service.h" 31 #include "components/variations/service/variations_service.h"
31 #include "components/variations/variations_associated_data.h" 32 #include "components/variations/variations_associated_data.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 OnJsonParseFailed("previously-fetched JSON was no longer parseable"); 272 OnJsonParseFailed("previously-fetched JSON was no longer parseable");
272 } 273 }
273 } else { 274 } else {
274 // 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.
275 FetchPopularSites(); 276 FetchPopularSites();
276 } 277 }
277 } 278 }
278 279
279 void PopularSites::FetchPopularSites() { 280 void PopularSites::FetchPopularSites() {
280 fetcher_ = URLFetcher::Create(pending_url_, URLFetcher::GET, this); 281 fetcher_ = URLFetcher::Create(pending_url_, URLFetcher::GET, this);
282 data_use_measurement::DataUseUserData::AttachToFetcher(
283 fetcher_.get(), data_use_measurement::DataUseUserData::NTP_SNIPPETS);
sfiera 2016/08/25 05:39:46 This doesn't seem like the right enum value. NTP_S
Raj 2016/09/22 19:12:03 Done.
281 fetcher_->SetRequestContext(download_context_); 284 fetcher_->SetRequestContext(download_context_);
282 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 285 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
283 net::LOAD_DO_NOT_SAVE_COOKIES); 286 net::LOAD_DO_NOT_SAVE_COOKIES);
284 fetcher_->SetAutomaticallyRetryOnNetworkChanges(1); 287 fetcher_->SetAutomaticallyRetryOnNetworkChanges(1);
285 fetcher_->Start(); 288 fetcher_->Start();
286 } 289 }
287 290
288 void PopularSites::OnURLFetchComplete(const net::URLFetcher* source) { 291 void PopularSites::OnURLFetchComplete(const net::URLFetcher* source) {
289 DCHECK_EQ(fetcher_.get(), source); 292 DCHECK_EQ(fetcher_.get(), source);
290 std::unique_ptr<net::URLFetcher> free_fetcher = std::move(fetcher_); 293 std::unique_ptr<net::URLFetcher> free_fetcher = std::move(fetcher_);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 pending_url_ = GetPopularSitesURL(kPopularSitesDefaultCountryCode, 376 pending_url_ = GetPopularSitesURL(kPopularSitesDefaultCountryCode,
374 kPopularSitesDefaultVersion); 377 kPopularSitesDefaultVersion);
375 FetchPopularSites(); 378 FetchPopularSites();
376 } else { 379 } else {
377 DLOG(WARNING) << "Download fallback site list failed"; 380 DLOG(WARNING) << "Download fallback site list failed";
378 callback_.Run(false); 381 callback_.Run(false);
379 } 382 }
380 } 383 }
381 384
382 } // namespace ntp_tiles 385 } // namespace ntp_tiles
OLDNEW
« no previous file with comments | « components/ntp_tiles/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698