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

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: Tweaks to compile. 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
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..72637aa91c0dbd8e13e0a082b8331d307cf4a1d8 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,17 @@ 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());
-
+ 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(BuildURLRequestContext(&net_log),
+ main_loop.message_loop_proxy()));
const base::Time start_time = base::Time::Now();
const base::TimeTicks start_ticks = base::TimeTicks::Now();

Powered by Google App Engine
This is Rietveld 408576698