Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: net/socket/transport_client_socket_pool_unittest.cc

Issue 9384024: Prefer ScopedNestableTaskAllower over manual save/restore (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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 #include "net/socket/transport_client_socket_pool.h" 5 #include "net/socket/transport_client_socket_pool.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 void OnComplete(int result) { 790 void OnComplete(int result) {
791 SetResult(result); 791 SetResult(result);
792 ASSERT_EQ(OK, result); 792 ASSERT_EQ(OK, result);
793 793
794 if (!within_callback_) { 794 if (!within_callback_) {
795 // Don't allow reuse of the socket. Disconnect it and then release it and 795 // Don't allow reuse of the socket. Disconnect it and then release it and
796 // run through the MessageLoop once to get it completely released. 796 // run through the MessageLoop once to get it completely released.
797 handle_->socket()->Disconnect(); 797 handle_->socket()->Disconnect();
798 handle_->Reset(); 798 handle_->Reset();
799 { 799 {
800 MessageLoop::ScopedNestableTaskAllower nestable( 800 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
801 MessageLoop::current());
802 MessageLoop::current()->RunAllPending(); 801 MessageLoop::current()->RunAllPending();
803 } 802 }
804 within_callback_ = true; 803 within_callback_ = true;
jar (doing other things) 2012/02/11 03:24:38 again... this looks like a pattern to prevent recu
805 scoped_refptr<TransportSocketParams> dest(new TransportSocketParams( 804 scoped_refptr<TransportSocketParams> dest(new TransportSocketParams(
806 HostPortPair("www.google.com", 80), LOWEST, false, false)); 805 HostPortPair("www.google.com", 80), LOWEST, false, false));
807 int rv = handle_->Init("a", dest, LOWEST, callback(), pool_, 806 int rv = handle_->Init("a", dest, LOWEST, callback(), pool_,
808 BoundNetLog()); 807 BoundNetLog());
809 EXPECT_EQ(OK, rv); 808 EXPECT_EQ(OK, rv);
810 } 809 }
811 } 810 }
812 811
813 ClientSocketHandle* const handle_; 812 ClientSocketHandle* const handle_;
814 TransportClientSocketPool* const pool_; 813 TransportClientSocketPool* const pool_;
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 EXPECT_TRUE(handle.socket()); 1257 EXPECT_TRUE(handle.socket());
1259 IPEndPoint endpoint; 1258 IPEndPoint endpoint;
1260 handle.socket()->GetLocalAddress(&endpoint); 1259 handle.socket()->GetLocalAddress(&endpoint);
1261 EXPECT_EQ(kIPv4AddressSize, endpoint.address().size()); 1260 EXPECT_EQ(kIPv4AddressSize, endpoint.address().size());
1262 EXPECT_EQ(1, client_socket_factory_.allocation_count()); 1261 EXPECT_EQ(1, client_socket_factory_.allocation_count());
1263 } 1262 }
1264 1263
1265 } // namespace 1264 } // namespace
1266 1265
1267 } // namespace net 1266 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698