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

Unified Diff: net/tools/get_server_time/get_server_time.cc

Issue 292063002: Create a TrivialURLRequestContextGetter to shim an existing URLRequestContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync'd up to r272911 Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/domain_reliability/monitor.cc ('k') | net/url_request/url_request_context_getter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/get_server_time/get_server_time.cc
diff --git a/net/tools/get_server_time/get_server_time.cc b/net/tools/get_server_time/get_server_time.cc
index f7c33f513ba83bab7bce7cc0ad107b0e57000211..9f081575f4e5eda6e38ea0f5aff3bb5963001f36 100644
--- a/net/tools/get_server_time/get_server_time.cc
+++ b/net/tools/get_server_time/get_server_time.cc
@@ -150,32 +150,6 @@ BuildURLRequestContext(net::NetLog* net_log) {
return context.Pass();
}
-class SingleThreadRequestContextGetter : public net::URLRequestContextGetter {
- public:
- // Since there's only a single thread, there's no need to worry
- // about when |context_| gets created.
- SingleThreadRequestContextGetter(
- net::NetLog* net_log,
- const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner)
- : context_(BuildURLRequestContext(net_log)),
- main_task_runner_(main_task_runner) {}
-
- virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE {
- return context_.get();
- }
-
- virtual scoped_refptr<base::SingleThreadTaskRunner>
- GetNetworkTaskRunner() const OVERRIDE {
- return main_task_runner_;
- }
-
- private:
- virtual ~SingleThreadRequestContextGetter() {}
-
- const scoped_ptr<net::URLRequestContext> context_;
- const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
-};
-
// Assuming that the time |server_time| was received from a server,
// that the request for the server was started on |start_ticks|, and
// that it ended on |end_ticks|, fills |server_now| with an estimate
@@ -251,15 +225,19 @@ int main(int argc, char* argv[]) {
net::NetLog net_log;
PrintingLogObserver printing_log_observer;
net_log.AddThreadSafeObserver(&printing_log_observer, net::NetLog::LOG_ALL);
- scoped_refptr<SingleThreadRequestContextGetter> context_getter(
- new SingleThreadRequestContextGetter(&net_log,
- main_loop.message_loop_proxy()));
QuitDelegate delegate;
scoped_ptr<net::URLFetcher> fetcher(
net::URLFetcher::Create(url, net::URLFetcher::HEAD, &delegate));
- fetcher->SetRequestContext(context_getter.get());
-
+ scoped_ptr<net::URLRequestContext> url_request_context(
+ BuildURLRequestContext(&net_log));
+ fetcher->SetRequestContext(
+ // Since there's only a single thread, there's no need to worry
+ // about when the URLRequestContext gets created.
+ // The URLFetcher will take a reference on the object, and hence
+ // implicitly take ownership.
+ new net::TrivialURLRequestContextGetter(url_request_context.get(),
+ main_loop.message_loop_proxy()));
const base::Time start_time = base::Time::Now();
const base::TimeTicks start_ticks = base::TimeTicks::Now();
« no previous file with comments | « components/domain_reliability/monitor.cc ('k') | net/url_request/url_request_context_getter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698