| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/tools/flip_server/spdy_interface.h" | 5 #include "net/tools/flip_server/spdy_interface.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 ~SpdyFrameDataFrame() override { delete frame; } | 32 ~SpdyFrameDataFrame() override { delete frame; } |
| 33 | 33 |
| 34 const SpdySerializedFrame* frame; | 34 const SpdySerializedFrame* frame; |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 SpdySM::SpdySM(SMConnection* connection, | 37 SpdySM::SpdySM(SMConnection* connection, |
| 38 SMInterface* sm_http_interface, | 38 SMInterface* sm_http_interface, |
| 39 EpollServer* epoll_server, | 39 EpollServer* epoll_server, |
| 40 MemoryCache* memory_cache, | 40 MemoryCache* memory_cache, |
| 41 FlipAcceptor* acceptor, | 41 FlipAcceptor* acceptor) |
| 42 SpdyMajorVersion spdy_version) | 42 : buffered_spdy_framer_(new BufferedSpdyFramer()), |
| 43 : buffered_spdy_framer_(new BufferedSpdyFramer(spdy_version)), | |
| 44 valid_spdy_session_(false), | 43 valid_spdy_session_(false), |
| 45 connection_(connection), | 44 connection_(connection), |
| 46 client_output_list_(connection->output_list()), | 45 client_output_list_(connection->output_list()), |
| 47 client_output_ordering_(connection), | 46 client_output_ordering_(connection), |
| 48 next_outgoing_stream_id_(2), | 47 next_outgoing_stream_id_(2), |
| 49 epoll_server_(epoll_server), | 48 epoll_server_(epoll_server), |
| 50 acceptor_(acceptor), | 49 acceptor_(acceptor), |
| 51 memory_cache_(memory_cache), | 50 memory_cache_(memory_cache), |
| 52 close_on_error_(false) { | 51 close_on_error_(false) { |
| 53 buffered_spdy_framer_->set_visitor(this); | 52 buffered_spdy_framer_->set_visitor(this); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 SMInterface* interface = it->second; | 232 SMInterface* interface = it->second; |
| 234 if (acceptor_->flip_handler_type_ == FLIP_HANDLER_PROXY) | 233 if (acceptor_->flip_handler_type_ == FLIP_HANDLER_PROXY) |
| 235 interface->ProcessWriteInput(nullptr, 0); | 234 interface->ProcessWriteInput(nullptr, 0); |
| 236 } | 235 } |
| 237 | 236 |
| 238 void SpdySM::OnStreamPadding(SpdyStreamId stream_id, size_t len) { | 237 void SpdySM::OnStreamPadding(SpdyStreamId stream_id, size_t len) { |
| 239 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: StreamPadding(" << stream_id | 238 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: StreamPadding(" << stream_id |
| 240 << ", [" << len << "])"; | 239 << ", [" << len << "])"; |
| 241 } | 240 } |
| 242 | 241 |
| 243 void SpdySM::OnSynStream(SpdyStreamId stream_id, | |
| 244 SpdyStreamId associated_stream_id, | |
| 245 SpdyPriority priority, | |
| 246 bool fin, | |
| 247 bool unidirectional, | |
| 248 const SpdyHeaderBlock& headers) { | |
| 249 std::string http_data; | |
| 250 bool is_https_scheme; | |
| 251 int ret = SpdyHandleNewStream( | |
| 252 stream_id, priority, headers, http_data, &is_https_scheme); | |
| 253 if (!ret) { | |
| 254 LOG(ERROR) << "SpdySM: Could not convert spdy into http."; | |
| 255 return; | |
| 256 } | |
| 257 // We've seen a valid looking SYN_STREAM, consider this to have | |
| 258 // been a real spdy session. | |
| 259 valid_spdy_session_ = true; | |
| 260 | |
| 261 if (acceptor_->flip_handler_type_ == FLIP_HANDLER_PROXY) { | |
| 262 std::string server_ip; | |
| 263 std::string server_port; | |
| 264 if (is_https_scheme) { | |
| 265 server_ip = acceptor_->https_server_ip_; | |
| 266 server_port = acceptor_->https_server_port_; | |
| 267 } else { | |
| 268 server_ip = acceptor_->http_server_ip_; | |
| 269 server_port = acceptor_->http_server_port_; | |
| 270 } | |
| 271 SMInterface* sm_http_interface = | |
| 272 FindOrMakeNewSMConnectionInterface(server_ip, server_port); | |
| 273 stream_to_smif_[stream_id] = sm_http_interface; | |
| 274 sm_http_interface->SetStreamID(stream_id); | |
| 275 sm_http_interface->ProcessWriteInput(http_data.c_str(), http_data.size()); | |
| 276 } | |
| 277 } | |
| 278 | |
| 279 void SpdySM::OnSynReply(SpdyStreamId stream_id, | |
| 280 bool fin, | |
| 281 const SpdyHeaderBlock& headers) { | |
| 282 // TODO(willchan): if there is an error parsing headers, we | |
| 283 // should send a RST_STREAM. | |
| 284 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: OnSynReply(" << stream_id << ")"; | |
| 285 } | |
| 286 | |
| 287 void SpdySM::OnHeaders(SpdyStreamId stream_id, | 242 void SpdySM::OnHeaders(SpdyStreamId stream_id, |
| 288 bool has_priority, | 243 bool has_priority, |
| 289 int weight, | 244 int weight, |
| 290 SpdyStreamId parent_stream_id, | 245 SpdyStreamId parent_stream_id, |
| 291 bool exclusive, | 246 bool exclusive, |
| 292 bool fin, | 247 bool fin, |
| 293 const SpdyHeaderBlock& headers) { | 248 const SpdyHeaderBlock& headers) { |
| 294 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: OnHeaders(" << stream_id << ")"; | 249 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: OnHeaders(" << stream_id << ")"; |
| 295 } | 250 } |
| 296 | 251 |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 num_to_write, | 555 num_to_write, |
| 601 0, | 556 0, |
| 602 should_compress); | 557 should_compress); |
| 603 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: GetOutput SendDataFrame[" | 558 VLOG(2) << ACCEPTOR_CLIENT_IDENT << "SpdySM: GetOutput SendDataFrame[" |
| 604 << mci->stream_id << "]: " << num_to_write; | 559 << mci->stream_id << "]: " << num_to_write; |
| 605 mci->body_bytes_consumed += num_to_write; | 560 mci->body_bytes_consumed += num_to_write; |
| 606 mci->bytes_sent += num_to_write; | 561 mci->bytes_sent += num_to_write; |
| 607 } | 562 } |
| 608 } | 563 } |
| 609 | 564 |
| 610 void SpdySM::CreateFramer(SpdyMajorVersion spdy_version) { | 565 void SpdySM::CreateFramer() { |
| 611 DCHECK(!buffered_spdy_framer_); | 566 DCHECK(!buffered_spdy_framer_); |
| 612 buffered_spdy_framer_.reset(new BufferedSpdyFramer(spdy_version)); | 567 buffered_spdy_framer_.reset(new BufferedSpdyFramer()); |
| 613 buffered_spdy_framer_->set_visitor(this); | 568 buffered_spdy_framer_->set_visitor(this); |
| 614 } | 569 } |
| 615 | 570 |
| 616 } // namespace net | 571 } // namespace net |
| OLD | NEW |