Chromium Code Reviews| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 public DevToolsNetworkInterceptor::Throttable { | 46 public DevToolsNetworkInterceptor::Throttable { |
| 47 public: | 47 public: |
| 48 static const char kDevToolsEmulateNetworkConditionsClientId[]; | 48 static const char kDevToolsEmulateNetworkConditionsClientId[]; |
| 49 | 49 |
| 50 DevToolsNetworkTransaction( | 50 DevToolsNetworkTransaction( |
| 51 DevToolsNetworkController* controller, | 51 DevToolsNetworkController* controller, |
| 52 scoped_ptr<net::HttpTransaction> network_transaction); | 52 scoped_ptr<net::HttpTransaction> network_transaction); |
| 53 | 53 |
| 54 ~DevToolsNetworkTransaction() override; | 54 ~DevToolsNetworkTransaction() override; |
| 55 | 55 |
| 56 // Checks if request contains DevTools specific headers. Found values are | |
| 57 // remembered and corresponding keys are removed from headers. | |
| 58 void ProcessRequest(); | |
| 59 | |
| 60 const std::string& client_id() const { | |
| 61 return client_id_; | |
| 62 } | |
| 63 | |
| 64 // DevToolsNetworkInterceptor::Throttable implementation. | 56 // DevToolsNetworkInterceptor::Throttable implementation. |
| 65 bool HasStarted() override; | 57 bool HasStarted() override; |
| 66 bool HasFailed() override; | 58 bool HasFailed() override; |
| 67 void Fail() override; | 59 void Fail() override; |
| 68 int64_t ThrottledByteCount() override; | 60 int64_t ThrottledByteCount() override; |
| 69 void Throttled(int64_t count) override; | 61 void Throttled(int64_t count) override; |
| 70 void ThrottleFinished() override; | 62 void ThrottleFinished() override; |
| 71 void GetSendEndTiming(base::TimeTicks* send_end) override; | 63 void GetSendEndTiming(base::TimeTicks* send_end) override; |
| 72 | 64 |
| 73 // HttpTransaction methods: | 65 // HttpTransaction methods: |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 103 const BeforeNetworkStartCallback& callback) override; | 95 const BeforeNetworkStartCallback& callback) override; |
| 104 void SetBeforeProxyHeadersSentCallback( | 96 void SetBeforeProxyHeadersSentCallback( |
| 105 const BeforeProxyHeadersSentCallback& callback) override; | 97 const BeforeProxyHeadersSentCallback& callback) override; |
| 106 int ResumeNetworkStart() override; | 98 int ResumeNetworkStart() override; |
| 107 void GetConnectionAttempts(net::ConnectionAttempts* out) const override; | 99 void GetConnectionAttempts(net::ConnectionAttempts* out) const override; |
| 108 | 100 |
| 109 protected: | 101 protected: |
| 110 friend class test::DevToolsNetworkControllerHelper; | 102 friend class test::DevToolsNetworkControllerHelper; |
| 111 | 103 |
| 112 private: | 104 private: |
| 105 // Checks whether request contains | |
| 106 // "X-DevTools-Emulate-Network-Conditions-Client-Id"DevTools header. | |
|
pfeldman
2015/11/03 22:53:54
space missing
dgozman
2015/11/04 22:54:06
Done.
| |
| 107 // If it does, header is removed from request, and it's value is returned. | |
| 108 void ProcessRequest(std::string* client_id); | |
| 109 | |
| 113 // Proxy callback handler. Runs saved callback. | 110 // Proxy callback handler. Runs saved callback. |
| 114 void OnCallback(int result); | 111 void OnCallback(int result); |
| 115 | 112 |
| 116 DevToolsNetworkController* controller_; | 113 DevToolsNetworkController* controller_; |
| 117 base::WeakPtr<DevToolsNetworkInterceptor> interceptor_; | 114 base::WeakPtr<DevToolsNetworkInterceptor> interceptor_; |
| 118 | 115 |
| 119 // Modified request. Should be destructed after |network_transaction_| | 116 // Modified request. Should be destructed after |network_transaction_| |
| 120 scoped_ptr<net::HttpRequestInfo> custom_request_; | 117 scoped_ptr<net::HttpRequestInfo> custom_request_; |
| 121 | 118 |
| 122 // Real network transaction. | 119 // Real network transaction. |
| 123 scoped_ptr<net::HttpTransaction> network_transaction_; | 120 scoped_ptr<net::HttpTransaction> network_transaction_; |
| 124 | 121 |
| 125 const net::HttpRequestInfo* request_; | 122 const net::HttpRequestInfo* request_; |
| 126 | 123 |
| 127 // True if Fail was already invoked. | 124 // True if Fail was already invoked. |
| 128 bool failed_; | 125 bool failed_; |
| 129 | 126 |
| 130 // Value of "X-DevTools-Emulate-Network-Conditions-Client-Id" request header. | 127 // Value of request header. |
| 131 std::string client_id_; | 128 std::string client_id_; |
| 132 | 129 |
| 133 enum CallbackType { | 130 enum CallbackType { |
| 134 NONE, | 131 NONE, |
| 135 READ, | 132 READ, |
| 136 RESTART_IGNORING_LAST_ERROR, | 133 RESTART_IGNORING_LAST_ERROR, |
| 137 RESTART_WITH_AUTH, | 134 RESTART_WITH_AUTH, |
| 138 RESTART_WITH_CERTIFICATE, | 135 RESTART_WITH_CERTIFICATE, |
| 139 START | 136 START |
| 140 }; | 137 }; |
| 141 | 138 |
| 142 int SetupCallback( | 139 int SetupCallback( |
| 143 net::CompletionCallback callback, | 140 net::CompletionCallback callback, |
| 144 int result, | 141 int result, |
| 145 CallbackType callback_type); | 142 CallbackType callback_type); |
| 146 | 143 |
| 147 void Throttle(int result); | 144 void Throttle(int result); |
| 148 | 145 |
| 149 int throttled_result_; | 146 int throttled_result_; |
| 150 int64_t throttled_byte_count_; | 147 int64_t throttled_byte_count_; |
| 151 CallbackType callback_type_; | 148 CallbackType callback_type_; |
| 152 net::CompletionCallback proxy_callback_; | 149 net::CompletionCallback proxy_callback_; |
| 153 net::CompletionCallback callback_; | 150 net::CompletionCallback callback_; |
| 154 | 151 |
| 155 DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkTransaction); | 152 DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkTransaction); |
| 156 }; | 153 }; |
| 157 | 154 |
| 158 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_ | 155 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_ |
| OLD | NEW |