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

Side by Side Diff: content/browser/geolocation/network_location_request.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
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 "content/browser/geolocation/network_location_request.h" 5 #include "content/browser/geolocation/network_location_request.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 url_fetcher_.reset(); 82 url_fetcher_.reset();
83 } 83 }
84 radio_data_ = radio_data; 84 radio_data_ = radio_data;
85 wifi_data_ = wifi_data; 85 wifi_data_ = wifi_data;
86 timestamp_ = timestamp; 86 timestamp_ = timestamp;
87 87
88 GURL request_url = FormRequestURL(url_.spec(), access_token, 88 GURL request_url = FormRequestURL(url_.spec(), access_token,
89 wifi_data, timestamp_); 89 wifi_data, timestamp_);
90 url_fetcher_.reset(URLFetcher::Create( 90 url_fetcher_.reset(URLFetcher::Create(
91 url_fetcher_id_for_tests, request_url, URLFetcher::GET, this)); 91 url_fetcher_id_for_tests, request_url, URLFetcher::GET, this));
92 url_fetcher_->set_request_context(url_context_); 92 url_fetcher_->SetRequestContext(url_context_);
93 url_fetcher_->set_load_flags( 93 url_fetcher_->SetLoadFlags(
94 net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE | 94 net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE |
95 net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_COOKIES | 95 net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_COOKIES |
96 net::LOAD_DO_NOT_SEND_AUTH_DATA); 96 net::LOAD_DO_NOT_SEND_AUTH_DATA);
97 97
98 url_fetcher_->Start(); 98 url_fetcher_->Start();
99 return true; 99 return true;
100 } 100 }
101 101
102 void NetworkLocationRequest::OnURLFetchComplete(const URLFetcher* source) { 102 void NetworkLocationRequest::OnURLFetchComplete(
103 const content::URLFetcher* source) {
103 DCHECK_EQ(url_fetcher_.get(), source); 104 DCHECK_EQ(url_fetcher_.get(), source);
104 105
105 net::URLRequestStatus status = source->status(); 106 net::URLRequestStatus status = source->GetStatus();
106 int response_code = source->response_code(); 107 int response_code = source->GetResponseCode();
107 108
108 Geoposition position; 109 Geoposition position;
109 string16 access_token; 110 string16 access_token;
110 std::string data; 111 std::string data;
111 source->GetResponseAsString(&data); 112 source->GetResponseAsString(&data);
112 GetLocationFromResponse(status.is_success(), 113 GetLocationFromResponse(status.is_success(),
113 response_code, 114 response_code,
114 data, 115 data,
115 timestamp_, 116 timestamp_,
116 source->url(), 117 source->GetUrl(),
117 &position, 118 &position,
118 &access_token); 119 &access_token);
119 const bool server_error = 120 const bool server_error =
120 !status.is_success() || (response_code >= 500 && response_code < 600); 121 !status.is_success() || (response_code >= 500 && response_code < 600);
121 url_fetcher_.reset(); 122 url_fetcher_.reset();
122 123
123 DCHECK(listener_); 124 DCHECK(listener_);
124 DVLOG(1) << "NetworkLocationRequest::Run() : Calling listener with position."; 125 DVLOG(1) << "NetworkLocationRequest::Run() : Calling listener with position.";
125 listener_->LocationResponseAvailable(position, server_error, access_token, 126 listener_->LocationResponseAvailable(position, server_error, access_token,
126 radio_data_, wifi_data_); 127 radio_data_, wifi_data_);
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 position->longitude = longitude; 401 position->longitude = longitude;
401 position->timestamp = timestamp; 402 position->timestamp = timestamp;
402 403
403 // Other fields are optional. 404 // Other fields are optional.
404 GetAsDouble(*response_object, kAccuracyString, &position->accuracy); 405 GetAsDouble(*response_object, kAccuracyString, &position->accuracy);
405 406
406 return true; 407 return true;
407 } 408 }
408 409
409 } // namespace 410 } // namespace
OLDNEW
« no previous file with comments | « content/browser/geolocation/network_location_request.h ('k') | content/browser/speech/speech_recognition_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698