• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2024 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "net/http/http_stream_pool_handle.h"
6 
7 #include <memory>
8 
9 #include "base/memory/weak_ptr.h"
10 #include "net/http/http_stream_pool.h"
11 #include "net/http/http_stream_pool_group.h"
12 #include "net/socket/stream_socket.h"
13 
14 namespace net {
15 
HttpStreamPoolHandle(base::WeakPtr<HttpStreamPool::Group> group,std::unique_ptr<StreamSocket> socket,int64_t generation)16 HttpStreamPoolHandle::HttpStreamPoolHandle(
17     base::WeakPtr<HttpStreamPool::Group> group,
18     std::unique_ptr<StreamSocket> socket,
19     int64_t generation)
20     : group_(std::move(group)), generation_(generation) {
21   CHECK(group_);
22   CHECK(socket);
23 
24   // Always considered initialized.
25   SetSocket(std::move(socket));
26   set_is_initialized(true);
27 }
28 
~HttpStreamPoolHandle()29 HttpStreamPoolHandle::~HttpStreamPoolHandle() {
30   Reset();
31 }
32 
Reset()33 void HttpStreamPoolHandle::Reset() {
34   if (socket() && group_) {
35     group_->ReleaseStreamSocket(PassSocket(), generation_);
36   }
37 }
38 
IsPoolStalled() const39 bool HttpStreamPoolHandle::IsPoolStalled() const {
40   return group_->pool()->IsPoolStalled();
41 }
42 
43 }  // namespace net
44