| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/string_tokenizer.h" | 10 #include "base/string_tokenizer.h" |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 if (delegate_) | 264 if (delegate_) |
| 265 delegate_->OnError(socket, error); | 265 delegate_->OnError(socket, error); |
| 266 } | 266 } |
| 267 | 267 |
| 268 bool WebSocketJob::SendHandshakeRequest(const char* data, int len) { | 268 bool WebSocketJob::SendHandshakeRequest(const char* data, int len) { |
| 269 DCHECK_EQ(state_, CONNECTING); | 269 DCHECK_EQ(state_, CONNECTING); |
| 270 if (!handshake_request_->ParseRequest(data, len)) | 270 if (!handshake_request_->ParseRequest(data, len)) |
| 271 return false; | 271 return false; |
| 272 | 272 |
| 273 // handshake message is completed. | 273 // handshake message is completed. |
| 274 handshake_response_->set_protocol_version( |
| 275 handshake_request_->protocol_version()); |
| 274 AddCookieHeaderAndSend(); | 276 AddCookieHeaderAndSend(); |
| 275 // Just buffered in |handshake_request_|. | 277 // Just buffered in |handshake_request_|. |
| 276 return true; | 278 return true; |
| 277 } | 279 } |
| 278 | 280 |
| 279 void WebSocketJob::AddCookieHeaderAndSend() { | 281 void WebSocketJob::AddCookieHeaderAndSend() { |
| 280 int policy = OK; | 282 int policy = OK; |
| 281 if (socket_->context()->cookie_policy()) { | 283 if (socket_->context()->cookie_policy()) { |
| 282 GURL url_for_cookies = GetURLForCookies(); | 284 GURL url_for_cookies = GetURLForCookies(); |
| 283 policy = socket_->context()->cookie_policy()->CanGetCookies( | 285 policy = socket_->context()->cookie_policy()->CanGetCookies( |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 socket_->Close(); | 491 socket_->Close(); |
| 490 return; | 492 return; |
| 491 } | 493 } |
| 492 current_buffer_ = new DrainableIOBuffer( | 494 current_buffer_ = new DrainableIOBuffer( |
| 493 send_frame_handler_->GetCurrentBuffer(), | 495 send_frame_handler_->GetCurrentBuffer(), |
| 494 send_frame_handler_->GetCurrentBufferSize()); | 496 send_frame_handler_->GetCurrentBufferSize()); |
| 495 socket_->SendData(current_buffer_->data(), current_buffer_->BytesRemaining()); | 497 socket_->SendData(current_buffer_->data(), current_buffer_->BytesRemaining()); |
| 496 } | 498 } |
| 497 | 499 |
| 498 } // namespace net | 500 } // namespace net |
| OLD | NEW |