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/spdy/spdy_websocket_stream.h" | 5 #include "net/spdy/spdy_websocket_stream.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 int SpdyWebSocketStream::SendData(const char* data, int length) { | 65 int SpdyWebSocketStream::SendData(const char* data, int length) { |
66 if (!stream_) { | 66 if (!stream_) { |
67 NOTREACHED(); | 67 NOTREACHED(); |
68 return ERR_UNEXPECTED; | 68 return ERR_UNEXPECTED; |
69 } | 69 } |
70 DCHECK_GE(length, 0); | 70 DCHECK_GE(length, 0); |
71 pending_send_data_length_ = static_cast<size_t>(length); | 71 pending_send_data_length_ = static_cast<size_t>(length); |
72 scoped_refptr<IOBuffer> buf(new IOBuffer(length)); | 72 scoped_refptr<IOBuffer> buf(new IOBuffer(length)); |
73 memcpy(buf->data(), data, length); | 73 memcpy(buf->data(), data, length); |
74 stream_->SendStreamData(buf.get(), length, MORE_DATA_TO_SEND); | 74 stream_->SendData(buf.get(), length, MORE_DATA_TO_SEND); |
75 return ERR_IO_PENDING; | 75 return ERR_IO_PENDING; |
76 } | 76 } |
77 | 77 |
78 void SpdyWebSocketStream::Close() { | 78 void SpdyWebSocketStream::Close() { |
79 if (stream_) { | 79 if (stream_) { |
80 stream_->Close(); | 80 stream_->Close(); |
81 DCHECK(!stream_); | 81 DCHECK(!stream_); |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 void SpdyWebSocketStream::OnSendRequestHeadersComplete() { | 85 void SpdyWebSocketStream::OnRequestHeadersSent() { |
86 DCHECK(delegate_); | 86 DCHECK(delegate_); |
87 delegate_->OnSentSpdyHeaders(); | 87 delegate_->OnSentSpdyHeaders(); |
88 } | 88 } |
89 | 89 |
90 void SpdyWebSocketStream::OnSendBody() { | 90 int SpdyWebSocketStream::OnResponseHeadersReceived( |
91 CHECK(false); | |
92 } | |
93 | |
94 void SpdyWebSocketStream::OnSendBodyComplete() { | |
95 CHECK(false); | |
96 } | |
97 | |
98 int SpdyWebSocketStream::OnResponseReceived( | |
99 const SpdyHeaderBlock& response, | 91 const SpdyHeaderBlock& response, |
100 base::Time response_time, int status) { | 92 base::Time response_time, int status) { |
101 DCHECK(delegate_); | 93 DCHECK(delegate_); |
102 return delegate_->OnReceivedSpdyResponseHeader(response, status); | 94 return delegate_->OnReceivedSpdyResponseHeader(response, status); |
103 } | 95 } |
104 | 96 |
105 int SpdyWebSocketStream::OnDataReceived(scoped_ptr<SpdyBuffer> buffer) { | 97 int SpdyWebSocketStream::OnDataReceived(scoped_ptr<SpdyBuffer> buffer) { |
106 DCHECK(delegate_); | 98 DCHECK(delegate_); |
107 delegate_->OnReceivedSpdyData(buffer.Pass()); | 99 delegate_->OnReceivedSpdyData(buffer.Pass()); |
108 return OK; | 100 return OK; |
(...skipping 21 matching lines...) Expand all Loading... |
130 if (result == OK) { | 122 if (result == OK) { |
131 stream_ = stream_request_.ReleaseStream(); | 123 stream_ = stream_request_.ReleaseStream(); |
132 DCHECK(stream_); | 124 DCHECK(stream_); |
133 stream_->SetDelegate(this); | 125 stream_->SetDelegate(this); |
134 } | 126 } |
135 DCHECK(delegate_); | 127 DCHECK(delegate_); |
136 delegate_->OnCreatedSpdyStream(result); | 128 delegate_->OnCreatedSpdyStream(result); |
137 } | 129 } |
138 | 130 |
139 } // namespace net | 131 } // namespace net |
OLD | NEW |