OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/browser/debugger/devtools_remote_listen_socket.h" | 5 #include "chrome/browser/debugger/devtools_remote_listen_socket.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 | 10 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 static const std::string kHandshakeString = "ChromeDevToolsHandshake"; | 157 static const std::string kHandshakeString = "ChromeDevToolsHandshake"; |
158 switch (state_) { | 158 switch (state_) { |
159 case HANDSHAKE: | 159 case HANDSHAKE: |
160 if (protocol_field_.compare(kHandshakeString)) { | 160 if (protocol_field_.compare(kHandshakeString)) { |
161 state_ = INVALID; | 161 state_ = INVALID; |
162 } else { | 162 } else { |
163 Send(kHandshakeString, true); | 163 Send(kHandshakeString, true); |
164 } | 164 } |
165 break; | 165 break; |
166 case HEADERS: { | 166 case HEADERS: { |
167 if (protocol_field_.size() > 0) { // not end-of-headers | 167 if (!protocol_field_.empty()) { // not end-of-headers |
168 std::string::size_type colon_pos = protocol_field_.find_first_of(":"); | 168 std::string::size_type colon_pos = protocol_field_.find_first_of(":"); |
169 if (colon_pos == std::string::npos) { | 169 if (colon_pos == std::string::npos) { |
170 // TODO(apavlov): handle the error (malformed header) | 170 // TODO(apavlov): handle the error (malformed header) |
171 } else { | 171 } else { |
172 const std::string header_name = protocol_field_.substr(0, colon_pos); | 172 const std::string header_name = protocol_field_.substr(0, colon_pos); |
173 std::string header_val = protocol_field_.substr(colon_pos + 1); | 173 std::string header_val = protocol_field_.substr(colon_pos + 1); |
174 header_map_[header_name] = header_val; | 174 header_map_[header_name] = header_val; |
175 } | 175 } |
176 } | 176 } |
177 break; | 177 break; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 send_buf += sent; | 252 send_buf += sent; |
253 len_left -= sent; | 253 len_left -= sent; |
254 } | 254 } |
255 base::PlatformThread::YieldCurrentThread(); | 255 base::PlatformThread::YieldCurrentThread(); |
256 } | 256 } |
257 } | 257 } |
258 | 258 |
259 void DevToolsRemoteListenSocket::Close() { | 259 void DevToolsRemoteListenSocket::Close() { |
260 ListenSocket::Close(); | 260 ListenSocket::Close(); |
261 } | 261 } |
OLD | NEW |