electron/brightray/browser/net/devtools_network_transaction.h

109 lines
4.1 KiB
C
Raw Normal View History

2015-09-26 18:19:27 +00:00
// Copyright 2014 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 BRIGHTRAY_BROWSER_NET_DEVTOOLS_NETWORK_TRANSACTION_H_
#define BRIGHTRAY_BROWSER_NET_DEVTOOLS_NETWORK_TRANSACTION_H_
2015-09-26 18:19:27 +00:00
#include <stdint.h>
#include "base/memory/weak_ptr.h"
#include "brightray/browser/net/devtools_network_interceptor.h"
2015-09-26 18:19:27 +00:00
#include "net/base/completion_callback.h"
#include "net/base/load_states.h"
#include "net/base/request_priority.h"
#include "net/http/http_transaction.h"
namespace brightray {
class DevToolsNetworkController;
class DevToolsNetworkUploadDataStream;
2015-09-26 18:19:27 +00:00
class DevToolsNetworkTransaction : public net::HttpTransaction {
public:
static const char kDevToolsEmulateNetworkConditionsClientId[];
2015-09-26 18:19:27 +00:00
DevToolsNetworkTransaction(
DevToolsNetworkController* controller,
std::unique_ptr<net::HttpTransaction> network_transaction);
2015-09-26 18:19:27 +00:00
~DevToolsNetworkTransaction() override;
// HttpTransaction methods:
int Start(const net::HttpRequestInfo* request,
const net::CompletionCallback& callback,
2017-01-23 06:10:34 +00:00
const net::NetLogWithSource& net_log) override;
2015-09-26 18:19:27 +00:00
int RestartIgnoringLastError(
const net::CompletionCallback& callback) override;
int RestartWithCertificate(
scoped_refptr<net::X509Certificate> client_cert,
scoped_refptr<net::SSLPrivateKey> client_private_key,
const net::CompletionCallback& callback) override;
2015-09-26 18:19:27 +00:00
int RestartWithAuth(const net::AuthCredentials& credentials,
const net::CompletionCallback& callback) override;
bool IsReadyToRestartForAuth() override;
int Read(net::IOBuffer* buf,
int buf_len,
const net::CompletionCallback& callback) override;
void StopCaching() override;
bool GetFullRequestHeaders(net::HttpRequestHeaders* headers) const override;
int64_t GetTotalReceivedBytes() const override;
2015-12-07 11:55:01 +00:00
int64_t GetTotalSentBytes() const override;
2015-09-26 18:19:27 +00:00
void DoneReading() override;
const net::HttpResponseInfo* GetResponseInfo() const override;
net::LoadState GetLoadState() const override;
void SetQuicServerInfo(net::QuicServerInfo* quic_server_info) override;
bool GetLoadTimingInfo(net::LoadTimingInfo* load_timing_info) const override;
2015-12-07 11:55:01 +00:00
bool GetRemoteEndpoint(net::IPEndPoint* endpoint) const override;
2016-03-08 06:29:23 +00:00
void PopulateNetErrorDetails(net::NetErrorDetails* details) const override;
2015-09-26 18:19:27 +00:00
void SetPriority(net::RequestPriority priority) override;
void SetWebSocketHandshakeStreamCreateHelper(
net::WebSocketHandshakeStreamBase::CreateHelper* create_helper) override;
void SetBeforeNetworkStartCallback(
const BeforeNetworkStartCallback& callback) override;
2016-09-06 08:22:52 +00:00
void SetBeforeHeadersSentCallback(
const BeforeHeadersSentCallback& callback) override;
2015-09-26 18:19:27 +00:00
int ResumeNetworkStart() override;
void GetConnectionAttempts(net::ConnectionAttempts* out) const override;
private:
void Fail();
bool CheckFailed();
void IOCallback(const net::CompletionCallback& callback,
bool start,
int result);
int Throttle(const net::CompletionCallback& callback,
bool start,
int result);
void ThrottleCallback(const net::CompletionCallback& callback,
int result,
int64_t bytes);
DevToolsNetworkInterceptor::ThrottleCallback throttle_callback_;
int64_t throttled_byte_count_;
2015-09-26 18:19:27 +00:00
DevToolsNetworkController* controller_;
base::WeakPtr<DevToolsNetworkInterceptor> interceptor_;
// Modified upload data stream. Should be destructed after |custom_request_|.
std::unique_ptr<DevToolsNetworkUploadDataStream> custom_upload_data_stream_;
// Modified request. Should be destructed after |transaction_|.
std::unique_ptr<net::HttpRequestInfo> custom_request_;
2015-09-26 18:19:27 +00:00
// Original network transaction.
std::unique_ptr<net::HttpTransaction> transaction_;
2015-09-26 18:19:27 +00:00
const net::HttpRequestInfo* request_;
// True if Fail was already invoked.
bool failed_;
DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkTransaction);
};
} // namespace brightray
#endif // BRIGHTRAY_BROWSER_NET_DEVTOOLS_NETWORK_TRANSACTION_H_