#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/grpc_support/include/bidirectional_stream_c.h"
#include <stdbool.h>
#include <memory>
#include <string>
#include <vector>
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/task/single_thread_task_runner.h"
#include "components/grpc_support/bidirectional_stream.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/base/request_priority.h"
#include "net/http/bidirectional_stream.h"
#include "net/http/bidirectional_stream_request_info.h"
#include "net/http/http_network_session.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
#include "net/http/http_transaction_factory.h"
#include "net/http/http_util.h"
#include "net/ssl/ssl_info.h"
#include "net/third_party/quiche/src/quiche/common/http/http_header_block.h"
#include "net/url_request/url_request_context.h"
#include "url/gurl.h"
namespace {
class HeadersArray : public bidirectional_stream_header_array { … };
HeadersArray::HeadersArray(const quiche::HttpHeaderBlock& header_block)
: … { … }
HeadersArray::~HeadersArray() { … }
class BidirectionalStreamAdapter
: public grpc_support::BidirectionalStream::Delegate { … };
BidirectionalStreamAdapter::BidirectionalStreamAdapter(
stream_engine* engine,
void* annotation,
const bidirectional_stream_callback* callback)
: … { … }
BidirectionalStreamAdapter::~BidirectionalStreamAdapter() { … }
void BidirectionalStreamAdapter::OnStreamReady() { … }
void BidirectionalStreamAdapter::OnHeadersReceived(
const quiche::HttpHeaderBlock& headers_block,
const char* negotiated_protocol) { … }
void BidirectionalStreamAdapter::OnDataRead(char* data, int size) { … }
void BidirectionalStreamAdapter::OnDataSent(const char* data) { … }
void BidirectionalStreamAdapter::OnTrailersReceived(
const quiche::HttpHeaderBlock& trailers_block) { … }
void BidirectionalStreamAdapter::OnSucceeded() { … }
void BidirectionalStreamAdapter::OnFailed(int error) { … }
void BidirectionalStreamAdapter::OnCanceled() { … }
grpc_support::BidirectionalStream* BidirectionalStreamAdapter::GetStream(
bidirectional_stream* stream) { … }
void BidirectionalStreamAdapter::DestroyAdapterForStream(
bidirectional_stream* stream) { … }
void BidirectionalStreamAdapter::DestroyOnNetworkThread() { … }
}
bidirectional_stream* bidirectional_stream_create(
stream_engine* engine,
void* annotation,
const bidirectional_stream_callback* callback) { … }
int bidirectional_stream_destroy(bidirectional_stream* stream) { … }
void bidirectional_stream_disable_auto_flush(bidirectional_stream* stream,
bool disable_auto_flush) { … }
void bidirectional_stream_delay_request_headers_until_flush(
bidirectional_stream* stream,
bool delay_headers_until_flush) { … }
int bidirectional_stream_start(bidirectional_stream* stream,
const char* url,
int priority,
const char* method,
const bidirectional_stream_header_array* headers,
bool end_of_stream) { … }
int bidirectional_stream_read(bidirectional_stream* stream,
char* buffer,
int capacity) { … }
int bidirectional_stream_write(bidirectional_stream* stream,
const char* buffer,
int count,
bool end_of_stream) { … }
void bidirectional_stream_flush(bidirectional_stream* stream) { … }
void bidirectional_stream_cancel(bidirectional_stream* stream) { … }