Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: net/tools/get_server_time/get_server_time.cc

Issue 2333923004: Extracting NetLog inner classes into their own classes. (Closed)
Patch Set: Some nit fixes and better, impl-agnostic naming of net_log_parameters_callback_typedef.h -> net/log… Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 17 matching lines...) Expand all
28 #include "base/run_loop.h" 28 #include "base/run_loop.h"
29 #include "base/single_thread_task_runner.h" 29 #include "base/single_thread_task_runner.h"
30 #include "base/strings/string_number_conversions.h" 30 #include "base/strings/string_number_conversions.h"
31 #include "base/strings/utf_string_conversions.h" 31 #include "base/strings/utf_string_conversions.h"
32 #include "base/time/time.h" 32 #include "base/time/time.h"
33 #include "base/values.h" 33 #include "base/values.h"
34 #include "build/build_config.h" 34 #include "build/build_config.h"
35 #include "net/base/net_errors.h" 35 #include "net/base/net_errors.h"
36 #include "net/http/http_response_headers.h" 36 #include "net/http/http_response_headers.h"
37 #include "net/log/net_log.h" 37 #include "net/log/net_log.h"
38 #include "net/log/net_log_entry.h"
38 #include "net/url_request/url_fetcher.h" 39 #include "net/url_request/url_fetcher.h"
39 #include "net/url_request/url_fetcher_delegate.h" 40 #include "net/url_request/url_fetcher_delegate.h"
40 #include "net/url_request/url_request_context.h" 41 #include "net/url_request/url_request_context.h"
41 #include "net/url_request/url_request_context_builder.h" 42 #include "net/url_request/url_request_context_builder.h"
42 #include "net/url_request/url_request_context_getter.h" 43 #include "net/url_request/url_request_context_getter.h"
43 #include "net/url_request/url_request_status.h" 44 #include "net/url_request/url_request_status.h"
44 #include "url/gurl.h" 45 #include "url/gurl.h"
45 46
46 #if defined(OS_MACOSX) 47 #if defined(OS_MACOSX)
47 #include "base/mac/scoped_nsautorelease_pool.h" 48 #include "base/mac/scoped_nsautorelease_pool.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 class PrintingLogObserver : public net::NetLog::ThreadSafeObserver { 104 class PrintingLogObserver : public net::NetLog::ThreadSafeObserver {
104 public: 105 public:
105 PrintingLogObserver() {} 106 PrintingLogObserver() {}
106 107
107 ~PrintingLogObserver() override { 108 ~PrintingLogObserver() override {
108 // This is guaranteed to be safe as this program is single threaded. 109 // This is guaranteed to be safe as this program is single threaded.
109 net_log()->DeprecatedRemoveObserver(this); 110 net_log()->DeprecatedRemoveObserver(this);
110 } 111 }
111 112
112 // NetLog::ThreadSafeObserver implementation: 113 // NetLog::ThreadSafeObserver implementation:
113 void OnAddEntry(const net::NetLog::Entry& entry) override { 114 void OnAddEntry(const net::NetLogEntry& entry) override {
114 // The log level of the entry is unknown, so just assume it maps 115 // The log level of the entry is unknown, so just assume it maps
115 // to VLOG(1). 116 // to VLOG(1).
116 if (!VLOG_IS_ON(1)) 117 if (!VLOG_IS_ON(1))
117 return; 118 return;
118 119
119 const char* const source_type = 120 const char* const source_type =
120 net::NetLog::SourceTypeToString(entry.source().type); 121 net::NetLog::SourceTypeToString(entry.source().type);
121 const char* const event_type = 122 const char* const event_type =
122 net::NetLog::EventTypeToString(entry.type()); 123 net::NetLog::EventTypeToString(entry.type());
123 const char* const event_phase = 124 const char* const event_phase =
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 &skew, &skew_uncertainty); 321 &skew, &skew_uncertainty);
321 322
322 std::printf( 323 std::printf(
323 "An estimate for the local clock skew is %.2f ms with " 324 "An estimate for the local clock skew is %.2f ms with "
324 "uncertainty %.2f ms\n", 325 "uncertainty %.2f ms\n",
325 skew.InMillisecondsF(), 326 skew.InMillisecondsF(),
326 skew_uncertainty.InMillisecondsF()); 327 skew_uncertainty.InMillisecondsF());
327 328
328 return EXIT_SUCCESS; 329 return EXIT_SUCCESS;
329 } 330 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698