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

Side by Side Diff: net/proxy/multi_threaded_proxy_resolver_unittest.cc

Issue 1545233002: Convert Pass()→std::move() in //net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
« no previous file with comments | « net/proxy/multi_threaded_proxy_resolver.cc ('k') | net/proxy/proxy_config.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "net/proxy/multi_threaded_proxy_resolver.h" 5 #include "net/proxy/multi_threaded_proxy_resolver.h"
6 6
7 #include <utility>
7 #include <vector> 8 #include <vector>
8 9
9 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 11 #include "base/run_loop.h"
11 #include "base/stl_util.h" 12 #include "base/stl_util.h"
12 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
13 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
14 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
15 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
16 #include "base/synchronization/waitable_event.h" 17 #include "base/synchronization/waitable_event.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 base::Lock lock_; 173 base::Lock lock_;
173 }; 174 };
174 175
175 class SingleShotMultiThreadedProxyResolverFactory 176 class SingleShotMultiThreadedProxyResolverFactory
176 : public MultiThreadedProxyResolverFactory { 177 : public MultiThreadedProxyResolverFactory {
177 public: 178 public:
178 SingleShotMultiThreadedProxyResolverFactory( 179 SingleShotMultiThreadedProxyResolverFactory(
179 size_t max_num_threads, 180 size_t max_num_threads,
180 scoped_ptr<ProxyResolverFactory> factory) 181 scoped_ptr<ProxyResolverFactory> factory)
181 : MultiThreadedProxyResolverFactory(max_num_threads, false), 182 : MultiThreadedProxyResolverFactory(max_num_threads, false),
182 factory_(factory.Pass()) {} 183 factory_(std::move(factory)) {}
183 184
184 scoped_ptr<ProxyResolverFactory> CreateProxyResolverFactory() override { 185 scoped_ptr<ProxyResolverFactory> CreateProxyResolverFactory() override {
185 DCHECK(factory_); 186 DCHECK(factory_);
186 return factory_.Pass(); 187 return std::move(factory_);
187 } 188 }
188 189
189 private: 190 private:
190 scoped_ptr<ProxyResolverFactory> factory_; 191 scoped_ptr<ProxyResolverFactory> factory_;
191 }; 192 };
192 193
193 class MultiThreadedProxyResolverTest : public testing::Test { 194 class MultiThreadedProxyResolverTest : public testing::Test {
194 public: 195 public:
195 void Init(size_t num_threads) { 196 void Init(size_t num_threads) {
196 scoped_ptr<BlockableProxyResolverFactory> factory_owner( 197 scoped_ptr<BlockableProxyResolverFactory> factory_owner(
197 new BlockableProxyResolverFactory); 198 new BlockableProxyResolverFactory);
198 factory_ = factory_owner.get(); 199 factory_ = factory_owner.get();
199 resolver_factory_.reset(new SingleShotMultiThreadedProxyResolverFactory( 200 resolver_factory_.reset(new SingleShotMultiThreadedProxyResolverFactory(
200 num_threads, factory_owner.Pass())); 201 num_threads, std::move(factory_owner)));
201 TestCompletionCallback ready_callback; 202 TestCompletionCallback ready_callback;
202 scoped_ptr<ProxyResolverFactory::Request> request; 203 scoped_ptr<ProxyResolverFactory::Request> request;
203 resolver_factory_->CreateProxyResolver( 204 resolver_factory_->CreateProxyResolver(
204 ProxyResolverScriptData::FromUTF8("pac script bytes"), &resolver_, 205 ProxyResolverScriptData::FromUTF8("pac script bytes"), &resolver_,
205 ready_callback.callback(), &request); 206 ready_callback.callback(), &request);
206 EXPECT_TRUE(request); 207 EXPECT_TRUE(request);
207 ASSERT_EQ(OK, ready_callback.WaitForResult()); 208 ASSERT_EQ(OK, ready_callback.WaitForResult());
208 209
209 // Verify that the script data reaches the synchronous resolver factory. 210 // Verify that the script data reaches the synchronous resolver factory.
210 ASSERT_EQ(1u, factory_->script_data().size()); 211 ASSERT_EQ(1u, factory_->script_data().size());
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 } 778 }
778 // The factory destructor will block until the worker thread stops, but it may 779 // The factory destructor will block until the worker thread stops, but it may
779 // post tasks to the origin message loop which are still pending. Run them 780 // post tasks to the origin message loop which are still pending. Run them
780 // now to ensure it works as expected. 781 // now to ensure it works as expected.
781 base::RunLoop().RunUntilIdle(); 782 base::RunLoop().RunUntilIdle();
782 } 783 }
783 784
784 } // namespace 785 } // namespace
785 786
786 } // namespace net 787 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/multi_threaded_proxy_resolver.cc ('k') | net/proxy/proxy_config.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698