| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 } | 52 } |
| 53 | 53 |
| 54 SocketStreamHandleInternal::~SocketStreamHandleInternal() | 54 SocketStreamHandleInternal::~SocketStreamHandleInternal() |
| 55 { | 55 { |
| 56 m_handle = 0; | 56 m_handle = 0; |
| 57 } | 57 } |
| 58 | 58 |
| 59 void SocketStreamHandleInternal::connect(const KURL& url) | 59 void SocketStreamHandleInternal::connect(const KURL& url) |
| 60 { | 60 { |
| 61 m_socket = adoptPtr(WebKit::Platform::current()->createSocketStreamHandle())
; | 61 m_socket = adoptPtr(WebKit::Platform::current()->createSocketStreamHandle())
; |
| 62 LOG(Network, "connect"); | 62 LOG_INFO(Network, "connect"); |
| 63 ASSERT(m_socket); | 63 ASSERT(m_socket); |
| 64 ASSERT(m_handle); | 64 ASSERT(m_handle); |
| 65 if (m_handle->m_client) | 65 if (m_handle->m_client) |
| 66 m_handle->m_client->willOpenSocketStream(m_handle); | 66 m_handle->m_client->willOpenSocketStream(m_handle); |
| 67 m_socket->connect(url, this); | 67 m_socket->connect(url, this); |
| 68 } | 68 } |
| 69 | 69 |
| 70 int SocketStreamHandleInternal::send(const char* data, int len) | 70 int SocketStreamHandleInternal::send(const char* data, int len) |
| 71 { | 71 { |
| 72 LOG(Network, "send len=%d", len); | 72 LOG_INFO(Network, "send len=%d", len); |
| 73 // FIXME: |m_socket| should not be null here, but it seems that there is the | 73 // FIXME: |m_socket| should not be null here, but it seems that there is the |
| 74 // case. We should figure out such a path and fix it rather than checking | 74 // case. We should figure out such a path and fix it rather than checking |
| 75 // null here. | 75 // null here. |
| 76 if (!m_socket) { | 76 if (!m_socket) { |
| 77 LOG(Network, "m_socket is null when sending. It should not be."); | 77 LOG_INFO(Network, "m_socket is null when sending. It should not be."); |
| 78 return 0; | 78 return 0; |
| 79 } | 79 } |
| 80 if (m_pendingAmountSent + len > m_maxPendingSendAllowed) | 80 if (m_pendingAmountSent + len > m_maxPendingSendAllowed) |
| 81 len = m_maxPendingSendAllowed - m_pendingAmountSent; | 81 len = m_maxPendingSendAllowed - m_pendingAmountSent; |
| 82 | 82 |
| 83 if (len <= 0) | 83 if (len <= 0) |
| 84 return len; | 84 return len; |
| 85 WebKit::WebData webdata(data, len); | 85 WebKit::WebData webdata(data, len); |
| 86 if (m_socket->send(webdata)) { | 86 if (m_socket->send(webdata)) { |
| 87 m_pendingAmountSent += len; | 87 m_pendingAmountSent += len; |
| 88 LOG(Network, "sent"); | 88 LOG_INFO(Network, "sent"); |
| 89 return len; | 89 return len; |
| 90 } | 90 } |
| 91 LOG(Network, "busy. buffering"); | 91 LOG_INFO(Network, "busy. buffering"); |
| 92 return 0; | 92 return 0; |
| 93 } | 93 } |
| 94 | 94 |
| 95 void SocketStreamHandleInternal::close() | 95 void SocketStreamHandleInternal::close() |
| 96 { | 96 { |
| 97 LOG(Network, "close"); | 97 LOG_INFO(Network, "close"); |
| 98 if (m_socket) | 98 if (m_socket) |
| 99 m_socket->close(); | 99 m_socket->close(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void SocketStreamHandleInternal::didOpenStream(WebKit::WebSocketStreamHandle* so
cketHandle, int maxPendingSendAllowed) | 102 void SocketStreamHandleInternal::didOpenStream(WebKit::WebSocketStreamHandle* so
cketHandle, int maxPendingSendAllowed) |
| 103 { | 103 { |
| 104 LOG(Network, "SocketStreamHandleInternal::didOpen %d", | 104 LOG_INFO(Network, "SocketStreamHandleInternal::didOpen %d", |
| 105 maxPendingSendAllowed); | 105 maxPendingSendAllowed); |
| 106 ASSERT(maxPendingSendAllowed > 0); | 106 ASSERT(maxPendingSendAllowed > 0); |
| 107 if (m_handle && m_socket) { | 107 if (m_handle && m_socket) { |
| 108 ASSERT(socketHandle == m_socket.get()); | 108 ASSERT(socketHandle == m_socket.get()); |
| 109 m_maxPendingSendAllowed = maxPendingSendAllowed; | 109 m_maxPendingSendAllowed = maxPendingSendAllowed; |
| 110 m_handle->m_state = SocketStreamHandleBase::Open; | 110 m_handle->m_state = SocketStreamHandleBase::Open; |
| 111 if (m_handle->m_client) { | 111 if (m_handle->m_client) { |
| 112 m_handle->m_client->didOpenSocketStream(m_handle); | 112 m_handle->m_client->didOpenSocketStream(m_handle); |
| 113 return; | 113 return; |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 LOG(Network, "no m_handle or m_socket?"); | 116 LOG_INFO(Network, "no m_handle or m_socket?"); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void SocketStreamHandleInternal::didSendData(WebKit::WebSocketStreamHandle* sock
etHandle, int amountSent) | 119 void SocketStreamHandleInternal::didSendData(WebKit::WebSocketStreamHandle* sock
etHandle, int amountSent) |
| 120 { | 120 { |
| 121 LOG(Network, "SocketStreamHandleInternal::didSendData %d", amountSent); | 121 LOG_INFO(Network, "SocketStreamHandleInternal::didSendData %d", amountSent); |
| 122 ASSERT(amountSent > 0); | 122 ASSERT(amountSent > 0); |
| 123 if (m_handle && m_socket) { | 123 if (m_handle && m_socket) { |
| 124 ASSERT(socketHandle == m_socket.get()); | 124 ASSERT(socketHandle == m_socket.get()); |
| 125 m_pendingAmountSent -= amountSent; | 125 m_pendingAmountSent -= amountSent; |
| 126 ASSERT(m_pendingAmountSent >= 0); | 126 ASSERT(m_pendingAmountSent >= 0); |
| 127 m_handle->sendPendingData(); | 127 m_handle->sendPendingData(); |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 | 130 |
| 131 void SocketStreamHandleInternal::didReceiveData(WebKit::WebSocketStreamHandle* s
ocketHandle, const WebKit::WebData& data) | 131 void SocketStreamHandleInternal::didReceiveData(WebKit::WebSocketStreamHandle* s
ocketHandle, const WebKit::WebData& data) |
| 132 { | 132 { |
| 133 LOG(Network, "didReceiveData"); | 133 LOG_INFO(Network, "didReceiveData"); |
| 134 if (m_handle && m_socket) { | 134 if (m_handle && m_socket) { |
| 135 ASSERT(socketHandle == m_socket.get()); | 135 ASSERT(socketHandle == m_socket.get()); |
| 136 if (m_handle->m_client) | 136 if (m_handle->m_client) |
| 137 m_handle->m_client->didReceiveSocketStreamData(m_handle, data.data()
, data.size()); | 137 m_handle->m_client->didReceiveSocketStreamData(m_handle, data.data()
, data.size()); |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 | 140 |
| 141 void SocketStreamHandleInternal::didClose(WebKit::WebSocketStreamHandle* socketH
andle) | 141 void SocketStreamHandleInternal::didClose(WebKit::WebSocketStreamHandle* socketH
andle) |
| 142 { | 142 { |
| 143 LOG(Network, "didClose"); | 143 LOG_INFO(Network, "didClose"); |
| 144 if (m_handle && m_socket) { | 144 if (m_handle && m_socket) { |
| 145 ASSERT(socketHandle == m_socket.get()); | 145 ASSERT(socketHandle == m_socket.get()); |
| 146 m_socket.clear(); | 146 m_socket.clear(); |
| 147 SocketStreamHandle* h = m_handle; | 147 SocketStreamHandle* h = m_handle; |
| 148 m_handle = 0; | 148 m_handle = 0; |
| 149 if (h->m_client) | 149 if (h->m_client) |
| 150 h->m_client->didCloseSocketStream(h); | 150 h->m_client->didCloseSocketStream(h); |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 | 153 |
| 154 void SocketStreamHandleInternal::didFail(WebKit::WebSocketStreamHandle* socketHa
ndle, const WebKit::WebSocketStreamError& err) | 154 void SocketStreamHandleInternal::didFail(WebKit::WebSocketStreamHandle* socketHa
ndle, const WebKit::WebSocketStreamError& err) |
| 155 { | 155 { |
| 156 LOG(Network, "didFail"); | 156 LOG_INFO(Network, "didFail"); |
| 157 if (m_handle && m_socket) { | 157 if (m_handle && m_socket) { |
| 158 ASSERT(socketHandle == m_socket.get()); | 158 ASSERT(socketHandle == m_socket.get()); |
| 159 m_socket.clear(); | 159 m_socket.clear(); |
| 160 SocketStreamHandle* h = m_handle; | 160 SocketStreamHandle* h = m_handle; |
| 161 m_handle = 0; | 161 m_handle = 0; |
| 162 if (h->m_client) | 162 if (h->m_client) |
| 163 h->m_client->didCloseSocketStream(h); // didFail(h, err); | 163 h->m_client->didCloseSocketStream(h); // didFail(h, err); |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 | 166 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 } | 206 } |
| 207 | 207 |
| 208 void SocketStreamHandle::receivedRequestToContinueWithoutCredential(const Authen
ticationChallenge& challenge) | 208 void SocketStreamHandle::receivedRequestToContinueWithoutCredential(const Authen
ticationChallenge& challenge) |
| 209 { | 209 { |
| 210 notImplemented(); | 210 notImplemented(); |
| 211 } | 211 } |
| 212 | 212 |
| 213 } // namespace WebCore | 213 } // namespace WebCore |
| 214 | 214 |
| 215 #endif // ENABLE(WEB_SOCKETS) | 215 #endif // ENABLE(WEB_SOCKETS) |
| OLD | NEW |