<commit_before>// 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);<commit_msg>Fix signed/unsigned mismatch for linux<commit_after>// 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 size_t 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);
{'fraction_non_alphanumeric': 0.11551292743953294, 'fraction_numerical': 0.004170141784820684, 'mean_word_length': 3.685546875, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6861524', 'n_tokens_mistral': 769, 'n_tokens_neox': 742, 'n_words': 201}