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

Side by Side Diff: content/browser/geolocation/network_location_request.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: sync and remove unncessary forward declares Created 9 years, 1 month 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"
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "content/common/geoposition.h" 14 #include "content/common/geoposition.h"
15 #include "content/common/net/url_fetcher.h"
15 #include "net/base/escape.h" 16 #include "net/base/escape.h"
16 #include "net/base/load_flags.h" 17 #include "net/base/load_flags.h"
17 #include "net/url_request/url_request_context_getter.h" 18 #include "net/url_request/url_request_context_getter.h"
18 #include "net/url_request/url_request_status.h" 19 #include "net/url_request/url_request_status.h"
19 20
20 namespace { 21 namespace {
21 22
22 const size_t kMaxRequestLength = 2048; 23 const size_t kMaxRequestLength = 2048;
23 24
24 const char kAccessTokenString[] = "access_token"; 25 const char kAccessTokenString[] = "access_token";
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 100 }
100 101
101 void NetworkLocationRequest::OnURLFetchComplete(const URLFetcher* source) { 102 void NetworkLocationRequest::OnURLFetchComplete(const URLFetcher* source) {
102 DCHECK_EQ(url_fetcher_.get(), source); 103 DCHECK_EQ(url_fetcher_.get(), source);
103 104
104 net::URLRequestStatus status = source->status(); 105 net::URLRequestStatus status = source->status();
105 int response_code = source->response_code(); 106 int response_code = source->response_code();
106 107
107 Geoposition position; 108 Geoposition position;
108 string16 access_token; 109 string16 access_token;
110 std::string data;
111 source->GetResponseAsString(&data);
109 GetLocationFromResponse(status.is_success(), 112 GetLocationFromResponse(status.is_success(),
110 response_code, 113 response_code,
111 source->GetResponseStringRef(), 114 data,
112 timestamp_, 115 timestamp_,
113 source->url(), 116 source->url(),
114 &position, 117 &position,
115 &access_token); 118 &access_token);
116 const bool server_error = 119 const bool server_error =
117 !status.is_success() || (response_code >= 500 && response_code < 600); 120 !status.is_success() || (response_code >= 500 && response_code < 600);
118 url_fetcher_.reset(); 121 url_fetcher_.reset();
119 122
120 DCHECK(listener_); 123 DCHECK(listener_);
121 DVLOG(1) << "NetworkLocationRequest::Run() : Calling listener with position."; 124 DVLOG(1) << "NetworkLocationRequest::Run() : Calling listener with position.";
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 position->longitude = longitude; 400 position->longitude = longitude;
398 position->timestamp = timestamp; 401 position->timestamp = timestamp;
399 402
400 // Other fields are optional. 403 // Other fields are optional.
401 GetAsDouble(*response_object, kAccuracyString, &position->accuracy); 404 GetAsDouble(*response_object, kAccuracyString, &position->accuracy);
402 405
403 return true; 406 return true;
404 } 407 }
405 408
406 } // namespace 409 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698