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

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

Issue 22795006: Remove WorkerPool dependency from URLRequestFileJob. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix android include Created 7 years, 4 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 | Annotate | Revision Log
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 <string> 14 #include <string>
15 15
16 #include "base/at_exit.h" 16 #include "base/at_exit.h"
17 #include "base/basictypes.h" 17 #include "base/basictypes.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/memory/ref_counted.h" 24 #include "base/memory/ref_counted.h"
25 #include "base/memory/scoped_ptr.h" 25 #include "base/memory/scoped_ptr.h"
26 #include "base/message_loop/message_loop.h" 26 #include "base/message_loop/message_loop.h"
27 #include "base/single_thread_task_runner.h" 27 #include "base/single_thread_task_runner.h"
28 #include "base/strings/string_number_conversions.h" 28 #include "base/strings/string_number_conversions.h"
29 #include "base/strings/utf_string_conversions.h" 29 #include "base/strings/utf_string_conversions.h"
30 #include "base/threading/worker_pool.h"
30 #include "base/time/time.h" 31 #include "base/time/time.h"
31 #include "base/values.h" 32 #include "base/values.h"
32 #include "build/build_config.h" 33 #include "build/build_config.h"
33 #include "net/base/net_errors.h" 34 #include "net/base/net_errors.h"
34 #include "net/base/net_log.h" 35 #include "net/base/net_log.h"
35 #include "net/http/http_response_headers.h" 36 #include "net/http/http_response_headers.h"
36 #include "net/url_request/url_fetcher.h" 37 #include "net/url_request/url_fetcher.h"
37 #include "net/url_request/url_fetcher_delegate.h" 38 #include "net/url_request/url_fetcher_delegate.h"
38 #include "net/url_request/url_request_context.h" 39 #include "net/url_request/url_request_context.h"
39 #include "net/url_request/url_request_context_builder.h" 40 #include "net/url_request/url_request_context_builder.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 << event_type << ": " << event_phase << params_str; 139 << event_type << ": " << event_phase << params_str;
139 } 140 }
140 141
141 private: 142 private:
142 DISALLOW_COPY_AND_ASSIGN(PrintingLogObserver); 143 DISALLOW_COPY_AND_ASSIGN(PrintingLogObserver);
143 }; 144 };
144 145
145 // Builds a URLRequestContext assuming there's only a single loop. 146 // Builds a URLRequestContext assuming there's only a single loop.
146 scoped_ptr<net::URLRequestContext> 147 scoped_ptr<net::URLRequestContext>
147 BuildURLRequestContext(net::NetLog* net_log) { 148 BuildURLRequestContext(net::NetLog* net_log) {
148 net::URLRequestContextBuilder builder; 149 net::URLRequestContextBuilder builder(
150 base::WorkerPool::GetTaskRunner(true /* task_is_slow */));
149 #if defined(OS_LINUX) 151 #if defined(OS_LINUX)
150 // On Linux, use a fixed ProxyConfigService, since the default one 152 // On Linux, use a fixed ProxyConfigService, since the default one
151 // depends on glib. 153 // depends on glib.
152 // 154 //
153 // TODO(akalin): Remove this once http://crbug.com/146421 is fixed. 155 // TODO(akalin): Remove this once http://crbug.com/146421 is fixed.
154 builder.set_proxy_config_service( 156 builder.set_proxy_config_service(
155 new net::ProxyConfigServiceFixed(net::ProxyConfig())); 157 new net::ProxyConfigServiceFixed(net::ProxyConfig()));
156 #endif 158 #endif
157 scoped_ptr<net::URLRequestContext> context(builder.Build()); 159 scoped_ptr<net::URLRequestContext> context(builder.Build());
158 context->set_net_log(net_log); 160 context->set_net_log(net_log);
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 &skew, &skew_uncertainty); 347 &skew, &skew_uncertainty);
346 348
347 std::printf( 349 std::printf(
348 "An estimate for the local clock skew is %.2f ms with " 350 "An estimate for the local clock skew is %.2f ms with "
349 "uncertainty %.2f ms\n", 351 "uncertainty %.2f ms\n",
350 skew.InMillisecondsF(), 352 skew.InMillisecondsF(),
351 skew_uncertainty.InMillisecondsF()); 353 skew_uncertainty.InMillisecondsF());
352 354
353 return EXIT_SUCCESS; 355 return EXIT_SUCCESS;
354 } 356 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698