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 | |
|
mmenke
2014/04/21 17:16:51
nit: two spaces before comment or remove comment.
eustas
2014/04/22 14:23:09
Done.
| |
| 30 | |
| 31 // DevToolsNetworkTransaction is a wrapper for network transaction. All | |
| 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); | |
|
mmenke
2014/04/21 17:16:51
include scoped_ptr.h
eustas
2014/04/22 14:23:09
Done.
| |
| 41 | |
| 42 virtual ~DevToolsNetworkTransaction(); | |
| 43 | |
| 44 const GURL& url() const { return url_; } | |
| 45 bool started() const { return started_; } | |
| 46 bool failed() const { return failed_; } | |
| 47 bool has_devtools_request_header() const { | |
| 48 return has_devtools_request_header_; } | |
| 49 | |
| 50 // Runs callback (if any) with net::ERR_INTERNET_DISCONNECTED result value. | |
| 51 void Fail(); | |
| 52 | |
| 53 // HttpTransaction methods: | |
| 54 virtual int Start( | |
| 55 const net::HttpRequestInfo* request_info, | |
| 56 const net::CompletionCallback& callback, | |
| 57 const net::BoundNetLog& net_log) OVERRIDE; | |
| 58 virtual int RestartIgnoringLastError( | |
| 59 const net::CompletionCallback& callback) OVERRIDE; | |
| 60 virtual int RestartWithCertificate( | |
| 61 net::X509Certificate* client_cert, | |
| 62 const net::CompletionCallback& callback) OVERRIDE; | |
| 63 virtual int RestartWithAuth( | |
| 64 const net::AuthCredentials& credentials, | |
| 65 const net::CompletionCallback& callback) OVERRIDE; | |
| 66 virtual bool IsReadyToRestartForAuth() OVERRIDE; | |
| 67 | |
| 68 virtual int Read( | |
| 69 net::IOBuffer* buf, | |
| 70 int buf_len, | |
| 71 const net::CompletionCallback& callback) OVERRIDE; | |
| 72 virtual void StopCaching() OVERRIDE; | |
| 73 virtual bool GetFullRequestHeaders( | |
| 74 net::HttpRequestHeaders* headers) const OVERRIDE; | |
| 75 virtual int64 GetTotalReceivedBytes() const OVERRIDE; | |
| 76 virtual void DoneReading() OVERRIDE; | |
| 77 virtual const net::HttpResponseInfo* GetResponseInfo() const OVERRIDE; | |
| 78 virtual net::LoadState GetLoadState() const OVERRIDE; | |
| 79 virtual net::UploadProgress GetUploadProgress() const OVERRIDE; | |
| 80 virtual void SetQuicServerInfo( | |
| 81 net::QuicServerInfo* quic_server_info) OVERRIDE; | |
| 82 virtual bool GetLoadTimingInfo( | |
| 83 net::LoadTimingInfo* load_timing_info) const OVERRIDE; | |
| 84 virtual void SetPriority(net::RequestPriority priority) OVERRIDE; | |
| 85 virtual void SetWebSocketHandshakeStreamCreateHelper( | |
| 86 net::WebSocketHandshakeStreamBase::CreateHelper* create_helper) OVERRIDE; | |
| 87 virtual void SetBeforeNetworkStartCallback( | |
| 88 const BeforeNetworkStartCallback& callback) OVERRIDE; | |
| 89 virtual int ResumeNetworkStart() OVERRIDE; | |
| 90 | |
| 91 private: | |
| 92 // Proxy callback handler. Runs saved callback. | |
| 93 void OnCallback(int result); | |
| 94 | |
| 95 DevToolsNetworkController* controller_; | |
| 96 | |
| 97 // Real network transaction. | |
| 98 scoped_ptr<net::HttpTransaction> network_transaction_; | |
| 99 | |
| 100 // Request URL captured when transaction is started. | |
| 101 GURL url_; | |
| 102 | |
| 103 // True if Start was already invoked. | |
| 104 bool started_; | |
| 105 | |
| 106 // True if request headers contain specific DevTools key. | |
| 107 bool has_devtools_request_header_; | |
| 108 | |
| 109 // True if Fail was already invoked. | |
| 110 bool failed_; | |
| 111 | |
| 112 net::CompletionCallback proxy_callback_; | |
| 113 net::CompletionCallback callback_; | |
| 114 | |
| 115 DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkTransaction); | |
| 116 }; | |
| 117 | |
| 118 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_ | |
| OLD | NEW |