| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 // Simply quits the current message loop when finished. Used to make | 69 // Simply quits the current message loop when finished. Used to make |
| 70 // URLFetcher synchronous. | 70 // URLFetcher synchronous. |
| 71 class QuitDelegate : public net::URLFetcherDelegate { | 71 class QuitDelegate : public net::URLFetcherDelegate { |
| 72 public: | 72 public: |
| 73 QuitDelegate() {} | 73 QuitDelegate() {} |
| 74 | 74 |
| 75 virtual ~QuitDelegate() {} | 75 virtual ~QuitDelegate() {} |
| 76 | 76 |
| 77 // net::URLFetcherDelegate implementation. | 77 // net::URLFetcherDelegate implementation. |
| 78 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE { | 78 virtual void OnURLFetchComplete(const net::URLFetcher* source) override { |
| 79 base::MessageLoop::current()->Quit(); | 79 base::MessageLoop::current()->Quit(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 virtual void OnURLFetchDownloadProgress( | 82 virtual void OnURLFetchDownloadProgress( |
| 83 const net::URLFetcher* source, | 83 const net::URLFetcher* source, |
| 84 int64 current, int64 total) OVERRIDE { | 84 int64 current, int64 total) override { |
| 85 NOTREACHED(); | 85 NOTREACHED(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 virtual void OnURLFetchUploadProgress(const net::URLFetcher* source, | 88 virtual void OnURLFetchUploadProgress(const net::URLFetcher* source, |
| 89 int64 current, int64 total) OVERRIDE { | 89 int64 current, int64 total) override { |
| 90 NOTREACHED(); | 90 NOTREACHED(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 private: | 93 private: |
| 94 DISALLOW_COPY_AND_ASSIGN(QuitDelegate); | 94 DISALLOW_COPY_AND_ASSIGN(QuitDelegate); |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 // NetLog::ThreadSafeObserver implementation that simply prints events | 97 // NetLog::ThreadSafeObserver implementation that simply prints events |
| 98 // to the logs. | 98 // to the logs. |
| 99 class PrintingLogObserver : public net::NetLog::ThreadSafeObserver { | 99 class PrintingLogObserver : public net::NetLog::ThreadSafeObserver { |
| 100 public: | 100 public: |
| 101 PrintingLogObserver() {} | 101 PrintingLogObserver() {} |
| 102 | 102 |
| 103 virtual ~PrintingLogObserver() { | 103 virtual ~PrintingLogObserver() { |
| 104 // This is guaranteed to be safe as this program is single threaded. | 104 // This is guaranteed to be safe as this program is single threaded. |
| 105 net_log()->RemoveThreadSafeObserver(this); | 105 net_log()->RemoveThreadSafeObserver(this); |
| 106 } | 106 } |
| 107 | 107 |
| 108 // NetLog::ThreadSafeObserver implementation: | 108 // NetLog::ThreadSafeObserver implementation: |
| 109 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE { | 109 virtual void OnAddEntry(const net::NetLog::Entry& entry) override { |
| 110 // The log level of the entry is unknown, so just assume it maps | 110 // The log level of the entry is unknown, so just assume it maps |
| 111 // to VLOG(1). | 111 // to VLOG(1). |
| 112 if (!VLOG_IS_ON(1)) | 112 if (!VLOG_IS_ON(1)) |
| 113 return; | 113 return; |
| 114 | 114 |
| 115 const char* const source_type = | 115 const char* const source_type = |
| 116 net::NetLog::SourceTypeToString(entry.source().type); | 116 net::NetLog::SourceTypeToString(entry.source().type); |
| 117 const char* const event_type = | 117 const char* const event_type = |
| 118 net::NetLog::EventTypeToString(entry.type()); | 118 net::NetLog::EventTypeToString(entry.type()); |
| 119 const char* const event_phase = | 119 const char* const event_phase = |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 &skew, &skew_uncertainty); | 315 &skew, &skew_uncertainty); |
| 316 | 316 |
| 317 std::printf( | 317 std::printf( |
| 318 "An estimate for the local clock skew is %.2f ms with " | 318 "An estimate for the local clock skew is %.2f ms with " |
| 319 "uncertainty %.2f ms\n", | 319 "uncertainty %.2f ms\n", |
| 320 skew.InMillisecondsF(), | 320 skew.InMillisecondsF(), |
| 321 skew_uncertainty.InMillisecondsF()); | 321 skew_uncertainty.InMillisecondsF()); |
| 322 | 322 |
| 323 return EXIT_SUCCESS; | 323 return EXIT_SUCCESS; |
| 324 } | 324 } |
| OLD | NEW |