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

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

Issue 2211473003: Remove calls to deprecated MessageLoop methods on Windows and Linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 3 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).
11 11
12 #include <cstdio> 12 #include <cstdio>
13 #include <cstdlib> 13 #include <cstdlib>
14 #include <memory> 14 #include <memory>
15 #include <string> 15 #include <string>
16 16
17 #include "base/at_exit.h" 17 #include "base/at_exit.h"
18 #include "base/command_line.h" 18 #include "base/command_line.h"
19 #include "base/compiler_specific.h" 19 #include "base/compiler_specific.h"
20 #include "base/format_macros.h" 20 #include "base/format_macros.h"
21 #include "base/i18n/time_formatting.h" 21 #include "base/i18n/time_formatting.h"
22 #include "base/json/json_writer.h" 22 #include "base/json/json_writer.h"
23 #include "base/logging.h" 23 #include "base/logging.h"
24 #include "base/macros.h" 24 #include "base/macros.h"
25 #include "base/memory/ptr_util.h" 25 #include "base/memory/ptr_util.h"
26 #include "base/memory/ref_counted.h" 26 #include "base/memory/ref_counted.h"
27 #include "base/message_loop/message_loop.h" 27 #include "base/message_loop/message_loop.h"
28 #include "base/run_loop.h"
28 #include "base/single_thread_task_runner.h" 29 #include "base/single_thread_task_runner.h"
29 #include "base/strings/string_number_conversions.h" 30 #include "base/strings/string_number_conversions.h"
30 #include "base/strings/utf_string_conversions.h" 31 #include "base/strings/utf_string_conversions.h"
31 #include "base/time/time.h" 32 #include "base/time/time.h"
32 #include "base/values.h" 33 #include "base/values.h"
33 #include "build/build_config.h" 34 #include "build/build_config.h"
34 #include "net/base/net_errors.h" 35 #include "net/base/net_errors.h"
35 #include "net/http/http_response_headers.h" 36 #include "net/http/http_response_headers.h"
36 #include "net/log/net_log.h" 37 #include "net/log/net_log.h"
37 #include "net/url_request/url_fetcher.h" 38 #include "net/url_request/url_fetcher.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 const base::Time start_time = base::Time::Now(); 246 const base::Time start_time = base::Time::Now();
246 const base::TimeTicks start_ticks = base::TimeTicks::Now(); 247 const base::TimeTicks start_ticks = base::TimeTicks::Now();
247 248
248 fetcher->Start(); 249 fetcher->Start();
249 std::printf( 250 std::printf(
250 "Request started at %s (ticks = %" PRId64 ")\n", 251 "Request started at %s (ticks = %" PRId64 ")\n",
251 UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime(start_time)).c_str(), 252 UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime(start_time)).c_str(),
252 start_ticks.ToInternalValue()); 253 start_ticks.ToInternalValue());
253 254
254 // |delegate| quits |main_loop| when the request is done. 255 // |delegate| quits |main_loop| when the request is done.
255 main_loop.Run(); 256 base::RunLoop().Run();
256 257
257 const base::Time end_time = base::Time::Now(); 258 const base::Time end_time = base::Time::Now();
258 const base::TimeTicks end_ticks = base::TimeTicks::Now(); 259 const base::TimeTicks end_ticks = base::TimeTicks::Now();
259 260
260 std::printf( 261 std::printf(
261 "Request ended at %s (ticks = %" PRId64 ")\n", 262 "Request ended at %s (ticks = %" PRId64 ")\n",
262 UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime(end_time)).c_str(), 263 UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime(end_time)).c_str(),
263 end_ticks.ToInternalValue()); 264 end_ticks.ToInternalValue());
264 265
265 const int64_t delta_ticks_internal = 266 const int64_t delta_ticks_internal =
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 &skew, &skew_uncertainty); 319 &skew, &skew_uncertainty);
319 320
320 std::printf( 321 std::printf(
321 "An estimate for the local clock skew is %.2f ms with " 322 "An estimate for the local clock skew is %.2f ms with "
322 "uncertainty %.2f ms\n", 323 "uncertainty %.2f ms\n",
323 skew.InMillisecondsF(), 324 skew.InMillisecondsF(),
324 skew_uncertainty.InMillisecondsF()); 325 skew_uncertainty.InMillisecondsF());
325 326
326 return EXIT_SUCCESS; 327 return EXIT_SUCCESS;
327 } 328 }
OLDNEW
« no previous file with comments | « net/test/spawned_test_server/spawner_communicator.cc ('k') | net/tools/net_watcher/net_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698