OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_ | 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_ |
6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_ | 6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "net/base/completion_callback.h" | 10 #include "net/base/completion_callback.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 // HttpTransaction methods are proxied to real transaction, but |callback| | 38 // HttpTransaction methods are proxied to real transaction, but |callback| |
39 // parameter is saved and replaced with proxy callback. Fail method should be | 39 // parameter is saved and replaced with proxy callback. Fail method should be |
40 // used to simulate network outage. It runs saved callback (if any) with | 40 // used to simulate network outage. It runs saved callback (if any) with |
41 // net::ERR_INTERNET_DISCONNECTED result value. | 41 // net::ERR_INTERNET_DISCONNECTED result value. |
42 class DevToolsNetworkTransaction : public net::HttpTransaction { | 42 class DevToolsNetworkTransaction : public net::HttpTransaction { |
43 public: | 43 public: |
44 DevToolsNetworkTransaction( | 44 DevToolsNetworkTransaction( |
45 DevToolsNetworkController* controller, | 45 DevToolsNetworkController* controller, |
46 scoped_ptr<net::HttpTransaction> network_transaction); | 46 scoped_ptr<net::HttpTransaction> network_transaction); |
47 | 47 |
48 virtual ~DevToolsNetworkTransaction(); | 48 ~DevToolsNetworkTransaction() override; |
49 | 49 |
50 const net::HttpRequestInfo* request() const { return request_; } | 50 const net::HttpRequestInfo* request() const { return request_; } |
51 | 51 |
52 // Checks if request contains DevTools specific headers. Found values are | 52 // Checks if request contains DevTools specific headers. Found values are |
53 // remembered and corresponding keys are removed from headers. | 53 // remembered and corresponding keys are removed from headers. |
54 void ProcessRequest(); | 54 void ProcessRequest(); |
55 | 55 |
56 bool failed() const { return failed_; } | 56 bool failed() const { return failed_; } |
57 | 57 |
58 // Runs callback (if any) with net::ERR_INTERNET_DISCONNECTED result value. | 58 // Runs callback (if any) with net::ERR_INTERNET_DISCONNECTED result value. |
59 void Fail(); | 59 void Fail(); |
60 | 60 |
61 int64_t throttled_byte_count() const { return throttled_byte_count_; } | 61 int64_t throttled_byte_count() const { return throttled_byte_count_; } |
62 void DecreaseThrottledByteCount(int64_t delta) { | 62 void DecreaseThrottledByteCount(int64_t delta) { |
63 throttled_byte_count_ -= delta; | 63 throttled_byte_count_ -= delta; |
64 } | 64 } |
65 | 65 |
66 const std::string& request_initiator() const { return request_initiator_; } | 66 const std::string& request_initiator() const { return request_initiator_; } |
67 | 67 |
68 const std::string& client_id() const { | 68 const std::string& client_id() const { |
69 return client_id_; | 69 return client_id_; |
70 } | 70 } |
71 | 71 |
72 void FireThrottledCallback(); | 72 void FireThrottledCallback(); |
73 | 73 |
74 // HttpTransaction methods: | 74 // HttpTransaction methods: |
75 virtual int Start( | 75 int Start(const net::HttpRequestInfo* request, |
76 const net::HttpRequestInfo* request, | 76 const net::CompletionCallback& callback, |
77 const net::CompletionCallback& callback, | 77 const net::BoundNetLog& net_log) override; |
78 const net::BoundNetLog& net_log) override; | 78 int RestartIgnoringLastError( |
79 virtual int RestartIgnoringLastError( | |
80 const net::CompletionCallback& callback) override; | 79 const net::CompletionCallback& callback) override; |
81 virtual int RestartWithCertificate( | 80 int RestartWithCertificate(net::X509Certificate* client_cert, |
82 net::X509Certificate* client_cert, | 81 const net::CompletionCallback& callback) override; |
83 const net::CompletionCallback& callback) override; | 82 int RestartWithAuth(const net::AuthCredentials& credentials, |
84 virtual int RestartWithAuth( | 83 const net::CompletionCallback& callback) override; |
85 const net::AuthCredentials& credentials, | 84 bool IsReadyToRestartForAuth() override; |
86 const net::CompletionCallback& callback) override; | |
87 virtual bool IsReadyToRestartForAuth() override; | |
88 | 85 |
89 virtual int Read( | 86 int Read(net::IOBuffer* buf, |
90 net::IOBuffer* buf, | 87 int buf_len, |
91 int buf_len, | 88 const net::CompletionCallback& callback) override; |
92 const net::CompletionCallback& callback) override; | 89 void StopCaching() override; |
93 virtual void StopCaching() override; | 90 bool GetFullRequestHeaders(net::HttpRequestHeaders* headers) const override; |
94 virtual bool GetFullRequestHeaders( | 91 int64 GetTotalReceivedBytes() const override; |
95 net::HttpRequestHeaders* headers) const override; | 92 void DoneReading() override; |
96 virtual int64 GetTotalReceivedBytes() const override; | 93 const net::HttpResponseInfo* GetResponseInfo() const override; |
97 virtual void DoneReading() override; | 94 net::LoadState GetLoadState() const override; |
98 virtual const net::HttpResponseInfo* GetResponseInfo() const override; | 95 net::UploadProgress GetUploadProgress() const override; |
99 virtual net::LoadState GetLoadState() const override; | 96 void SetQuicServerInfo(net::QuicServerInfo* quic_server_info) override; |
100 virtual net::UploadProgress GetUploadProgress() const override; | 97 bool GetLoadTimingInfo(net::LoadTimingInfo* load_timing_info) const override; |
101 virtual void SetQuicServerInfo( | 98 void SetPriority(net::RequestPriority priority) override; |
102 net::QuicServerInfo* quic_server_info) override; | 99 void SetWebSocketHandshakeStreamCreateHelper( |
103 virtual bool GetLoadTimingInfo( | |
104 net::LoadTimingInfo* load_timing_info) const override; | |
105 virtual void SetPriority(net::RequestPriority priority) override; | |
106 virtual void SetWebSocketHandshakeStreamCreateHelper( | |
107 net::WebSocketHandshakeStreamBase::CreateHelper* create_helper) override; | 100 net::WebSocketHandshakeStreamBase::CreateHelper* create_helper) override; |
108 virtual void SetBeforeNetworkStartCallback( | 101 void SetBeforeNetworkStartCallback( |
109 const BeforeNetworkStartCallback& callback) override; | 102 const BeforeNetworkStartCallback& callback) override; |
110 virtual void SetBeforeProxyHeadersSentCallback( | 103 void SetBeforeProxyHeadersSentCallback( |
111 const BeforeProxyHeadersSentCallback& callback) override; | 104 const BeforeProxyHeadersSentCallback& callback) override; |
112 virtual int ResumeNetworkStart() override; | 105 int ResumeNetworkStart() override; |
113 | 106 |
114 protected: | 107 protected: |
115 friend class test::DevToolsNetworkControllerHelper; | 108 friend class test::DevToolsNetworkControllerHelper; |
116 | 109 |
117 private: | 110 private: |
118 // Proxy callback handler. Runs saved callback. | 111 // Proxy callback handler. Runs saved callback. |
119 void OnCallback(int result); | 112 void OnCallback(int result); |
120 | 113 |
121 DevToolsNetworkController* controller_; | 114 DevToolsNetworkController* controller_; |
122 base::WeakPtr<DevToolsNetworkInterceptor> interceptor_; | 115 base::WeakPtr<DevToolsNetworkInterceptor> interceptor_; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 int throttled_result_; | 153 int throttled_result_; |
161 int64_t throttled_byte_count_; | 154 int64_t throttled_byte_count_; |
162 CallbackType callback_type_; | 155 CallbackType callback_type_; |
163 net::CompletionCallback proxy_callback_; | 156 net::CompletionCallback proxy_callback_; |
164 net::CompletionCallback callback_; | 157 net::CompletionCallback callback_; |
165 | 158 |
166 DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkTransaction); | 159 DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkTransaction); |
167 }; | 160 }; |
168 | 161 |
169 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_ | 162 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_ |
OLD | NEW |