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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // The declaration order for net_log and printing_log_observer is | 223 // The declaration order for net_log and printing_log_observer is |
224 // important. The destructor of PrintingLogObserver removes itself | 224 // important. The destructor of PrintingLogObserver removes itself |
225 // from net_log, so net_log must be available for entire lifetime of | 225 // from net_log, so net_log must be available for entire lifetime of |
226 // printing_log_observer. | 226 // printing_log_observer. |
227 net::NetLog net_log; | 227 net::NetLog net_log; |
228 PrintingLogObserver printing_log_observer; | 228 PrintingLogObserver printing_log_observer; |
229 net_log.DeprecatedAddObserver(&printing_log_observer, | 229 net_log.DeprecatedAddObserver(&printing_log_observer, |
230 net::NetLogCaptureMode::IncludeSocketBytes()); | 230 net::NetLogCaptureMode::IncludeSocketBytes()); |
231 | 231 |
232 QuitDelegate delegate; | 232 QuitDelegate delegate; |
233 scoped_ptr<net::URLFetcher> fetcher( | 233 scoped_ptr<net::URLFetcher> fetcher = |
234 net::URLFetcher::Create(url, net::URLFetcher::HEAD, &delegate)); | 234 net::URLFetcher::Create(url, net::URLFetcher::HEAD, &delegate); |
235 scoped_ptr<net::URLRequestContext> url_request_context( | 235 scoped_ptr<net::URLRequestContext> url_request_context( |
236 BuildURLRequestContext(&net_log)); | 236 BuildURLRequestContext(&net_log)); |
237 fetcher->SetRequestContext( | 237 fetcher->SetRequestContext( |
238 // Since there's only a single thread, there's no need to worry | 238 // Since there's only a single thread, there's no need to worry |
239 // about when the URLRequestContext gets created. | 239 // about when the URLRequestContext gets created. |
240 // The URLFetcher will take a reference on the object, and hence | 240 // The URLFetcher will take a reference on the object, and hence |
241 // implicitly take ownership. | 241 // implicitly take ownership. |
242 new net::TrivialURLRequestContextGetter(url_request_context.get(), | 242 new net::TrivialURLRequestContextGetter(url_request_context.get(), |
243 main_loop.message_loop_proxy())); | 243 main_loop.message_loop_proxy())); |
244 const base::Time start_time = base::Time::Now(); | 244 const base::Time start_time = base::Time::Now(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 &skew, &skew_uncertainty); | 317 &skew, &skew_uncertainty); |
318 | 318 |
319 std::printf( | 319 std::printf( |
320 "An estimate for the local clock skew is %.2f ms with " | 320 "An estimate for the local clock skew is %.2f ms with " |
321 "uncertainty %.2f ms\n", | 321 "uncertainty %.2f ms\n", |
322 skew.InMillisecondsF(), | 322 skew.InMillisecondsF(), |
323 skew_uncertainty.InMillisecondsF()); | 323 skew_uncertainty.InMillisecondsF()); |
324 | 324 |
325 return EXIT_SUCCESS; | 325 return EXIT_SUCCESS; |
326 } | 326 } |
OLD | NEW |