Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_ | |
| 6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_ | |
| 7 | |
| 8 #include "net/base/completion_callback.h" | |
| 9 #include "net/base/load_states.h" | |
| 10 #include "net/base/net_export.h" | |
| 11 #include "net/base/request_priority.h" | |
| 12 #include "net/base/upload_progress.h" | |
| 13 #include "net/http/http_transaction.h" | |
| 14 #include "net/websockets/websocket_handshake_stream_base.h" | |
| 15 | |
| 16 class DevToolsNetworkController; | |
| 17 class GURL; | |
| 18 | |
| 19 namespace net { | |
| 20 class AuthCredentials; | |
| 21 class BoundNetLog; | |
| 22 class HttpRequestHeaders; | |
| 23 struct HttpRequestInfo; | |
| 24 class HttpResponseInfo; | |
| 25 class HttpNetworkSession; | |
| 26 class IOBuffer; | |
| 27 struct LoadTimingInfo; | |
| 28 class X509Certificate; | |
| 29 } // namespace net | |
| 30 | |
| 31 // DevToolsNetworkTransaction is a "decorator" for network transaction. All | |
|
mmenke
2014/04/18 15:41:42
wrapper is the more commonly used term.
eustas
2014/04/21 11:34:59
Done.
| |
| 32 // HttpTransaction methods are proxied to real transaction, but |callback| | |
| 33 // parameter is saved and replaced with proxy callback. Fail method should be | |
| 34 // used to simulate network outage. It runs saved callback (if any) with | |
| 35 // net::ERR_INTERNET_DISCONNECTED result value. | |
| 36 class NET_EXPORT DevToolsNetworkTransaction : public net::HttpTransaction { | |
| 37 public: | |
| 38 DevToolsNetworkTransaction( | |
| 39 DevToolsNetworkController* controller, | |
| 40 scoped_ptr<net::HttpTransaction> network_transaction); | |
| 41 | |
| 42 virtual ~DevToolsNetworkTransaction(); | |
| 43 | |
| 44 const GURL& url() const { return url_; } | |
| 45 bool started() const { return started_; } | |
| 46 bool has_devtools_request_header() const { | |
| 47 return has_devtools_request_header_; } | |
| 48 | |
| 49 // Runs callback (if any) with net::ERR_INTERNET_DISCONNECTED result value. | |
| 50 void Fail(); | |
| 51 | |
| 52 // HttpTransaction methods: | |
| 53 virtual int Start( | |
| 54 const net::HttpRequestInfo* request_info, | |
| 55 const net::CompletionCallback& callback, | |
| 56 const net::BoundNetLog& net_log) OVERRIDE; | |
| 57 virtual int RestartIgnoringLastError( | |
| 58 const net::CompletionCallback& callback) OVERRIDE; | |
| 59 virtual int RestartWithCertificate( | |
| 60 net::X509Certificate* client_cert, | |
| 61 const net::CompletionCallback& callback) OVERRIDE; | |
| 62 virtual int RestartWithAuth( | |
| 63 const net::AuthCredentials& credentials, | |
| 64 const net::CompletionCallback& callback) OVERRIDE; | |
| 65 virtual bool IsReadyToRestartForAuth() OVERRIDE; | |
| 66 | |
| 67 virtual int Read( | |
| 68 net::IOBuffer* buf, | |
| 69 int buf_len, | |
| 70 const net::CompletionCallback& callback) OVERRIDE; | |
| 71 virtual void StopCaching() OVERRIDE; | |
| 72 virtual bool GetFullRequestHeaders( | |
| 73 net::HttpRequestHeaders* headers) const OVERRIDE; | |
| 74 virtual int64 GetTotalReceivedBytes() const OVERRIDE; | |
| 75 virtual void DoneReading() OVERRIDE; | |
| 76 virtual const net::HttpResponseInfo* GetResponseInfo() const OVERRIDE; | |
| 77 virtual net::LoadState GetLoadState() const OVERRIDE; | |
| 78 virtual net::UploadProgress GetUploadProgress() const OVERRIDE; | |
| 79 virtual void SetQuicServerInfo( | |
| 80 net::QuicServerInfo* quic_server_info) OVERRIDE; | |
| 81 virtual bool GetLoadTimingInfo( | |
| 82 net::LoadTimingInfo* load_timing_info) const OVERRIDE; | |
| 83 virtual void SetPriority(net::RequestPriority priority) OVERRIDE; | |
| 84 virtual void SetWebSocketHandshakeStreamCreateHelper( | |
| 85 net::WebSocketHandshakeStreamBase::CreateHelper* create_helper) OVERRIDE; | |
| 86 virtual void SetBeforeNetworkStartCallback( | |
| 87 const BeforeNetworkStartCallback& callback) OVERRIDE; | |
| 88 virtual int ResumeNetworkStart() OVERRIDE; | |
| 89 | |
| 90 private: | |
| 91 // Proxy callback handler. Runs saved callback. | |
| 92 void OnCallback(int result); | |
| 93 | |
| 94 // Transaction id. | |
| 95 const uint64 id_; | |
| 96 | |
| 97 DevToolsNetworkController* controller_; | |
| 98 | |
| 99 // Real network transaction. | |
| 100 scoped_ptr<net::HttpTransaction> network_transaction_; | |
| 101 | |
| 102 // Request URL captured when transaction is started. | |
| 103 GURL url_; | |
| 104 | |
| 105 // True if Start was already invoked. | |
| 106 bool started_; | |
| 107 | |
| 108 // True if request headers contain specific DevTools key. | |
| 109 bool has_devtools_request_header_; | |
| 110 | |
| 111 // True if Fail was already invoked. | |
| 112 bool failed_; | |
| 113 | |
| 114 net::CompletionCallback proxy_callback_; | |
| 115 net::CompletionCallback callback_; | |
| 116 | |
| 117 DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkTransaction); | |
| 118 }; | |
| 119 | |
| 120 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_ | |
| OLD | NEW |