Move Http2Optional to QuicheOptional. This is part of the overall effort to merge quic, spdy, and http2 platform in QUICHE. gfe-relnote: n/a, no functional change. PiperOrigin-RevId: 289853288 Change-Id: I98711f5dd54db265c29f337a73ad71c5400b227c
diff --git a/common/platform/api/quiche_optional.h b/common/platform/api/quiche_optional.h new file mode 100644 index 0000000..7342714 --- /dev/null +++ b/common/platform/api/quiche_optional.h
@@ -0,0 +1,19 @@ +// Copyright 2018 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. + +#ifndef QUICHE_COMMON_PLATFORM_API_QUICHE_OPTIONAL_H_ +#define QUICHE_COMMON_PLATFORM_API_QUICHE_OPTIONAL_H_ + +#include <utility> + +#include "net/quiche/common/platform/impl/quiche_optional_impl.h" + +namespace quiche { + +template <typename T> +using QuicheOptional = QuicheOptionalImpl<T>; + +} // namespace quiche + +#endif // QUICHE_COMMON_PLATFORM_API_QUICHE_OPTIONAL_H_
diff --git a/http2/platform/api/http2_optional.h b/http2/platform/api/http2_optional.h deleted file mode 100644 index 64ce5f5..0000000 --- a/http2/platform/api/http2_optional.h +++ /dev/null
@@ -1,19 +0,0 @@ -// Copyright 2018 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. - -#ifndef QUICHE_HTTP2_PLATFORM_API_HTTP2_OPTIONAL_H_ -#define QUICHE_HTTP2_PLATFORM_API_HTTP2_OPTIONAL_H_ - -#include <utility> - -#include "net/http2/platform/impl/http2_optional_impl.h" - -namespace http2 { - -template <typename T> -using Http2Optional = Http2OptionalImpl<T>; - -} // namespace http2 - -#endif // QUICHE_HTTP2_PLATFORM_API_HTTP2_OPTIONAL_H_
diff --git a/http2/test_tools/frame_parts.cc b/http2/test_tools/frame_parts.cc index 32d3a97..7d5c218 100644 --- a/http2/test_tools/frame_parts.cc +++ b/http2/test_tools/frame_parts.cc
@@ -507,9 +507,10 @@ return AssertionSuccess(); } -AssertionResult FrameParts::AppendString(quiche::QuicheStringPiece source, - std::string* target, - Http2Optional<size_t>* opt_length) { +AssertionResult FrameParts::AppendString( + quiche::QuicheStringPiece source, + std::string* target, + quiche::QuicheOptional<size_t>* opt_length) { target->append(source.data(), source.size()); if (opt_length != nullptr) { VERIFY_TRUE(*opt_length) << "Length is not set yet\n" << *this;
diff --git a/http2/test_tools/frame_parts.h b/http2/test_tools/frame_parts.h index 2d54143..bd6d939 100644 --- a/http2/test_tools/frame_parts.h +++ b/http2/test_tools/frame_parts.h
@@ -21,7 +21,7 @@ #include "net/third_party/quiche/src/http2/http2_constants.h" #include "net/third_party/quiche/src/http2/http2_structures.h" #include "net/third_party/quiche/src/http2/platform/api/http2_logging.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_optional.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_optional.h" #include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { @@ -115,70 +115,78 @@ const Http2FrameHeader& GetFrameHeader() const { return frame_header_; } - Http2Optional<Http2PriorityFields> GetOptPriority() const { + quiche::QuicheOptional<Http2PriorityFields> GetOptPriority() const { return opt_priority_; } - Http2Optional<Http2ErrorCode> GetOptRstStreamErrorCode() const { + quiche::QuicheOptional<Http2ErrorCode> GetOptRstStreamErrorCode() const { return opt_rst_stream_error_code_; } - Http2Optional<Http2PushPromiseFields> GetOptPushPromise() const { + quiche::QuicheOptional<Http2PushPromiseFields> GetOptPushPromise() const { return opt_push_promise_; } - Http2Optional<Http2PingFields> GetOptPing() const { return opt_ping_; } - Http2Optional<Http2GoAwayFields> GetOptGoaway() const { return opt_goaway_; } - Http2Optional<size_t> GetOptPadLength() const { return opt_pad_length_; } - Http2Optional<size_t> GetOptPayloadLength() const { + quiche::QuicheOptional<Http2PingFields> GetOptPing() const { + return opt_ping_; + } + quiche::QuicheOptional<Http2GoAwayFields> GetOptGoaway() const { + return opt_goaway_; + } + quiche::QuicheOptional<size_t> GetOptPadLength() const { + return opt_pad_length_; + } + quiche::QuicheOptional<size_t> GetOptPayloadLength() const { return opt_payload_length_; } - Http2Optional<size_t> GetOptMissingLength() const { + quiche::QuicheOptional<size_t> GetOptMissingLength() const { return opt_missing_length_; } - Http2Optional<size_t> GetOptAltsvcOriginLength() const { + quiche::QuicheOptional<size_t> GetOptAltsvcOriginLength() const { return opt_altsvc_origin_length_; } - Http2Optional<size_t> GetOptAltsvcValueLength() const { + quiche::QuicheOptional<size_t> GetOptAltsvcValueLength() const { return opt_altsvc_value_length_; } - Http2Optional<size_t> GetOptWindowUpdateIncrement() const { + quiche::QuicheOptional<size_t> GetOptWindowUpdateIncrement() const { return opt_window_update_increment_; } bool GetHasFrameSizeError() const { return has_frame_size_error_; } - void SetOptPriority(Http2Optional<Http2PriorityFields> opt_priority) { + void SetOptPriority( + quiche::QuicheOptional<Http2PriorityFields> opt_priority) { opt_priority_ = opt_priority; } void SetOptRstStreamErrorCode( - Http2Optional<Http2ErrorCode> opt_rst_stream_error_code) { + quiche::QuicheOptional<Http2ErrorCode> opt_rst_stream_error_code) { opt_rst_stream_error_code_ = opt_rst_stream_error_code; } void SetOptPushPromise( - Http2Optional<Http2PushPromiseFields> opt_push_promise) { + quiche::QuicheOptional<Http2PushPromiseFields> opt_push_promise) { opt_push_promise_ = opt_push_promise; } - void SetOptPing(Http2Optional<Http2PingFields> opt_ping) { + void SetOptPing(quiche::QuicheOptional<Http2PingFields> opt_ping) { opt_ping_ = opt_ping; } - void SetOptGoaway(Http2Optional<Http2GoAwayFields> opt_goaway) { + void SetOptGoaway(quiche::QuicheOptional<Http2GoAwayFields> opt_goaway) { opt_goaway_ = opt_goaway; } - void SetOptPadLength(Http2Optional<size_t> opt_pad_length) { + void SetOptPadLength(quiche::QuicheOptional<size_t> opt_pad_length) { opt_pad_length_ = opt_pad_length; } - void SetOptPayloadLength(Http2Optional<size_t> opt_payload_length) { + void SetOptPayloadLength(quiche::QuicheOptional<size_t> opt_payload_length) { opt_payload_length_ = opt_payload_length; } - void SetOptMissingLength(Http2Optional<size_t> opt_missing_length) { + void SetOptMissingLength(quiche::QuicheOptional<size_t> opt_missing_length) { opt_missing_length_ = opt_missing_length; } void SetOptAltsvcOriginLength( - Http2Optional<size_t> opt_altsvc_origin_length) { + quiche::QuicheOptional<size_t> opt_altsvc_origin_length) { opt_altsvc_origin_length_ = opt_altsvc_origin_length; } - void SetOptAltsvcValueLength(Http2Optional<size_t> opt_altsvc_value_length) { + void SetOptAltsvcValueLength( + quiche::QuicheOptional<size_t> opt_altsvc_value_length) { opt_altsvc_value_length_ = opt_altsvc_value_length; } void SetOptWindowUpdateIncrement( - Http2Optional<size_t> opt_window_update_increment) { + quiche::QuicheOptional<size_t> opt_window_update_increment) { opt_window_update_increment_ = opt_window_update_increment; } @@ -208,9 +216,10 @@ // Append source to target. If opt_length is not nullptr, then verifies that // the optional has a value (i.e. that the necessary On*Start method has been // called), and that target is not longer than opt_length->value(). - ::testing::AssertionResult AppendString(quiche::QuicheStringPiece source, - std::string* target, - Http2Optional<size_t>* opt_length); + ::testing::AssertionResult AppendString( + quiche::QuicheStringPiece source, + std::string* target, + quiche::QuicheOptional<size_t>* opt_length); const Http2FrameHeader frame_header_; @@ -219,19 +228,19 @@ std::string altsvc_origin_; std::string altsvc_value_; - Http2Optional<Http2PriorityFields> opt_priority_; - Http2Optional<Http2ErrorCode> opt_rst_stream_error_code_; - Http2Optional<Http2PushPromiseFields> opt_push_promise_; - Http2Optional<Http2PingFields> opt_ping_; - Http2Optional<Http2GoAwayFields> opt_goaway_; + quiche::QuicheOptional<Http2PriorityFields> opt_priority_; + quiche::QuicheOptional<Http2ErrorCode> opt_rst_stream_error_code_; + quiche::QuicheOptional<Http2PushPromiseFields> opt_push_promise_; + quiche::QuicheOptional<Http2PingFields> opt_ping_; + quiche::QuicheOptional<Http2GoAwayFields> opt_goaway_; - Http2Optional<size_t> opt_pad_length_; - Http2Optional<size_t> opt_payload_length_; - Http2Optional<size_t> opt_missing_length_; - Http2Optional<size_t> opt_altsvc_origin_length_; - Http2Optional<size_t> opt_altsvc_value_length_; + quiche::QuicheOptional<size_t> opt_pad_length_; + quiche::QuicheOptional<size_t> opt_payload_length_; + quiche::QuicheOptional<size_t> opt_missing_length_; + quiche::QuicheOptional<size_t> opt_altsvc_origin_length_; + quiche::QuicheOptional<size_t> opt_altsvc_value_length_; - Http2Optional<size_t> opt_window_update_increment_; + quiche::QuicheOptional<size_t> opt_window_update_increment_; bool has_frame_size_error_ = false;
diff --git a/spdy/core/http2_frame_decoder_adapter.h b/spdy/core/http2_frame_decoder_adapter.h index b1e16b1..f3ccdff 100644 --- a/spdy/core/http2_frame_decoder_adapter.h +++ b/spdy/core/http2_frame_decoder_adapter.h
@@ -12,7 +12,7 @@ #include <string> #include "net/third_party/quiche/src/http2/decoder/http2_frame_decoder.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_optional.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_optional.h" #include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/hpack/hpack_decoder_adapter.h" #include "net/third_party/quiche/src/spdy/core/hpack/hpack_header_table.h" @@ -249,7 +249,7 @@ // Amount of trailing padding. Currently used just as an indicator of whether // OnPadLength has been called. - Http2Optional<size_t> opt_pad_length_; + quiche::QuicheOptional<size_t> opt_pad_length_; // Temporary buffers for the AltSvc fields. std::string alt_svc_origin_;