Add IS_TIZEN_DA to fix build break in standard build.
[platform/framework/web/chromium-efl.git] / net / quic / quic_http_utils.cc
1 // Copyright 2013 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/quic/quic_http_utils.h"
6
7 #include <utility>
8
9 #include "base/metrics/histogram_macros.h"
10 #include "net/spdy/spdy_log_util.h"
11
12 namespace net {
13
14 spdy::SpdyPriority ConvertRequestPriorityToQuicPriority(
15     const RequestPriority priority) {
16   DCHECK_GE(priority, MINIMUM_PRIORITY);
17   DCHECK_LE(priority, MAXIMUM_PRIORITY);
18   return static_cast<spdy::SpdyPriority>(HIGHEST - priority);
19 }
20
21 RequestPriority ConvertQuicPriorityToRequestPriority(
22     spdy::SpdyPriority priority) {
23   // Handle invalid values gracefully.
24   return (priority >= 5) ? IDLE
25                          : static_cast<RequestPriority>(HIGHEST - priority);
26 }
27
28 base::Value::Dict QuicRequestNetLogParams(quic::QuicStreamId stream_id,
29                                           const spdy::Http2HeaderBlock* headers,
30                                           quic::QuicStreamPriority priority,
31                                           NetLogCaptureMode capture_mode) {
32   base::Value::Dict dict = Http2HeaderBlockNetLogParams(headers, capture_mode);
33   switch (priority.type()) {
34     case quic::QuicPriorityType::kHttp: {
35       auto http_priority = priority.http();
36       dict.Set("quic_priority_type", "http");
37       dict.Set("quic_priority_urgency", http_priority.urgency);
38       dict.Set("quic_priority_incremental", http_priority.incremental);
39       break;
40     }
41     case quic::QuicPriorityType::kWebTransport: {
42       auto web_transport_priority = priority.web_transport();
43       dict.Set("quic_priority_type", "web_transport");
44       const char* stream_type = "invalid";
45       switch (web_transport_priority.stream_type) {
46         case quic::WebTransportStreamPriority::StreamType::kData:
47           stream_type = "data";
48           break;
49         case quic::WebTransportStreamPriority::StreamType::kHttp:
50           stream_type = "http";
51           break;
52         case quic::WebTransportStreamPriority::StreamType::kStatic:
53           stream_type = "static";
54           break;
55       }
56       dict.Set("web_transport_stream_type", stream_type);
57       // send_order is an int64_t, but base::Value doesn't support that type.
58       // Case to a double instead. As this is just for diagnostics, some loss of
59       // precision is acceptable.
60       dict.Set("web_transport_send_order",
61                static_cast<double>(web_transport_priority.send_order));
62       break;
63     }
64   }
65   dict.Set("quic_stream_id", static_cast<int>(stream_id));
66   return dict;
67 }
68
69 base::Value::Dict QuicResponseNetLogParams(
70     quic::QuicStreamId stream_id,
71     bool fin_received,
72     const spdy::Http2HeaderBlock* headers,
73     NetLogCaptureMode capture_mode) {
74   base::Value::Dict dict = Http2HeaderBlockNetLogParams(headers, capture_mode);
75   dict.Set("quic_stream_id", static_cast<int>(stream_id));
76   dict.Set("fin", fin_received);
77   return dict;
78 }
79
80 }  // namespace net