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

Side by Side Diff: chrome/browser/autofill/autofill_download.cc

Issue 8373021: Convert URLFetcher::Delegates to use an interface in content/public/common. Also remove the old U... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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/autofill/autofill_download.h ('k') | chrome/browser/bug_report_util.cc » ('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/autofill/autofill_download.h" 5 #include "chrome/browser/autofill/autofill_download.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <ostream> 8 #include <ostream>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/rand_util.h" 12 #include "base/rand_util.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "chrome/browser/autofill/autofill_metrics.h" 15 #include "chrome/browser/autofill/autofill_metrics.h"
16 #include "chrome/browser/autofill/autofill_xml_parser.h" 16 #include "chrome/browser/autofill/autofill_xml_parser.h"
17 #include "chrome/browser/autofill/form_structure.h" 17 #include "chrome/browser/autofill/form_structure.h"
18 #include "chrome/browser/prefs/pref_service.h" 18 #include "chrome/browser/prefs/pref_service.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
21 #include "content/common/net/url_fetcher.h"
21 #include "googleurl/src/gurl.h" 22 #include "googleurl/src/gurl.h"
22 #include "net/http/http_response_headers.h" 23 #include "net/http/http_response_headers.h"
23 #include "third_party/libjingle/source/talk/xmllite/xmlparser.h" 24 #include "third_party/libjingle/source/talk/xmllite/xmlparser.h"
24 25
25 namespace { 26 namespace {
26 const char kAutofillQueryServerRequestUrl[] = 27 const char kAutofillQueryServerRequestUrl[] =
27 "https://toolbarqueries.google.com/tbproxy/af/query"; 28 "https://toolbarqueries.google.com/tbproxy/af/query";
28 const char kAutofillUploadServerRequestUrl[] = 29 const char kAutofillUploadServerRequestUrl[] =
29 "https://toolbarqueries.google.com/tbproxy/af/upload"; 30 "https://toolbarqueries.google.com/tbproxy/af/upload";
30 const char kAutofillQueryServerNameStartInHeader[] = "GFE/"; 31 const char kAutofillQueryServerNameStartInHeader[] = "GFE/";
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 << " request has failed with response " 311 << " request has failed with response "
311 << source->response_code(); 312 << source->response_code();
312 if (observer_) { 313 if (observer_) {
313 observer_->OnServerRequestError(it->second.form_signatures[0], 314 observer_->OnServerRequestError(it->second.form_signatures[0],
314 it->second.request_type, 315 it->second.request_type,
315 source->response_code()); 316 source->response_code());
316 } 317 }
317 } else { 318 } else {
318 VLOG(1) << "AutofillDownloadManager: " << type_of_request 319 VLOG(1) << "AutofillDownloadManager: " << type_of_request
319 << " request has succeeded"; 320 << " request has succeeded";
320 const std::string& response_body = source->GetResponseStringRef(); 321 std::string response_body;
322 CHECK(source->GetResponseAsString(&response_body));
Ilya Sherman 2011/10/23 00:20:12 nit: Do we really need a CHECK() here? Per Brett'
jam 2011/10/23 01:29:18 brett's email was about logging. do CHECKs also ad
321 if (it->second.request_type == AutofillDownloadManager::REQUEST_QUERY) { 323 if (it->second.request_type == AutofillDownloadManager::REQUEST_QUERY) {
322 CacheQueryRequest(it->second.form_signatures, response_body); 324 CacheQueryRequest(it->second.form_signatures, response_body);
323 if (observer_) 325 if (observer_)
324 observer_->OnLoadedServerPredictions(response_body); 326 observer_->OnLoadedServerPredictions(response_body);
325 } else { 327 } else {
326 double new_positive_upload_rate = 0; 328 double new_positive_upload_rate = 0;
327 double new_negative_upload_rate = 0; 329 double new_negative_upload_rate = 0;
328 AutofillUploadXmlParser parse_handler(&new_positive_upload_rate, 330 AutofillUploadXmlParser parse_handler(&new_positive_upload_rate,
329 &new_negative_upload_rate); 331 &new_negative_upload_rate);
330 buzz::XmlParser parser(&parse_handler); 332 buzz::XmlParser parser(&parse_handler);
331 parser.Parse(response_body.data(), response_body.length(), true); 333 parser.Parse(response_body.data(), response_body.length(), true);
332 if (parse_handler.succeeded()) { 334 if (parse_handler.succeeded()) {
333 SetPositiveUploadRate(new_positive_upload_rate); 335 SetPositiveUploadRate(new_positive_upload_rate);
334 SetNegativeUploadRate(new_negative_upload_rate); 336 SetNegativeUploadRate(new_negative_upload_rate);
335 } 337 }
336 338
337 if (observer_) 339 if (observer_)
338 observer_->OnUploadedPossibleFieldTypes(); 340 observer_->OnUploadedPossibleFieldTypes();
339 } 341 }
340 } 342 }
341 delete it->first; 343 delete it->first;
342 url_fetchers_.erase(it); 344 url_fetchers_.erase(it);
343 } 345 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_download.h ('k') | chrome/browser/bug_report_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698