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

Side by Side Diff: mojo/services/network/url_loader_impl_apptest.cc

Issue 1295523006: Using scoped_ptr for URLRequestJobFactoryImpl::SetProtocolHandler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing un-modified file Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/lazy_instance.h" 6 #include "base/lazy_instance.h"
7 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "mojo/application/public/cpp/application_test_base.h" 10 #include "mojo/application/public/cpp/application_test_base.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 }; 86 };
87 87
88 class TestProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler { 88 class TestProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler {
89 public: 89 public:
90 net::URLRequestJob* MaybeCreateJob( 90 net::URLRequestJob* MaybeCreateJob(
91 net::URLRequest* request, 91 net::URLRequest* request,
92 net::NetworkDelegate* network_delegate) const override { 92 net::NetworkDelegate* network_delegate) const override {
93 return new TestURLRequestJob(request, network_delegate); 93 return new TestURLRequestJob(request, network_delegate);
94 } 94 }
95 95
96 private:
97 ~TestProtocolHandler() override {} 96 ~TestProtocolHandler() override {}
98 }; 97 };
99 98
100 class UrlLoaderImplTest : public test::ApplicationTestBase { 99 class UrlLoaderImplTest : public test::ApplicationTestBase {
101 public: 100 public:
102 UrlLoaderImplTest() : message_loop_(common::MessagePumpMojo::Create()) {} 101 UrlLoaderImplTest() : message_loop_(common::MessagePumpMojo::Create()) {}
103 102
104 protected: 103 protected:
105 bool ShouldCreateDefaultRunLoop() override { 104 bool ShouldCreateDefaultRunLoop() override {
106 return false; 105 return false;
107 } 106 }
108 107
109 void SetUp() override { 108 void SetUp() override {
110 ApplicationTestBase::SetUp(); 109 ApplicationTestBase::SetUp();
111 110
112 scoped_ptr<net::TestURLRequestContext> url_request_context( 111 scoped_ptr<net::TestURLRequestContext> url_request_context(
113 new net::TestURLRequestContext(true)); 112 new net::TestURLRequestContext(true));
114 ASSERT_TRUE(url_request_job_factory_.SetProtocolHandler( 113 ASSERT_TRUE(url_request_job_factory_.SetProtocolHandler(
115 "http", new TestProtocolHandler())); 114 "http", make_scoped_ptr(new TestProtocolHandler())));
116 url_request_context->set_job_factory(&url_request_job_factory_); 115 url_request_context->set_job_factory(&url_request_job_factory_);
117 url_request_context->Init(); 116 url_request_context->Init();
118 network_context_.reset(new NetworkContext(url_request_context.Pass())); 117 network_context_.reset(new NetworkContext(url_request_context.Pass()));
119 MessagePipe pipe; 118 MessagePipe pipe;
120 new URLLoaderImpl(network_context_.get(), 119 new URLLoaderImpl(network_context_.get(),
121 GetProxy(&url_loader_proxy_), 120 GetProxy(&url_loader_proxy_),
122 make_scoped_ptr<mojo::AppRefCount>(nullptr)); 121 make_scoped_ptr<mojo::AppRefCount>(nullptr));
123 EXPECT_TRUE(IsUrlLoaderValid()); 122 EXPECT_TRUE(IsUrlLoaderValid());
124 } 123 }
125 124
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 265
267 EXPECT_TRUE(IsUrlLoaderValid()); 266 EXPECT_TRUE(IsUrlLoaderValid());
268 267
269 g_current_job->NotifyReadComplete(-1); 268 g_current_job->NotifyReadComplete(-1);
270 base::RunLoop().RunUntilIdle(); 269 base::RunLoop().RunUntilIdle();
271 270
272 EXPECT_FALSE(IsUrlLoaderValid()); 271 EXPECT_FALSE(IsUrlLoaderValid());
273 } 272 }
274 273
275 } // namespace mojo 274 } // namespace mojo
OLDNEW
« no previous file with comments | « ios/web/webui/url_data_manager_ios_backend.cc ('k') | net/proxy/proxy_script_fetcher_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698