| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/websockets/websocket_job.h" | 5 #include "net/websockets/websocket_job.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/string_tokenizer.h" | 9 #include "base/string_tokenizer.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 Singleton<WebSocketThrottle>::get()->PutInQueue(this); | 166 Singleton<WebSocketThrottle>::get()->PutInQueue(this); |
| 167 if (!waiting_) | 167 if (!waiting_) |
| 168 return OK; | 168 return OK; |
| 169 callback_ = callback; | 169 callback_ = callback; |
| 170 AddRef(); // Balanced when callback_ becomes NULL. | 170 AddRef(); // Balanced when callback_ becomes NULL. |
| 171 return ERR_IO_PENDING; | 171 return ERR_IO_PENDING; |
| 172 } | 172 } |
| 173 | 173 |
| 174 void WebSocketJob::OnConnected( | 174 void WebSocketJob::OnConnected( |
| 175 SocketStream* socket, int max_pending_send_allowed) { | 175 SocketStream* socket, int max_pending_send_allowed) { |
| 176 if (state_ == CLOSED) |
| 177 return; |
| 176 DCHECK_EQ(CONNECTING, state_); | 178 DCHECK_EQ(CONNECTING, state_); |
| 177 if (delegate_) | 179 if (delegate_) |
| 178 delegate_->OnConnected(socket, max_pending_send_allowed); | 180 delegate_->OnConnected(socket, max_pending_send_allowed); |
| 179 } | 181 } |
| 180 | 182 |
| 181 void WebSocketJob::OnSentData(SocketStream* socket, int amount_sent) { | 183 void WebSocketJob::OnSentData(SocketStream* socket, int amount_sent) { |
| 182 DCHECK_NE(INITIALIZED, state_); | 184 DCHECK_NE(INITIALIZED, state_); |
| 183 if (state_ == CLOSED) | 185 if (state_ == CLOSED) |
| 184 return; | 186 return; |
| 185 if (state_ == CONNECTING) { | 187 if (state_ == CONNECTING) { |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 socket_->Close(); | 489 socket_->Close(); |
| 488 return; | 490 return; |
| 489 } | 491 } |
| 490 current_buffer_ = new DrainableIOBuffer( | 492 current_buffer_ = new DrainableIOBuffer( |
| 491 send_frame_handler_->GetCurrentBuffer(), | 493 send_frame_handler_->GetCurrentBuffer(), |
| 492 send_frame_handler_->GetCurrentBufferSize()); | 494 send_frame_handler_->GetCurrentBufferSize()); |
| 493 socket_->SendData(current_buffer_->data(), current_buffer_->BytesRemaining()); | 495 socket_->SendData(current_buffer_->data(), current_buffer_->BytesRemaining()); |
| 494 } | 496 } |
| 495 | 497 |
| 496 } // namespace net | 498 } // namespace net |
| OLD | NEW |