summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/flip/flip_io_buffer.cc5
-rw-r--r--net/flip/flip_io_buffer.h5
-rw-r--r--net/flip/flip_session.cc8
-rw-r--r--net/flip/flip_session_pool.cc26
-rw-r--r--net/flip/flip_session_pool.h25
-rw-r--r--net/flip/flip_stream_unittest.cc25
-rw-r--r--net/http/http_network_session.h4
-rw-r--r--tools/valgrind/memcheck/suppressions.txt54
-rw-r--r--tools/valgrind/memcheck/suppressions_mac.txt94
9 files changed, 64 insertions, 182 deletions
diff --git a/net/flip/flip_io_buffer.cc b/net/flip/flip_io_buffer.cc
index b3aecc5..5235c62 100644
--- a/net/flip/flip_io_buffer.cc
+++ b/net/flip/flip_io_buffer.cc
@@ -21,4 +21,9 @@ FlipIOBuffer::FlipIOBuffer() : priority_(0), position_(0), stream_(NULL) {}
FlipIOBuffer::~FlipIOBuffer() {}
+void FlipIOBuffer::release() {
+ buffer_ = NULL;
+ stream_ = NULL;
+}
+
} // namespace net
diff --git a/net/flip/flip_io_buffer.h b/net/flip/flip_io_buffer.h
index 85d9510..ffb4b3b 100644
--- a/net/flip/flip_io_buffer.h
+++ b/net/flip/flip_io_buffer.h
@@ -30,10 +30,7 @@ class FlipIOBuffer {
// Accessors.
IOBuffer* buffer() const { return buffer_; }
size_t size() const { return buffer_->size(); }
- void release() {
- buffer_.release();
- stream_.release();
- }
+ void release();
int priority() const { return priority_; }
const scoped_refptr<FlipStream>& stream() const { return stream_; }
diff --git a/net/flip/flip_session.cc b/net/flip/flip_session.cc
index d3bcedc..de87732 100644
--- a/net/flip/flip_session.cc
+++ b/net/flip/flip_session.cc
@@ -169,7 +169,9 @@ FlipSession::~FlipSession() {
connection_.socket()->Disconnect();
}
- session_->flip_session_pool()->Remove(this);
+ // TODO(willchan): Don't hardcode port 80 here.
+ DCHECK(!session_->flip_session_pool()->HasSession(
+ HostResolver::RequestInfo(domain_, 80)));
}
net::Error FlipSession::Connect(const std::string& group_name,
@@ -359,7 +361,7 @@ void FlipSession::OnTCPConnect(int result) {
if (result != net::OK) {
net::Error err = static_cast<net::Error>(result);
CloseAllStreams(err);
- this->Release();
+ session_->flip_session_pool()->Remove(this);
return;
}
@@ -426,7 +428,7 @@ void FlipSession::OnReadComplete(int bytes_read) {
// Session is tearing down.
net::Error err = static_cast<net::Error>(bytes_read);
CloseAllStreams(err);
- this->Release();
+ session_->flip_session_pool()->Remove(this);
return;
}
diff --git a/net/flip/flip_session_pool.cc b/net/flip/flip_session_pool.cc
index 386fddc..ec3b34d 100644
--- a/net/flip/flip_session_pool.cc
+++ b/net/flip/flip_session_pool.cc
@@ -17,10 +17,10 @@ FlipSessionPool::~FlipSessionPool() {
CloseAllSessions();
}
-FlipSession* FlipSessionPool::Get(const HostResolver::RequestInfo& info,
- HttpNetworkSession* session) {
+scoped_refptr<FlipSession> FlipSessionPool::Get(
+ const HostResolver::RequestInfo& info, HttpNetworkSession* session) {
const std::string& domain = info.hostname();
- FlipSession* flip_session = NULL;
+ scoped_refptr<FlipSession> flip_session;
FlipSessionList* list = GetSessionList(domain);
if (list) {
if (list->size() >= kMaxSessionsPerDomain) {
@@ -32,10 +32,8 @@ FlipSession* FlipSessionPool::Get(const HostResolver::RequestInfo& info,
}
DCHECK(list);
- if (!flip_session) {
+ if (!flip_session)
flip_session = new FlipSession(domain, session);
- flip_session->AddRef(); // Keep it in the cache.
- }
DCHECK(flip_session);
list->push_back(flip_session);
@@ -43,6 +41,14 @@ FlipSession* FlipSessionPool::Get(const HostResolver::RequestInfo& info,
return flip_session;
}
+scoped_refptr<FlipSession> FlipSessionPool::GetFlipSessionFromSocket(
+ const HostResolver::RequestInfo& info,
+ HttpNetworkSession* session,
+ ClientSocket* socket) {
+ NOTIMPLEMENTED();
+ return NULL;
+}
+
bool FlipSessionPool::HasSession(const HostResolver::RequestInfo& info) const {
const std::string& domain = info.hostname();
if (GetSessionList(domain))
@@ -50,11 +56,10 @@ bool FlipSessionPool::HasSession(const HostResolver::RequestInfo& info) const {
return false;
}
-void FlipSessionPool::Remove(FlipSession* session) {
+void FlipSessionPool::Remove(const scoped_refptr<FlipSession>& session) {
std::string domain = session->domain();
FlipSessionList* list = GetSessionList(domain);
- if (list == NULL)
- return;
+ CHECK(list);
list->remove(session);
if (list->empty())
RemoveSessionList(domain);
@@ -98,10 +103,9 @@ void FlipSessionPool::CloseAllSessions() {
DCHECK(list);
sessions_.erase(sessions_.begin()->first);
while (list->size()) {
- FlipSession* session = list->front();
+ scoped_refptr<FlipSession> session = list->front();
list->pop_front();
session->CloseAllStreams(net::OK);
- session->Release();
}
delete list;
}
diff --git a/net/flip/flip_session_pool.h b/net/flip/flip_session_pool.h
index 76ffc0d..fc3be5c 100644
--- a/net/flip/flip_session_pool.h
+++ b/net/flip/flip_session_pool.h
@@ -27,18 +27,16 @@ class FlipSessionPool : public base::RefCounted<FlipSessionPool> {
// Either returns an existing FlipSession or creates a new FlipSession for
// use.
- FlipSession* Get(const HostResolver::RequestInfo& info,
- HttpNetworkSession* session);
+ scoped_refptr<FlipSession> Get(
+ const HostResolver::RequestInfo& info, HttpNetworkSession* session);
// Builds a FlipSession from an existing socket.
- FlipSession* GetFlipSessionFromSocket(
+ // TODO(willchan): Implement this to allow a HttpNetworkTransaction to
+ // upgrade a TCP connection from HTTP to FLIP.
+ scoped_refptr<FlipSession> GetFlipSessionFromSocket(
const HostResolver::RequestInfo& info,
HttpNetworkSession* session,
- ClientSocket* socket) {
- // TODO(willchan): Implement this to allow a HttpNetworkTransaction to
- // upgrade a TCP connection from HTTP to FLIP.
- return NULL;
- }
+ ClientSocket* socket);
// TODO(willchan): Consider renaming to HasReusableSession, since perhaps we
// should be creating a new session.
@@ -50,14 +48,15 @@ class FlipSessionPool : public base::RefCounted<FlipSessionPool> {
private:
friend class base::RefCounted<FlipSessionPool>;
friend class FlipSession; // Needed for Remove().
+ friend class FlipSessionPoolPeer; // For testing.
- virtual ~FlipSessionPool();
-
- typedef std::list<FlipSession*> FlipSessionList;
+ typedef std::list<scoped_refptr<FlipSession> > FlipSessionList;
typedef std::map<std::string, FlipSessionList*> FlipSessionsMap;
- // Return a FlipSession to the pool.
- void Remove(FlipSession* session);
+ virtual ~FlipSessionPool();
+
+ // Removes a FlipSession from the FlipSessionPool.
+ void Remove(const scoped_refptr<FlipSession>& session);
// Helper functions for manipulating the lists.
FlipSessionList* AddSessionList(const std::string& domain);
diff --git a/net/flip/flip_stream_unittest.cc b/net/flip/flip_stream_unittest.cc
index 46d3b54..311b51c 100644
--- a/net/flip/flip_stream_unittest.cc
+++ b/net/flip/flip_stream_unittest.cc
@@ -19,6 +19,21 @@
namespace net {
+class FlipSessionPoolPeer {
+ public:
+ explicit FlipSessionPoolPeer(const scoped_refptr<FlipSessionPool>& pool)
+ : pool_(pool) {}
+
+ void RemoveFlipSession(const scoped_refptr<FlipSession>& session) {
+ pool_->Remove(session);
+ }
+
+ private:
+ const scoped_refptr<FlipSessionPool> pool_;
+
+ DISALLOW_COPY_AND_ASSIGN(FlipSessionPoolPeer);
+};
+
namespace {
// Create a proxy service which fails on all requests (falls back to direct).
@@ -62,7 +77,8 @@ HttpNetworkSession* CreateSession(SessionDependencies* session_deps) {
class FlipStreamTest : public testing::Test {
protected:
FlipStreamTest()
- : session_(CreateSession(&session_deps_)) {}
+ : session_(CreateSession(&session_deps_)),
+ pool_peer_(session_->flip_session_pool()) {}
scoped_refptr<FlipSession> CreateFlipSession() {
HostResolver::RequestInfo resolve_info("www.google.com", 80);
@@ -77,10 +93,11 @@ class FlipStreamTest : public testing::Test {
SessionDependencies session_deps_;
scoped_refptr<HttpNetworkSession> session_;
+ FlipSessionPoolPeer pool_peer_;
};
// Needs fixing, see http://crbug.com/28622
-TEST_F(FlipStreamTest, DISABLED_SendRequest) {
+TEST_F(FlipStreamTest, SendRequest) {
scoped_refptr<FlipSession> session(CreateFlipSession());
HttpRequestInfo request;
request.method = "GET";
@@ -89,6 +106,10 @@ TEST_F(FlipStreamTest, DISABLED_SendRequest) {
scoped_refptr<FlipStream> stream(new FlipStream(session, 1, false));
EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(NULL, &callback));
+
+ // Need to manually remove the flip session since normally it gets removed on
+ // socket close/error, but we aren't communicating over a socket here.
+ pool_peer_.RemoveFlipSession(session);
}
// TODO(willchan): Write a longer test for FlipStream that exercises all
diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h
index 11e42f4..f2e76e2 100644
--- a/net/http/http_network_session.h
+++ b/net/http/http_network_session.h
@@ -38,7 +38,9 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> {
HostResolver* host_resolver() { return host_resolver_; }
ProxyService* proxy_service() { return proxy_service_; }
SSLConfigService* ssl_config_service() { return ssl_config_service_; }
- FlipSessionPool* flip_session_pool() { return flip_session_pool_; }
+ const scoped_refptr<FlipSessionPool>& flip_session_pool() {
+ return flip_session_pool_;
+ }
static void set_max_sockets_per_group(int socket_count);
diff --git a/tools/valgrind/memcheck/suppressions.txt b/tools/valgrind/memcheck/suppressions.txt
index 6325f76..9270036 100644
--- a/tools/valgrind/memcheck/suppressions.txt
+++ b/tools/valgrind/memcheck/suppressions.txt
@@ -1728,60 +1728,6 @@
fun:_ZN11MessageLoop11RunInternalEv
fun:_ZN11MessageLoop10RunHandlerEv
}
-# new flip leaks TODO(willchan): fix these
-{
- bug_28493a
- Memcheck:Leak
- fun:_Znw*
- fun:_ZN3net11FlipSession17GetOrCreateStreamERKNS_15HttpRequestInfoEPKNS_16UploadDataStreamE
- ...
-}
-{
- bug_28493b
- Memcheck:Leak
- fun:_Znw*
- ...
- fun:_ZN3net26FlipNetworkTransactionTest17TransactionHelperERKNS_15HttpRequestInfoEPNS_8MockReadES5_
- ...
-}
-{
- bug_28493c
- Memcheck:Leak
- fun:_Znw*
- fun:_ZN3net116_GLOBAL__N__b_slave_chromium_rel_linux_valgrind_builder_build_src_net_flip_flip_stream_unittest.cc_00000000_46E4189919SessionDependenciesC1Ev
- fun:_ZN3net116_GLOBAL__N__b_slave_chromium_rel_linux_valgrind_builder_build_src_net_flip_flip_stream_unittest.cc_00000000_46E4189914FlipStreamTestC2Ev
- fun:_ZN3net116_GLOBAL__N__b_slave_chromium_rel_linux_valgrind_builder_build_src_net_flip_flip_stream_unittest.cc_00000000_46E4189931FlipStreamTest_SendRequest_TestC1Ev
- fun:_ZN7testing8internal15TestFactoryImplIN3net116_GLOBAL__N__b_slave_chromium_rel_linux_valgrind_builder_build_src_net_flip_flip_stream_unittest.cc_00000000_46E4189931FlipStreamTest_SendRequest_TestEE10CreateTestEv
- fun:_ZN7testing8internal12TestInfoImpl3RunEv
- fun:_ZN7testing8TestCase3RunEv
- fun:_ZN7testing8internal12UnitTestImpl11RunAllTestsEv
- fun:_ZN7testing8UnitTest3RunEv
- fun:_ZN9TestSuite3RunEv
- fun:main
-}
-{
- bug_28493d
- Memcheck:Leak
- fun:_Znw*
- fun:_ZN3net11FlipSession11WriteSocketEv
- ...
-}
-{
- bug_28493
- Memcheck:Leak
- fun:_Znw*
- fun:_ZN3net129_GLOBAL__N__b_slave_chromium_rel_linux_valgrind_builder_build_src_net_flip_flip_network_transaction_unittest.cc_00000000_9BF5CC6519SessionDependenciesC1Ev
- fun:_ZN3net26FlipNetworkTransactionTest17TransactionHelperERKNS_15HttpRequestInfoEPNS_8MockReadES5_
- fun:_ZN3net47FlipNetworkTransactionTest_SynReplyHeaders_Test8TestBodyEv
- fun:_ZN7testing4Test3RunEv
- fun:_ZN7testing8internal12TestInfoImpl3RunEv
- fun:_ZN7testing8TestCase3RunEv
- fun:_ZN7testing8internal12UnitTestImpl11RunAllTestsEv
- fun:_ZN7testing8UnitTest3RunEv
- fun:_ZN9TestSuite3RunEv
- fun:main
-}
-
{
bug_28633
Memcheck:Leak
diff --git a/tools/valgrind/memcheck/suppressions_mac.txt b/tools/valgrind/memcheck/suppressions_mac.txt
index d6e005a..792559b 100644
--- a/tools/valgrind/memcheck/suppressions_mac.txt
+++ b/tools/valgrind/memcheck/suppressions_mac.txt
@@ -423,97 +423,3 @@
fun:_ZN21ResourceMessageFilter10OnDestructEv
fun:_ZN3IPC12ChannelProxy19MessageFilterTraits8DestructEPNS0_13MessageFilterE
}
-# new flip leaks TODO(willchan): fix these
-{
- bug_28493a
- Memcheck:Leak
- fun:_Znw*
- fun:_ZN3net11FlipSession17GetOrCreateStreamERKNS_15HttpRequestInfoEPKNS_16UploadDataStreamE
- ...
-}
-{
- bug_28493b
- Memcheck:Leak
- fun:_Znw*
- ...
- fun:_ZN3net26FlipNetworkTransactionTest17TransactionHelperERKNS_15HttpRequestInfoEPNS_8MockReadES5_
- ...
-}
-{
- bug_28493c
- Memcheck:Leak
- fun:_Znw*
- fun:_ZN3net116_GLOBAL__N__b_slave_chromium_rel_linux_valgrind_builder_build_src_net_flip_flip_stream_unittest.cc_00000000_46E4189919SessionDependenciesC1Ev
- fun:_ZN3net116_GLOBAL__N__b_slave_chromium_rel_linux_valgrind_builder_build_src_net_flip_flip_stream_unittest.cc_00000000_46E4189914FlipStreamTestC2Ev
- fun:_ZN3net116_GLOBAL__N__b_slave_chromium_rel_linux_valgrind_builder_build_src_net_flip_flip_stream_unittest.cc_00000000_46E4189931FlipStreamTest_SendRequest_TestC1Ev
- fun:_ZN7testing8internal15TestFactoryImplIN3net116_GLOBAL__N__b_slave_chromium_rel_linux_valgrind_builder_build_src_net_flip_flip_stream_unittest.cc_00000000_46E4189931FlipStreamTest_SendRequest_TestEE10CreateTestEv
- fun:_ZN7testing8internal12TestInfoImpl3RunEv
- fun:_ZN7testing8TestCase3RunEv
- fun:_ZN7testing8internal12UnitTestImpl11RunAllTestsEv
- fun:_ZN7testing8UnitTest3RunEv
- fun:_ZN9TestSuite3RunEv
- fun:main
-}
-{
- bug_28493d
- Memcheck:Leak
- fun:_Znw*
- fun:_ZN3net11FlipSession11WriteSocketEv
- ...
-}
-{
- bug_28493
- Memcheck:Leak
- fun:_Znw*
- fun:_ZN3net129_GLOBAL__N__b_slave_chromium_rel_linux_valgrind_builder_build_src_net_flip_flip_network_transaction_unittest.cc_00000000_9BF5CC6519SessionDependenciesC1Ev
- fun:_ZN3net26FlipNetworkTransactionTest17TransactionHelperERKNS_15HttpRequestInfoEPNS_8MockReadES5_
- fun:_ZN3net47FlipNetworkTransactionTest_SynReplyHeaders_Test8TestBodyEv
- fun:_ZN7testing4Test3RunEv
- fun:_ZN7testing8internal12TestInfoImpl3RunEv
- fun:_ZN7testing8TestCase3RunEv
- fun:_ZN7testing8internal12UnitTestImpl11RunAllTestsEv
- fun:_ZN7testing8UnitTest3RunEv
- fun:_ZN9TestSuite3RunEv
- fun:main
-}
-{
- bug_28493
- Memcheck:Leak
- fun:_Znw*
- fun:_ZN3net12_GLOBAL__N_119SessionDependenciesC2Ev
- fun:_ZN3net12_GLOBAL__N_119SessionDependenciesC1Ev
- fun:_ZN3net12_GLOBAL__N_114FlipStreamTestC2Ev
- fun:_ZN3net12_GLOBAL__N_131FlipStreamTest_SendRequest_TestC2Ev
- fun:_ZN3net12_GLOBAL__N_131FlipStreamTest_SendRequest_TestC1Ev
- fun:_ZN7testing8internal15TestFactoryImplIN3net12_GLOBAL__N_131FlipStreamTest_SendRequest_TestEE10CreateTestEv
- fun:_ZN7testing8internal12TestInfoImpl3RunEv
- fun:_ZN7testing8TestCase3RunEv
- fun:_ZN7testing8internal12UnitTestImpl11RunAllTestsEv
- fun:_ZN7testing8UnitTest3RunEv
- fun:_ZN9TestSuite3RunEv
- fun:main
-}
-{
- bug_28493
- Memcheck:Leak
- fun:_Znw*
- fun:_ZN9__gnu_cxx13new_allocatorISt13_Rb_tree_nodeISt4pairIKSsPSt4listIPN3net11FlipSessionESaIS7_EEEEE8allocateEmPKv
- fun:_ZNSt8_Rb_treeISsSt4pairIKSsPSt4listIPN3net11FlipSessionESaIS5_EEESt10_Select1stIS9_ESt4lessISsESaIS9_EE11_M_get_nodeEv
- fun:_ZNSt8_Rb_treeISsSt4pairIKSsPSt4listIPN3net11FlipSessionESaIS5_EEESt10_Select1stIS9_ESt4lessISsESaIS9_EE14_M_create_nodeERKS9_
- fun:_ZNSt8_Rb_treeISsSt4pairIKSsPSt4listIPN3net11FlipSessionESaIS5_EEESt10_Select1stIS9_ESt4lessISsESaIS9_EE9_M_insertEPSt18_Rb_tree_node_baseSH_RKS9_
- fun:_ZNSt8_Rb_treeISsSt4pairIKSsPSt4listIPN3net11FlipSessionESaIS5_EEESt10_Select1stIS9_ESt4lessISsESaIS9_EE13insert_uniqueERKS9_
- fun:_ZNSt8_Rb_treeISsSt4pairIKSsPSt4listIPN3net11FlipSessionESaIS5_EEESt10_Select1stIS9_ESt4lessISsESaIS9_EE13insert_uniqueESt17_Rb_tree_iteratorIS9_ERKS9_
- fun:_ZNSt3mapISsPSt4listIPN3net11FlipSessionESaIS3_EESt4lessISsESaISt4pairIKSsS6_EEE6insertESt17_Rb_tree_iteratorISB_ERKSB_
- fun:_ZNSt3mapISsPSt4listIPN3net11FlipSessionESaIS3_EESt4lessISsESaISt4pairIKSsS6_EEEixERSA_
- fun:_ZN3net15FlipSessionPool14AddSessionListERKSs
- fun:_ZN3net15FlipSessionPool3GetERKNS_12HostResolver11RequestInfoEPNS_18HttpNetworkSessionE
- fun:_ZN3net12_GLOBAL__N_114FlipStreamTest17CreateFlipSessionEv
- fun:_ZN3net12_GLOBAL__N_131FlipStreamTest_SendRequest_Test8TestBodyEv
- fun:_ZN7testing4Test3RunEv
- fun:_ZN7testing8internal12TestInfoImpl3RunEv
- fun:_ZN7testing8TestCase3RunEv
- fun:_ZN7testing8internal12UnitTestImpl11RunAllTestsEv
- fun:_ZN7testing8UnitTest3RunEv
- fun:_ZN9TestSuite3RunEv
- fun:main
-}