| 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/spdy/spdy_session.h" | 5 #include "net/spdy/spdy_session.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/linked_ptr.h" | 8 #include "base/linked_ptr.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 dict->SetInteger("id", id_); | 55 dict->SetInteger("id", id_); |
| 56 if (associated_stream_) | 56 if (associated_stream_) |
| 57 dict->SetInteger("associated_stream", associated_stream_); | 57 dict->SetInteger("associated_stream", associated_stream_); |
| 58 return dict; | 58 return dict; |
| 59 } | 59 } |
| 60 | 60 |
| 61 namespace { | 61 namespace { |
| 62 | 62 |
| 63 const int kReadBufferSize = 8 * 1024; | 63 const int kReadBufferSize = 8 * 1024; |
| 64 | 64 |
| 65 void AdjustSocketBufferSizes(ClientSocket* socket) { | |
| 66 // Adjust socket buffer sizes. | |
| 67 // SPDY uses one socket, and we want a really big buffer. | |
| 68 // This greatly helps on links with packet loss - we can even | |
| 69 // outperform Vista's dynamic window sizing algorithm. | |
| 70 // TODO(mbelshe): more study. | |
| 71 const int kSocketBufferSize = 512 * 1024; | |
| 72 socket->SetReceiveBufferSize(kSocketBufferSize); | |
| 73 socket->SetSendBufferSize(kSocketBufferSize); | |
| 74 } | |
| 75 | |
| 76 class NetLogSpdySessionParameter : public NetLog::EventParameters { | 65 class NetLogSpdySessionParameter : public NetLog::EventParameters { |
| 77 public: | 66 public: |
| 78 NetLogSpdySessionParameter(const HostPortProxyPair& host_pair) | 67 NetLogSpdySessionParameter(const HostPortProxyPair& host_pair) |
| 79 : host_pair_(host_pair) {} | 68 : host_pair_(host_pair) {} |
| 80 virtual Value* ToValue() const { | 69 virtual Value* ToValue() const { |
| 81 DictionaryValue* dict = new DictionaryValue(); | 70 DictionaryValue* dict = new DictionaryValue(); |
| 82 dict->Set("host", new StringValue(host_pair_.first.ToString())); | 71 dict->Set("host", new StringValue(host_pair_.first.ToString())); |
| 83 dict->Set("proxy", new StringValue(host_pair_.second.ToPacString())); | 72 dict->Set("proxy", new StringValue(host_pair_.second.ToPacString())); |
| 84 return dict; | 73 return dict; |
| 85 } | 74 } |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 net_log_.EndEvent(NetLog::TYPE_SPDY_SESSION, NULL); | 276 net_log_.EndEvent(NetLog::TYPE_SPDY_SESSION, NULL); |
| 288 } | 277 } |
| 289 | 278 |
| 290 net::Error SpdySession::InitializeWithSocket( | 279 net::Error SpdySession::InitializeWithSocket( |
| 291 ClientSocketHandle* connection, | 280 ClientSocketHandle* connection, |
| 292 bool is_secure, | 281 bool is_secure, |
| 293 int certificate_error_code) { | 282 int certificate_error_code) { |
| 294 static base::StatsCounter spdy_sessions("spdy.sessions"); | 283 static base::StatsCounter spdy_sessions("spdy.sessions"); |
| 295 spdy_sessions.Increment(); | 284 spdy_sessions.Increment(); |
| 296 | 285 |
| 297 AdjustSocketBufferSizes(connection->socket()); | |
| 298 | |
| 299 state_ = CONNECTED; | 286 state_ = CONNECTED; |
| 300 connection_.reset(connection); | 287 connection_.reset(connection); |
| 301 is_secure_ = is_secure; | 288 is_secure_ = is_secure; |
| 302 certificate_error_code_ = certificate_error_code; | 289 certificate_error_code_ = certificate_error_code; |
| 303 | 290 |
| 304 // Write out any data that we might have to send, such as the settings frame. | 291 // Write out any data that we might have to send, such as the settings frame. |
| 305 WriteSocketLater(); | 292 WriteSocketLater(); |
| 306 net::Error error = ReadSocket(); | 293 net::Error error = ReadSocket(); |
| 307 if (error == ERR_IO_PENDING) | 294 if (error == ERR_IO_PENDING) |
| 308 return OK; | 295 return OK; |
| (...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 if (it == pending_callback_map_.end()) | 1414 if (it == pending_callback_map_.end()) |
| 1428 return; | 1415 return; |
| 1429 | 1416 |
| 1430 CompletionCallback* callback = it->second.callback; | 1417 CompletionCallback* callback = it->second.callback; |
| 1431 int result = it->second.result; | 1418 int result = it->second.result; |
| 1432 pending_callback_map_.erase(it); | 1419 pending_callback_map_.erase(it); |
| 1433 callback->Run(result); | 1420 callback->Run(result); |
| 1434 } | 1421 } |
| 1435 | 1422 |
| 1436 } // namespace net | 1423 } // namespace net |
| OLD | NEW |