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

Side by Side Diff: chrome/browser/google/google_url_tracker.cc

Issue 8375039: Create a content::UrlFetcher interface that lives in content/public/common and convert users to i... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments Created 9 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/google/google_url_tracker.h ('k') | chrome/browser/importer/toolbar_importer.h » ('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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/google/google_url_tracker.h" 5 #include "chrome/browser/google/google_url_tracker.h"
6 6
7 #include <vector> 7 #include <vector>
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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 switches::kDisableBackgroundNetworking)) 204 switches::kDisableBackgroundNetworking))
205 return; 205 return;
206 206
207 already_fetched_ = true; 207 already_fetched_ = true;
208 fetcher_.reset(URLFetcher::Create(fetcher_id_, GURL(kSearchDomainCheckURL), 208 fetcher_.reset(URLFetcher::Create(fetcher_id_, GURL(kSearchDomainCheckURL),
209 URLFetcher::GET, this)); 209 URLFetcher::GET, this));
210 ++fetcher_id_; 210 ++fetcher_id_;
211 // We don't want this fetch to affect existing state in local_state. For 211 // We don't want this fetch to affect existing state in local_state. For
212 // example, if a user has no Google cookies, this automatic check should not 212 // example, if a user has no Google cookies, this automatic check should not
213 // cause one to be set, lest we alarm the user. 213 // cause one to be set, lest we alarm the user.
214 fetcher_->set_load_flags(net::LOAD_DISABLE_CACHE | 214 fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE |
215 net::LOAD_DO_NOT_SAVE_COOKIES); 215 net::LOAD_DO_NOT_SAVE_COOKIES);
216 fetcher_->set_request_context(g_browser_process->system_request_context()); 216 fetcher_->SetRequestContext(g_browser_process->system_request_context());
217 217
218 // Configure to max_retries at most kMaxRetries times for 5xx errors. 218 // Configure to max_retries at most kMaxRetries times for 5xx errors.
219 static const int kMaxRetries = 5; 219 static const int kMaxRetries = 5;
220 fetcher_->set_max_retries(kMaxRetries); 220 fetcher_->SetMaxRetries(kMaxRetries);
221 221
222 fetcher_->Start(); 222 fetcher_->Start();
223 } 223 }
224 224
225 void GoogleURLTracker::OnURLFetchComplete(const URLFetcher* source) { 225 void GoogleURLTracker::OnURLFetchComplete(const content::URLFetcher* source) {
226 // Delete the fetcher on this function's exit. 226 // Delete the fetcher on this function's exit.
227 scoped_ptr<URLFetcher> clean_up_fetcher(fetcher_.release()); 227 scoped_ptr<content::URLFetcher> clean_up_fetcher(fetcher_.release());
228 228
229 // Don't update the URL if the request didn't succeed. 229 // Don't update the URL if the request didn't succeed.
230 if (!source->status().is_success() || (source->response_code() != 200)) { 230 if (!source->GetStatus().is_success() || (source->GetResponseCode() != 200)) {
231 already_fetched_ = false; 231 already_fetched_ = false;
232 return; 232 return;
233 } 233 }
234 234
235 // See if the response data was one we want to use, and if so, convert to the 235 // See if the response data was one we want to use, and if so, convert to the
236 // appropriate Google base URL. 236 // appropriate Google base URL.
237 std::string url_str; 237 std::string url_str;
238 source->GetResponseAsString(&url_str); 238 source->GetResponseAsString(&url_str);
239 TrimWhitespace(url_str, TRIM_ALL, &url_str); 239 TrimWhitespace(url_str, TRIM_ALL, &url_str);
240 240
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 380
381 // |tab_contents| can be NULL during tests. 381 // |tab_contents| can be NULL during tests.
382 InfoBarTabHelper* infobar_helper = NULL; 382 InfoBarTabHelper* infobar_helper = NULL;
383 if (tab_contents) { 383 if (tab_contents) {
384 TabContentsWrapper* wrapper = 384 TabContentsWrapper* wrapper =
385 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); 385 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents);
386 infobar_helper = wrapper->infobar_tab_helper(); 386 infobar_helper = wrapper->infobar_tab_helper();
387 } 387 }
388 infobar_ = (*infobar_creator_)(infobar_helper, this, fetched_google_url_); 388 infobar_ = (*infobar_creator_)(infobar_helper, this, fetched_google_url_);
389 } 389 }
OLDNEW
« no previous file with comments | « chrome/browser/google/google_url_tracker.h ('k') | chrome/browser/importer/toolbar_importer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698