OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 void RecordUmaEvent(NetworkLocationRequestEvent event) { | 51 void RecordUmaEvent(NetworkLocationRequestEvent event) { |
52 UMA_HISTOGRAM_ENUMERATION("Geolocation.NetworkLocationRequest.Event", | 52 UMA_HISTOGRAM_ENUMERATION("Geolocation.NetworkLocationRequest.Event", |
53 event, NETWORK_LOCATION_REQUEST_EVENT_COUNT); | 53 event, NETWORK_LOCATION_REQUEST_EVENT_COUNT); |
54 } | 54 } |
55 | 55 |
56 void RecordUmaResponseCode(int code) { | 56 void RecordUmaResponseCode(int code) { |
57 UMA_HISTOGRAM_SPARSE_SLOWLY("Geolocation.NetworkLocationRequest.ResponseCode", | 57 UMA_HISTOGRAM_SPARSE_SLOWLY("Geolocation.NetworkLocationRequest.ResponseCode", |
58 code); | 58 code); |
59 } | 59 } |
60 | 60 |
| 61 void RecordUmaAccessPoints(int count) { |
| 62 const int min = 0; |
| 63 const int max = 10; |
| 64 const int buckets = 11; |
| 65 UMA_HISTOGRAM_CUSTOM_COUNTS("Geolocation.NetworkLocationRequest.AccessPoints", |
| 66 count, min, max, buckets); |
| 67 } |
| 68 |
61 // Local functions | 69 // Local functions |
62 // Creates the request url to send to the server. | 70 // Creates the request url to send to the server. |
63 GURL FormRequestURL(const GURL& url); | 71 GURL FormRequestURL(const GURL& url); |
64 | 72 |
65 void FormUploadData(const WifiData& wifi_data, | 73 void FormUploadData(const WifiData& wifi_data, |
66 const base::Time& timestamp, | 74 const base::Time& timestamp, |
67 const string16& access_token, | 75 const string16& access_token, |
68 std::string* upload_data); | 76 std::string* upload_data); |
69 | 77 |
70 // Attempts to extract a position from the response. Detects and indicates | 78 // Attempts to extract a position from the response. Detects and indicates |
(...skipping 29 matching lines...) Expand all Loading... |
100 url_(url) { | 108 url_(url) { |
101 } | 109 } |
102 | 110 |
103 NetworkLocationRequest::~NetworkLocationRequest() { | 111 NetworkLocationRequest::~NetworkLocationRequest() { |
104 } | 112 } |
105 | 113 |
106 bool NetworkLocationRequest::MakeRequest(const string16& access_token, | 114 bool NetworkLocationRequest::MakeRequest(const string16& access_token, |
107 const WifiData& wifi_data, | 115 const WifiData& wifi_data, |
108 const base::Time& timestamp) { | 116 const base::Time& timestamp) { |
109 RecordUmaEvent(NETWORK_LOCATION_REQUEST_EVENT_REQUEST_START); | 117 RecordUmaEvent(NETWORK_LOCATION_REQUEST_EVENT_REQUEST_START); |
| 118 RecordUmaAccessPoints(wifi_data.access_point_data.size()); |
110 if (url_fetcher_ != NULL) { | 119 if (url_fetcher_ != NULL) { |
111 DVLOG(1) << "NetworkLocationRequest : Cancelling pending request"; | 120 DVLOG(1) << "NetworkLocationRequest : Cancelling pending request"; |
112 RecordUmaEvent(NETWORK_LOCATION_REQUEST_EVENT_REQUEST_CANCEL); | 121 RecordUmaEvent(NETWORK_LOCATION_REQUEST_EVENT_REQUEST_CANCEL); |
113 url_fetcher_.reset(); | 122 url_fetcher_.reset(); |
114 } | 123 } |
115 wifi_data_ = wifi_data; | 124 wifi_data_ = wifi_data; |
116 timestamp_ = timestamp; | 125 timestamp_ = timestamp; |
117 | 126 |
118 GURL request_url = FormRequestURL(url_); | 127 GURL request_url = FormRequestURL(url_); |
119 url_fetcher_.reset(net::URLFetcher::Create( | 128 url_fetcher_.reset(net::URLFetcher::Create( |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 | 422 |
414 // Other fields are optional. | 423 // Other fields are optional. |
415 GetAsDouble(*response_object, kAccuracyString, &position->accuracy); | 424 GetAsDouble(*response_object, kAccuracyString, &position->accuracy); |
416 | 425 |
417 return true; | 426 return true; |
418 } | 427 } |
419 | 428 |
420 } // namespace | 429 } // namespace |
421 | 430 |
422 } // namespace content | 431 } // namespace content |
OLD | NEW |