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

Side by Side Diff: components/google/core/browser/google_url_tracker.cc

Issue 1330443002: Report data usage UMA for Chrome services (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@NewArchServices
Patch Set: Fix calling Init function in sync_client.cc Created 5 years, 3 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/google/core/browser/DEPS ('k') | components/invalidation.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/google/core/browser/google_url_tracker.h" 5 #include "components/google/core/browser/google_url_tracker.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
14 #include "components/data_use_measurement/core/data_use_user_data.h"
14 #include "components/google/core/browser/google_pref_names.h" 15 #include "components/google/core/browser/google_pref_names.h"
15 #include "components/google/core/browser/google_switches.h" 16 #include "components/google/core/browser/google_switches.h"
16 #include "components/google/core/browser/google_util.h" 17 #include "components/google/core/browser/google_util.h"
17 #include "components/pref_registry/pref_registry_syncable.h" 18 #include "components/pref_registry/pref_registry_syncable.h"
18 #include "net/base/load_flags.h" 19 #include "net/base/load_flags.h"
19 #include "net/url_request/url_fetcher.h" 20 #include "net/url_request/url_fetcher.h"
20 #include "net/url_request/url_request_status.h" 21 #include "net/url_request/url_request_status.h"
21 22
22 23
23 const char GoogleURLTracker::kDefaultGoogleHomepage[] = 24 const char GoogleURLTracker::kDefaultGoogleHomepage[] =
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // specified a Google base URL manually, we shouldn't bother to look up any 157 // specified a Google base URL manually, we shouldn't bother to look up any
157 // alternatives or offer to switch to them. 158 // alternatives or offer to switch to them.
158 if (!client_->IsBackgroundNetworkingEnabled() || 159 if (!client_->IsBackgroundNetworkingEnabled() ||
159 base::CommandLine::ForCurrentProcess()->HasSwitch( 160 base::CommandLine::ForCurrentProcess()->HasSwitch(
160 switches::kGoogleBaseURL)) 161 switches::kGoogleBaseURL))
161 return; 162 return;
162 163
163 already_fetched_ = true; 164 already_fetched_ = true;
164 fetcher_ = net::URLFetcher::Create(fetcher_id_, GURL(kSearchDomainCheckURL), 165 fetcher_ = net::URLFetcher::Create(fetcher_id_, GURL(kSearchDomainCheckURL),
165 net::URLFetcher::GET, this); 166 net::URLFetcher::GET, this);
167 data_use_measurement::DataUseUserData::AttachToFetcher(
168 fetcher_.get(),
169 data_use_measurement::DataUseUserData::GOOGLE_URL_TRACKER);
166 ++fetcher_id_; 170 ++fetcher_id_;
167 // We don't want this fetch to set new entries in the cache or cookies, lest 171 // We don't want this fetch to set new entries in the cache or cookies, lest
168 // we alarm the user. 172 // we alarm the user.
169 fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE | 173 fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE |
170 net::LOAD_DO_NOT_SAVE_COOKIES); 174 net::LOAD_DO_NOT_SAVE_COOKIES);
171 fetcher_->SetRequestContext(client_->GetRequestContext()); 175 fetcher_->SetRequestContext(client_->GetRequestContext());
172 176
173 // Configure to retry at most kMaxRetries times for 5xx errors. 177 // Configure to retry at most kMaxRetries times for 5xx errors.
174 static const int kMaxRetries = 5; 178 static const int kMaxRetries = 5;
175 fetcher_->SetMaxRetriesOn5xx(kMaxRetries); 179 fetcher_->SetMaxRetriesOn5xx(kMaxRetries);
176 180
177 // Also retry kMaxRetries times on network change errors. A network change can 181 // Also retry kMaxRetries times on network change errors. A network change can
178 // propagate through Chrome in various stages, so it's possible for this code 182 // propagate through Chrome in various stages, so it's possible for this code
179 // to be reached via OnNetworkChanged(), and then have the fetch we kick off 183 // to be reached via OnNetworkChanged(), and then have the fetch we kick off
180 // be canceled due to e.g. the DNS server changing at a later time. In general 184 // be canceled due to e.g. the DNS server changing at a later time. In general
181 // it's not possible to ensure that by the time we reach here any requests we 185 // it's not possible to ensure that by the time we reach here any requests we
182 // start won't be canceled in this fashion, so retrying is the best we can do. 186 // start won't be canceled in this fashion, so retrying is the best we can do.
183 fetcher_->SetAutomaticallyRetryOnNetworkChanges(kMaxRetries); 187 fetcher_->SetAutomaticallyRetryOnNetworkChanges(kMaxRetries);
184 188
185 fetcher_->Start(); 189 fetcher_->Start();
186 } 190 }
OLDNEW
« no previous file with comments | « components/google/core/browser/DEPS ('k') | components/invalidation.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698