summaryrefslogtreecommitdiffstats
path: root/net/flip/flip_session_pool.cc
diff options
context:
space:
mode:
authornsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-17 23:33:29 +0000
committernsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-17 23:33:29 +0000
commitfa958d0c51c5ddf94b370c16ca01f1a606aa405e (patch)
treeea0e31753be212c395e11017048f7a380466c89c /net/flip/flip_session_pool.cc
parent637118fb52d4736b5ecef1253b4c879f5fdaf00e (diff)
downloadchromium_src-fa958d0c51c5ddf94b370c16ca01f1a606aa405e.zip
chromium_src-fa958d0c51c5ddf94b370c16ca01f1a606aa405e.tar.gz
chromium_src-fa958d0c51c5ddf94b370c16ca01f1a606aa405e.tar.bz2
Revert change 26484 "This is not production code; landing some experimental network code." because
it broke the "check_deps" step on Chromium XP Review URL: http://codereview.chromium.org/212015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26524 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/flip/flip_session_pool.cc')
-rw-r--r--net/flip/flip_session_pool.cc99
1 files changed, 0 insertions, 99 deletions
diff --git a/net/flip/flip_session_pool.cc b/net/flip/flip_session_pool.cc
deleted file mode 100644
index 2aef13a..0000000
--- a/net/flip/flip_session_pool.cc
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "net/flip/flip_session_pool.h"
-
-#include "base/logging.h"
-#include "net/flip/flip_session.h"
-
-namespace net {
-
-// The maximum number of sessions to open to a single domain.
-const int kMaxSessionsPerDomain = 1;
-
-scoped_ptr<FlipSessionPool::FlipSessionsMap> FlipSessionPool::sessions_;
-
-FlipSession* FlipSessionPool::Get(const HostResolver::RequestInfo& info,
- HttpNetworkSession* session) {
- if (!sessions_.get())
- sessions_.reset(new FlipSessionsMap());
-
- const std::string domain = info.hostname();
- FlipSession* flip_session = NULL;
- FlipSessionList* list = GetSessionList(domain);
- if (list) {
- if (list->size() >= kMaxSessionsPerDomain) {
- flip_session = list->front();
- list->pop_front();
- }
- } else {
- list = AddSessionList(domain);
- }
-
- DCHECK(list);
- 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);
- DCHECK(list->size() <= kMaxSessionsPerDomain);
- return flip_session;
-}
-
-void FlipSessionPool::Remove(FlipSession* session) {
- std::string domain = session->domain();
- FlipSessionList* list = GetSessionList(domain);
- if (list == NULL)
- return;
- list->remove(session);
- if (!list->size())
- RemoveSessionList(domain);
-}
-
-FlipSessionPool::FlipSessionList*
- FlipSessionPool::AddSessionList(std::string domain) {
- DCHECK(sessions_->find(domain) == sessions_->end());
- return (*sessions_)[domain] = new FlipSessionList();
-}
-
-// static
-FlipSessionPool::FlipSessionList*
- FlipSessionPool::GetSessionList(std::string domain) {
- FlipSessionsMap::iterator it = sessions_->find(domain);
- if (it == sessions_->end())
- return NULL;
- return it->second;
-}
-
-// static
-void FlipSessionPool::RemoveSessionList(std::string domain) {
- FlipSessionList* list = GetSessionList(domain);
- if (list) {
- delete list;
- sessions_->erase(domain);
- } else {
- DCHECK(false) << "removing orphaned session list";
- }
-}
-
-// static
-void FlipSessionPool::CloseAllSessions() {
- while (sessions_->size()) {
- FlipSessionList* list = sessions_->begin()->second;
- DCHECK(list);
- sessions_->erase(sessions_->begin()->first);
- while (list->size()) {
- FlipSession* session = list->front();
- list->pop_front();
- session->CloseAllStreams(net::OK);
- session->Release();
- }
- delete list;
- }
-}
-
-} // namespace net
-