File: http_stream_request.cc

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (105 lines) | stat: -rw-r--r-- 3,267 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/http/http_stream_request.h"

#include <utility>

#include "base/check.h"
#include "base/functional/callback.h"
#include "net/http/bidirectional_stream_impl.h"
#include "net/log/net_log_event_type.h"
#include "net/spdy/bidirectional_stream_spdy_impl.h"
#include "net/spdy/spdy_http_stream.h"
#include "net/spdy/spdy_session.h"

namespace net {

HttpStreamRequest::HttpStreamRequest(
    Helper* helper,
    WebSocketHandshakeStreamBase::CreateHelper*
        websocket_handshake_stream_create_helper,
    const NetLogWithSource& net_log,
    StreamType stream_type)
    : helper_(helper),
      websocket_handshake_stream_create_helper_(
          websocket_handshake_stream_create_helper),
      net_log_(net_log),
      stream_type_(stream_type) {
  net_log_.BeginEvent(NetLogEventType::HTTP_STREAM_REQUEST);
}

HttpStreamRequest::~HttpStreamRequest() {
  net_log_.EndEvent(NetLogEventType::HTTP_STREAM_REQUEST);
  helper_.ExtractAsDangling()->OnRequestComplete();  // May delete `*helper_`;
}

void HttpStreamRequest::Complete(
    NextProto negotiated_protocol,
    AlternateProtocolUsage alternate_protocol_usage) {
  DCHECK(!completed_);
  completed_ = true;
  negotiated_protocol_ = negotiated_protocol;
  alternate_protocol_usage_ = alternate_protocol_usage;
}

int HttpStreamRequest::RestartTunnelWithProxyAuth() {
  return helper_->RestartTunnelWithProxyAuth();
}

void HttpStreamRequest::SetPriority(RequestPriority priority) {
  helper_->SetPriority(priority);
}

LoadState HttpStreamRequest::GetLoadState() const {
  return helper_->GetLoadState();
}

NextProto HttpStreamRequest::negotiated_protocol() const {
  DCHECK(completed_);
  return negotiated_protocol_;
}

AlternateProtocolUsage HttpStreamRequest::alternate_protocol_usage() const {
  DCHECK(completed_);
  return alternate_protocol_usage_;
}

const ConnectionAttempts& HttpStreamRequest::connection_attempts() const {
  return connection_attempts_;
}

void HttpStreamRequest::AddConnectionAttempts(
    const ConnectionAttempts& attempts) {
  for (const auto& attempt : attempts) {
    connection_attempts_.push_back(attempt);
  }
}

WebSocketHandshakeStreamBase::CreateHelper*
HttpStreamRequest::websocket_handshake_stream_create_helper() const {
  return websocket_handshake_stream_create_helper_;
}

void HttpStreamRequest::SetDnsResolutionTimeOverrides(
    base::TimeTicks dns_resolution_start_time_override,
    base::TimeTicks dns_resolution_end_time_override) {
  CHECK(!dns_resolution_start_time_override.is_null());
  CHECK(!dns_resolution_end_time_override.is_null());
  if (dns_resolution_start_time_override_.is_null() ||
      (dns_resolution_start_time_override <
       dns_resolution_start_time_override_)) {
    dns_resolution_start_time_override_ = dns_resolution_start_time_override;
  }
  if (dns_resolution_end_time_override_.is_null() ||
      (dns_resolution_end_time_override < dns_resolution_end_time_override_)) {
    dns_resolution_end_time_override_ = dns_resolution_end_time_override;
  }
}

void HttpStreamRequest::SetHelperForSwitchingToPool(Helper* helper) {
  helper_ = helper;
}

}  // namespace net