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 "net/base/completion_callback.h" | 9 #include "net/base/completion_callback.h" |
10 #include "net/base/load_states.h" | 10 #include "net/base/load_states.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 bool failed() const { return failed_; } | 45 bool failed() const { return failed_; } |
46 | 46 |
47 // Runs callback (if any) with net::ERR_INTERNET_DISCONNECTED result value. | 47 // Runs callback (if any) with net::ERR_INTERNET_DISCONNECTED result value. |
48 void Fail(); | 48 void Fail(); |
49 | 49 |
50 int64_t throttled_byte_count() const { return throttled_byte_count_; } | 50 int64_t throttled_byte_count() const { return throttled_byte_count_; } |
51 void DecreaseThrottledByteCount(int64_t delta) { | 51 void DecreaseThrottledByteCount(int64_t delta) { |
52 throttled_byte_count_ -= delta; | 52 throttled_byte_count_ -= delta; |
53 } | 53 } |
54 | 54 |
| 55 const std::string& request_initiator() const { return request_initiator_; } |
| 56 |
| 57 const std::string& client_id() const { |
| 58 return client_id_; |
| 59 } |
| 60 |
55 void FireThrottledCallback(); | 61 void FireThrottledCallback(); |
56 | 62 |
57 // HttpTransaction methods: | 63 // HttpTransaction methods: |
58 virtual int Start( | 64 virtual int Start( |
59 const net::HttpRequestInfo* request, | 65 const net::HttpRequestInfo* request, |
60 const net::CompletionCallback& callback, | 66 const net::CompletionCallback& callback, |
61 const net::BoundNetLog& net_log) OVERRIDE; | 67 const net::BoundNetLog& net_log) OVERRIDE; |
62 virtual int RestartIgnoringLastError( | 68 virtual int RestartIgnoringLastError( |
63 const net::CompletionCallback& callback) OVERRIDE; | 69 const net::CompletionCallback& callback) OVERRIDE; |
64 virtual int RestartWithCertificate( | 70 virtual int RestartWithCertificate( |
(...skipping 24 matching lines...) Expand all Loading... |
89 virtual void SetWebSocketHandshakeStreamCreateHelper( | 95 virtual void SetWebSocketHandshakeStreamCreateHelper( |
90 net::WebSocketHandshakeStreamBase::CreateHelper* create_helper) OVERRIDE; | 96 net::WebSocketHandshakeStreamBase::CreateHelper* create_helper) OVERRIDE; |
91 virtual void SetBeforeNetworkStartCallback( | 97 virtual void SetBeforeNetworkStartCallback( |
92 const BeforeNetworkStartCallback& callback) OVERRIDE; | 98 const BeforeNetworkStartCallback& callback) OVERRIDE; |
93 virtual int ResumeNetworkStart() OVERRIDE; | 99 virtual int ResumeNetworkStart() OVERRIDE; |
94 | 100 |
95 private: | 101 private: |
96 // Proxy callback handler. Runs saved callback. | 102 // Proxy callback handler. Runs saved callback. |
97 void OnCallback(int result); | 103 void OnCallback(int result); |
98 | 104 |
| 105 // Checks if request contains DevTools specific headers. Found values are |
| 106 // remembered and corresponding keys are removed from headers. |
| 107 void ProcessRequest(); |
| 108 |
99 DevToolsNetworkController* controller_; | 109 DevToolsNetworkController* controller_; |
100 | 110 |
101 // Real network transaction. | 111 // Real network transaction. |
102 scoped_ptr<net::HttpTransaction> network_transaction_; | 112 scoped_ptr<net::HttpTransaction> network_transaction_; |
103 | 113 |
104 const net::HttpRequestInfo* request_; | 114 const net::HttpRequestInfo* request_; |
105 | 115 |
106 // True if Start was already invoked. | 116 // True if Start was already invoked. |
107 bool started_; | 117 bool started_; |
108 | 118 |
109 // True if Fail was already invoked. | 119 // True if Fail was already invoked. |
110 bool failed_; | 120 bool failed_; |
111 | 121 |
| 122 // Value of "X-DevTools-Request-Initiator" request header. |
| 123 std::string request_initiator_; |
| 124 |
| 125 // Value of "X-DevTools-Emulate-Network-Conditions-Client-Id" request header. |
| 126 std::string client_id_; |
| 127 |
| 128 scoped_ptr<net::HttpRequestInfo> custom_request_; |
| 129 |
112 enum CallbackType { | 130 enum CallbackType { |
113 NONE, | 131 NONE, |
114 READ, | 132 READ, |
115 RESTART_IGNORING_LAST_ERROR, | 133 RESTART_IGNORING_LAST_ERROR, |
116 RESTART_WITH_AUTH, | 134 RESTART_WITH_AUTH, |
117 RESTART_WITH_CERTIFICATE, | 135 RESTART_WITH_CERTIFICATE, |
118 START | 136 START |
119 }; | 137 }; |
120 | 138 |
121 int SetupCallback( | 139 int SetupCallback( |
122 net::CompletionCallback callback, | 140 net::CompletionCallback callback, |
123 int result, | 141 int result, |
124 CallbackType callback_type); | 142 CallbackType callback_type); |
125 | 143 |
126 void Throttle(int result); | 144 void Throttle(int result); |
127 | 145 |
128 int throttled_result_; | 146 int throttled_result_; |
129 int64_t throttled_byte_count_; | 147 int64_t throttled_byte_count_; |
130 CallbackType callback_type_; | 148 CallbackType callback_type_; |
131 net::CompletionCallback proxy_callback_; | 149 net::CompletionCallback proxy_callback_; |
132 net::CompletionCallback callback_; | 150 net::CompletionCallback callback_; |
133 | 151 |
134 DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkTransaction); | 152 DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkTransaction); |
135 }; | 153 }; |
136 | 154 |
137 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_ | 155 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_ |
OLD | NEW |