OLD | NEW |
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 #ifndef CHROME_BROWSER_NET_NETWORK_STATS_H_ | 5 #ifndef CHROME_BROWSER_NET_NETWORK_STATS_H_ |
6 #define CHROME_BROWSER_NET_NETWORK_STATS_H_ | 6 #define CHROME_BROWSER_NET_NETWORK_STATS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 UDPStatsClient(); | 202 UDPStatsClient(); |
203 virtual ~UDPStatsClient(); | 203 virtual ~UDPStatsClient(); |
204 | 204 |
205 protected: | 205 protected: |
206 // Allow tests to access our innards for testing purposes. | 206 // Allow tests to access our innards for testing purposes. |
207 friend class NetworkStatsTestUDP; | 207 friend class NetworkStatsTestUDP; |
208 | 208 |
209 // Called after host is resolved. Creates UDClientSocket and connects to the | 209 // Called after host is resolved. Creates UDClientSocket and connects to the |
210 // server. If successfully connected, then calls ConnectComplete() to start | 210 // server. If successfully connected, then calls ConnectComplete() to start |
211 // the echo protocol. Returns |false| if there is any error. | 211 // the echo protocol. Returns |false| if there is any error. |
212 virtual bool DoConnect(int result); | 212 virtual bool DoConnect(int result) OVERRIDE; |
213 | 213 |
214 // This method calls NetworkStats::ReadComplete() to verify the data and calls | 214 // This method calls NetworkStats::ReadComplete() to verify the data and calls |
215 // Finish() if there is an error or if read callback didn't return any data | 215 // Finish() if there is an error or if read callback didn't return any data |
216 // (|result| is less than or equal to 0). | 216 // (|result| is less than or equal to 0). |
217 virtual bool ReadComplete(int result); | 217 virtual bool ReadComplete(int result) OVERRIDE; |
218 | 218 |
219 // Collects stats for UDP connectivity. This is called when all the data from | 219 // Collects stats for UDP connectivity. This is called when all the data from |
220 // server is read or when there is a failure during connect/read/write. | 220 // server is read or when there is a failure during connect/read/write. |
221 virtual void Finish(Status status, int result); | 221 virtual void Finish(Status status, int result) OVERRIDE; |
222 }; | 222 }; |
223 | 223 |
224 class TCPStatsClient : public NetworkStats { | 224 class TCPStatsClient : public NetworkStats { |
225 public: | 225 public: |
226 // Constructs a TCPStatsClient object that collects metrics for TCP | 226 // Constructs a TCPStatsClient object that collects metrics for TCP |
227 // connectivity. | 227 // connectivity. |
228 TCPStatsClient(); | 228 TCPStatsClient(); |
229 virtual ~TCPStatsClient(); | 229 virtual ~TCPStatsClient(); |
230 | 230 |
231 protected: | 231 protected: |
232 // Allow tests to access our innards for testing purposes. | 232 // Allow tests to access our innards for testing purposes. |
233 friend class NetworkStatsTestTCP; | 233 friend class NetworkStatsTestTCP; |
234 | 234 |
235 // Called after host is resolved. Creates TCPClientSocket and connects to the | 235 // Called after host is resolved. Creates TCPClientSocket and connects to the |
236 // server. | 236 // server. |
237 virtual bool DoConnect(int result); | 237 virtual bool DoConnect(int result) OVERRIDE; |
238 | 238 |
239 // This method calls NetworkStats::ReadComplete() to verify the data and calls | 239 // This method calls NetworkStats::ReadComplete() to verify the data and calls |
240 // Finish() if there is an error (|result| is less than 0). | 240 // Finish() if there is an error (|result| is less than 0). |
241 virtual bool ReadComplete(int result); | 241 virtual bool ReadComplete(int result) OVERRIDE; |
242 | 242 |
243 // Collects stats for TCP connectivity. This is called when all the data from | 243 // Collects stats for TCP connectivity. This is called when all the data from |
244 // server is read or when there is a failure during connect/read/write. | 244 // server is read or when there is a failure during connect/read/write. |
245 virtual void Finish(Status status, int result); | 245 virtual void Finish(Status status, int result) OVERRIDE; |
246 | 246 |
247 private: | 247 private: |
248 // Callback that is called when connect is completed and calls | 248 // Callback that is called when connect is completed and calls |
249 // ConnectComplete() to start the echo protocol. | 249 // ConnectComplete() to start the echo protocol. |
250 void OnConnectComplete(int result); | 250 void OnConnectComplete(int result); |
251 | 251 |
252 // Callback to call when connect is completed. | 252 // Callback to call when connect is completed. |
253 net::OldCompletionCallbackImpl<TCPStatsClient> connect_callback_; | 253 net::OldCompletionCallbackImpl<TCPStatsClient> connect_callback_; |
254 }; | 254 }; |
255 | 255 |
256 // This collects the network connectivity stats for UDP and TCP for small | 256 // This collects the network connectivity stats for UDP and TCP for small |
257 // percentage of users who are participating in the experiment. All users must | 257 // percentage of users who are participating in the experiment. All users must |
258 // have enabled "UMA upload". This method gets called only if UMA upload to the | 258 // have enabled "UMA upload". This method gets called only if UMA upload to the |
259 // server has succeeded. | 259 // server has succeeded. |
260 void CollectNetworkStats(const std::string& network_stats_server_url, | 260 void CollectNetworkStats(const std::string& network_stats_server_url, |
261 IOThread* io_thread); | 261 IOThread* io_thread); |
262 | 262 |
263 } // namespace chrome_browser_net | 263 } // namespace chrome_browser_net |
264 | 264 |
265 #endif // CHROME_BROWSER_NET_NETWORK_STATS_H_ | 265 #endif // CHROME_BROWSER_NET_NETWORK_STATS_H_ |
OLD | NEW |