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

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

Issue 1117703002: Adjust URLFetcher::Create API so that object is returned as scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unneeded Pass() calls Created 5 years, 7 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
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/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // Some switches should disable the Google URL tracker entirely. If we can't 141 // Some switches should disable the Google URL tracker entirely. If we can't
142 // do background networking, we can't do the necessary fetch, and if the user 142 // do background networking, we can't do the necessary fetch, and if the user
143 // specified a Google base URL manually, we shouldn't bother to look up any 143 // specified a Google base URL manually, we shouldn't bother to look up any
144 // alternatives or offer to switch to them. 144 // alternatives or offer to switch to them.
145 if (!client_->IsBackgroundNetworkingEnabled() || 145 if (!client_->IsBackgroundNetworkingEnabled() ||
146 base::CommandLine::ForCurrentProcess()->HasSwitch( 146 base::CommandLine::ForCurrentProcess()->HasSwitch(
147 switches::kGoogleBaseURL)) 147 switches::kGoogleBaseURL))
148 return; 148 return;
149 149
150 already_fetched_ = true; 150 already_fetched_ = true;
151 fetcher_.reset(net::URLFetcher::Create( 151 fetcher_ = net::URLFetcher::Create(fetcher_id_, GURL(kSearchDomainCheckURL),
152 fetcher_id_, GURL(kSearchDomainCheckURL), net::URLFetcher::GET, this)); 152 net::URLFetcher::GET, this);
153 ++fetcher_id_; 153 ++fetcher_id_;
154 // We don't want this fetch to set new entries in the cache or cookies, lest 154 // We don't want this fetch to set new entries in the cache or cookies, lest
155 // we alarm the user. 155 // we alarm the user.
156 fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE | 156 fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE |
157 net::LOAD_DO_NOT_SAVE_COOKIES); 157 net::LOAD_DO_NOT_SAVE_COOKIES);
158 fetcher_->SetRequestContext(client_->GetRequestContext()); 158 fetcher_->SetRequestContext(client_->GetRequestContext());
159 159
160 // Configure to retry at most kMaxRetries times for 5xx errors. 160 // Configure to retry at most kMaxRetries times for 5xx errors.
161 static const int kMaxRetries = 5; 161 static const int kMaxRetries = 5;
162 fetcher_->SetMaxRetriesOn5xx(kMaxRetries); 162 fetcher_->SetMaxRetriesOn5xx(kMaxRetries);
163 163
164 // Also retry kMaxRetries times on network change errors. A network change can 164 // Also retry kMaxRetries times on network change errors. A network change can
165 // propagate through Chrome in various stages, so it's possible for this code 165 // propagate through Chrome in various stages, so it's possible for this code
166 // to be reached via OnNetworkChanged(), and then have the fetch we kick off 166 // to be reached via OnNetworkChanged(), and then have the fetch we kick off
167 // be canceled due to e.g. the DNS server changing at a later time. In general 167 // be canceled due to e.g. the DNS server changing at a later time. In general
168 // it's not possible to ensure that by the time we reach here any requests we 168 // it's not possible to ensure that by the time we reach here any requests we
169 // start won't be canceled in this fashion, so retrying is the best we can do. 169 // start won't be canceled in this fashion, so retrying is the best we can do.
170 fetcher_->SetAutomaticallyRetryOnNetworkChanges(kMaxRetries); 170 fetcher_->SetAutomaticallyRetryOnNetworkChanges(kMaxRetries);
171 171
172 fetcher_->Start(); 172 fetcher_->Start();
173 } 173 }
OLDNEW
« no previous file with comments | « components/gcm_driver/gcm_channel_status_request.cc ('k') | components/history/core/browser/web_history_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698