| 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 // This is a small utility that snarfs the server time from the | 5 // This is a small utility that snarfs the server time from the |
| 6 // response headers of an http/https HEAD request and compares it to | 6 // response headers of an http/https HEAD request and compares it to |
| 7 // the local time. | 7 // the local time. |
| 8 // | 8 // |
| 9 // TODO(akalin): Also snarf the server time from the TLS handshake, if | 9 // TODO(akalin): Also snarf the server time from the TLS handshake, if |
| 10 // any (http://crbug.com/146090). | 10 // any (http://crbug.com/146090). |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "net/url_request/url_request_status.h" | 41 #include "net/url_request/url_request_status.h" |
| 42 #include "url/gurl.h" | 42 #include "url/gurl.h" |
| 43 | 43 |
| 44 #if defined(OS_MACOSX) | 44 #if defined(OS_MACOSX) |
| 45 #include "base/mac/scoped_nsautorelease_pool.h" | 45 #include "base/mac/scoped_nsautorelease_pool.h" |
| 46 #elif defined(OS_LINUX) | 46 #elif defined(OS_LINUX) |
| 47 #include "net/proxy/proxy_config.h" | 47 #include "net/proxy/proxy_config.h" |
| 48 #include "net/proxy/proxy_config_service_fixed.h" | 48 #include "net/proxy/proxy_config_service_fixed.h" |
| 49 #endif | 49 #endif |
| 50 | 50 |
| 51 using base::UTF16ToUTF8; |
| 52 |
| 51 namespace { | 53 namespace { |
| 52 | 54 |
| 53 // base::TimeTicks::Now() is documented to have a resolution of | 55 // base::TimeTicks::Now() is documented to have a resolution of |
| 54 // ~1-15ms. | 56 // ~1-15ms. |
| 55 const int64 kTicksResolutionMs = 15; | 57 const int64 kTicksResolutionMs = 15; |
| 56 | 58 |
| 57 // For the sources that are supported (HTTP date headers, TLS | 59 // For the sources that are supported (HTTP date headers, TLS |
| 58 // handshake), the resolution of the server time is 1 second. | 60 // handshake), the resolution of the server time is 1 second. |
| 59 const int64 kServerTimeResolutionMs = 1000; | 61 const int64 kServerTimeResolutionMs = 1000; |
| 60 | 62 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 &skew, &skew_uncertainty); | 336 &skew, &skew_uncertainty); |
| 335 | 337 |
| 336 std::printf( | 338 std::printf( |
| 337 "An estimate for the local clock skew is %.2f ms with " | 339 "An estimate for the local clock skew is %.2f ms with " |
| 338 "uncertainty %.2f ms\n", | 340 "uncertainty %.2f ms\n", |
| 339 skew.InMillisecondsF(), | 341 skew.InMillisecondsF(), |
| 340 skew_uncertainty.InMillisecondsF()); | 342 skew_uncertainty.InMillisecondsF()); |
| 341 | 343 |
| 342 return EXIT_SUCCESS; | 344 return EXIT_SUCCESS; |
| 343 } | 345 } |
| OLD | NEW |