Chromium Code Reviews| Index: chrome/browser/devtools/devtools_network_transaction.h |
| diff --git a/chrome/browser/devtools/devtools_network_transaction.h b/chrome/browser/devtools/devtools_network_transaction.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a8557bc8062afd566bce1a8536d75e53b85a221e |
| --- /dev/null |
| +++ b/chrome/browser/devtools/devtools_network_transaction.h |
| @@ -0,0 +1,118 @@ |
| +// 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 CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_ |
| +#define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_ |
| + |
| +#include "net/base/completion_callback.h" |
| +#include "net/base/load_states.h" |
| +#include "net/base/net_export.h" |
| +#include "net/base/request_priority.h" |
| +#include "net/base/upload_progress.h" |
| +#include "net/http/http_transaction.h" |
| +#include "net/websockets/websocket_handshake_stream_base.h" |
| + |
| +class DevToolsNetworkController; |
| +class GURL; |
| + |
| +namespace net { |
| +class AuthCredentials; |
| +class BoundNetLog; |
| +class HttpRequestHeaders; |
| +struct HttpRequestInfo; |
| +class HttpResponseInfo; |
| +class HttpNetworkSession; |
| +class IOBuffer; |
| +struct LoadTimingInfo; |
| +class X509Certificate; |
| +} // namespace net |
|
mmenke
2014/04/21 17:16:51
nit: two spaces before comment or remove comment.
eustas
2014/04/22 14:23:09
Done.
|
| + |
| +// DevToolsNetworkTransaction is a wrapper for network transaction. All |
| +// HttpTransaction methods are proxied to real transaction, but |callback| |
| +// parameter is saved and replaced with proxy callback. Fail method should be |
| +// used to simulate network outage. It runs saved callback (if any) with |
| +// net::ERR_INTERNET_DISCONNECTED result value. |
| +class NET_EXPORT DevToolsNetworkTransaction : public net::HttpTransaction { |
| + public: |
| + DevToolsNetworkTransaction( |
| + DevToolsNetworkController* controller, |
| + scoped_ptr<net::HttpTransaction> network_transaction); |
|
mmenke
2014/04/21 17:16:51
include scoped_ptr.h
eustas
2014/04/22 14:23:09
Done.
|
| + |
| + virtual ~DevToolsNetworkTransaction(); |
| + |
| + const GURL& url() const { return url_; } |
| + bool started() const { return started_; } |
| + bool failed() const { return failed_; } |
| + bool has_devtools_request_header() const { |
| + return has_devtools_request_header_; } |
| + |
| + // Runs callback (if any) with net::ERR_INTERNET_DISCONNECTED result value. |
| + void Fail(); |
| + |
| + // HttpTransaction methods: |
| + virtual int Start( |
| + const net::HttpRequestInfo* request_info, |
| + const net::CompletionCallback& callback, |
| + const net::BoundNetLog& net_log) OVERRIDE; |
| + virtual int RestartIgnoringLastError( |
| + const net::CompletionCallback& callback) OVERRIDE; |
| + virtual int RestartWithCertificate( |
| + net::X509Certificate* client_cert, |
| + const net::CompletionCallback& callback) OVERRIDE; |
| + virtual int RestartWithAuth( |
| + const net::AuthCredentials& credentials, |
| + const net::CompletionCallback& callback) OVERRIDE; |
| + virtual bool IsReadyToRestartForAuth() OVERRIDE; |
| + |
| + virtual int Read( |
| + net::IOBuffer* buf, |
| + int buf_len, |
| + const net::CompletionCallback& callback) OVERRIDE; |
| + virtual void StopCaching() OVERRIDE; |
| + virtual bool GetFullRequestHeaders( |
| + net::HttpRequestHeaders* headers) const OVERRIDE; |
| + virtual int64 GetTotalReceivedBytes() const OVERRIDE; |
| + virtual void DoneReading() OVERRIDE; |
| + virtual const net::HttpResponseInfo* GetResponseInfo() const OVERRIDE; |
| + virtual net::LoadState GetLoadState() const OVERRIDE; |
| + virtual net::UploadProgress GetUploadProgress() const OVERRIDE; |
| + virtual void SetQuicServerInfo( |
| + net::QuicServerInfo* quic_server_info) OVERRIDE; |
| + virtual bool GetLoadTimingInfo( |
| + net::LoadTimingInfo* load_timing_info) const OVERRIDE; |
| + virtual void SetPriority(net::RequestPriority priority) OVERRIDE; |
| + virtual void SetWebSocketHandshakeStreamCreateHelper( |
| + net::WebSocketHandshakeStreamBase::CreateHelper* create_helper) OVERRIDE; |
| + virtual void SetBeforeNetworkStartCallback( |
| + const BeforeNetworkStartCallback& callback) OVERRIDE; |
| + virtual int ResumeNetworkStart() OVERRIDE; |
| + |
| + private: |
| + // Proxy callback handler. Runs saved callback. |
| + void OnCallback(int result); |
| + |
| + DevToolsNetworkController* controller_; |
| + |
| + // Real network transaction. |
| + scoped_ptr<net::HttpTransaction> network_transaction_; |
| + |
| + // Request URL captured when transaction is started. |
| + GURL url_; |
| + |
| + // True if Start was already invoked. |
| + bool started_; |
| + |
| + // True if request headers contain specific DevTools key. |
| + bool has_devtools_request_header_; |
| + |
| + // True if Fail was already invoked. |
| + bool failed_; |
| + |
| + net::CompletionCallback proxy_callback_; |
| + net::CompletionCallback callback_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkTransaction); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_ |