| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 ThreadableWebSocketChannelClientWrapper::~ThreadableWebSocketChannelClientWrappe
r() | 48 ThreadableWebSocketChannelClientWrapper::~ThreadableWebSocketChannelClientWrappe
r() |
| 49 { | 49 { |
| 50 } | 50 } |
| 51 | 51 |
| 52 PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> ThreadableWebSoc
ketChannelClientWrapper::create(WebSocketChannelClient* client) | 52 PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> ThreadableWebSoc
ketChannelClientWrapper::create(WebSocketChannelClient* client) |
| 53 { | 53 { |
| 54 return adoptRefWillBeNoop(new ThreadableWebSocketChannelClientWrapper(client
)); | 54 return adoptRefWillBeNoop(new ThreadableWebSocketChannelClientWrapper(client
)); |
| 55 } | 55 } |
| 56 | 56 |
| 57 String ThreadableWebSocketChannelClientWrapper::subprotocol() const | |
| 58 { | |
| 59 if (m_subprotocol.isEmpty()) | |
| 60 return emptyString(); | |
| 61 return String(m_subprotocol); | |
| 62 } | |
| 63 | |
| 64 void ThreadableWebSocketChannelClientWrapper::setSubprotocol(const String& subpr
otocol) | |
| 65 { | |
| 66 m_subprotocol.clear(); | |
| 67 append(m_subprotocol, subprotocol); | |
| 68 } | |
| 69 | |
| 70 String ThreadableWebSocketChannelClientWrapper::extensions() const | |
| 71 { | |
| 72 if (m_extensions.isEmpty()) | |
| 73 return emptyString(); | |
| 74 return String(m_extensions); | |
| 75 } | |
| 76 | |
| 77 void ThreadableWebSocketChannelClientWrapper::setExtensions(const String& extens
ions) | |
| 78 { | |
| 79 m_extensions.clear(); | |
| 80 append(m_extensions, extensions); | |
| 81 } | |
| 82 | |
| 83 void ThreadableWebSocketChannelClientWrapper::clearClient() | 57 void ThreadableWebSocketChannelClientWrapper::clearClient() |
| 84 { | 58 { |
| 85 m_client = 0; | 59 m_client = 0; |
| 86 } | 60 } |
| 87 | 61 |
| 88 void ThreadableWebSocketChannelClientWrapper::didConnect() | 62 void ThreadableWebSocketChannelClientWrapper::didConnect(const String& subprotoc
ol, const String& extensions) |
| 89 { | 63 { |
| 90 m_pendingTasks.append(createCallbackTask(&didConnectCallback, this)); | 64 m_pendingTasks.append(createCallbackTask(&didConnectCallback, this, subproto
col, extensions)); |
| 91 if (!m_suspended) | 65 if (!m_suspended) |
| 92 processPendingTasks(); | 66 processPendingTasks(); |
| 93 } | 67 } |
| 94 | 68 |
| 95 void ThreadableWebSocketChannelClientWrapper::didReceiveMessage(const String& me
ssage) | 69 void ThreadableWebSocketChannelClientWrapper::didReceiveMessage(const String& me
ssage) |
| 96 { | 70 { |
| 97 m_pendingTasks.append(createCallbackTask(&didReceiveMessageCallback, this, m
essage)); | 71 m_pendingTasks.append(createCallbackTask(&didReceiveMessageCallback, this, m
essage)); |
| 98 if (!m_suspended) | 72 if (!m_suspended) |
| 99 processPendingTasks(); | 73 processPendingTasks(); |
| 100 } | 74 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 void ThreadableWebSocketChannelClientWrapper::processPendingTasks() | 122 void ThreadableWebSocketChannelClientWrapper::processPendingTasks() |
| 149 { | 123 { |
| 150 if (m_suspended) | 124 if (m_suspended) |
| 151 return; | 125 return; |
| 152 Vector<OwnPtr<ExecutionContextTask> > tasks; | 126 Vector<OwnPtr<ExecutionContextTask> > tasks; |
| 153 tasks.swap(m_pendingTasks); | 127 tasks.swap(m_pendingTasks); |
| 154 for (Vector<OwnPtr<ExecutionContextTask> >::const_iterator iter = tasks.begi
n(); iter != tasks.end(); ++iter) | 128 for (Vector<OwnPtr<ExecutionContextTask> >::const_iterator iter = tasks.begi
n(); iter != tasks.end(); ++iter) |
| 155 (*iter)->performTask(0); | 129 (*iter)->performTask(0); |
| 156 } | 130 } |
| 157 | 131 |
| 158 void ThreadableWebSocketChannelClientWrapper::didConnectCallback(ExecutionContex
t* context, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> wrap
per) | 132 void ThreadableWebSocketChannelClientWrapper::didConnectCallback(ExecutionContex
t* context, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrapper> wrap
per, const String& subprotocol, const String& extensions) |
| 159 { | 133 { |
| 160 ASSERT_UNUSED(context, !context); | 134 ASSERT_UNUSED(context, !context); |
| 161 if (wrapper->m_client) | 135 if (wrapper->m_client) |
| 162 wrapper->m_client->didConnect(); | 136 wrapper->m_client->didConnect(subprotocol, extensions); |
| 163 } | 137 } |
| 164 | 138 |
| 165 void ThreadableWebSocketChannelClientWrapper::didReceiveMessageCallback(Executio
nContext* context, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrappe
r> wrapper, const String& message) | 139 void ThreadableWebSocketChannelClientWrapper::didReceiveMessageCallback(Executio
nContext* context, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWrappe
r> wrapper, const String& message) |
| 166 { | 140 { |
| 167 ASSERT_UNUSED(context, !context); | 141 ASSERT_UNUSED(context, !context); |
| 168 if (wrapper->m_client) | 142 if (wrapper->m_client) |
| 169 wrapper->m_client->didReceiveMessage(message); | 143 wrapper->m_client->didReceiveMessage(message); |
| 170 } | 144 } |
| 171 | 145 |
| 172 void ThreadableWebSocketChannelClientWrapper::didReceiveBinaryDataCallback(Execu
tionContext* context, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWra
pper> wrapper, PassOwnPtr<Vector<char> > binaryData) | 146 void ThreadableWebSocketChannelClientWrapper::didReceiveBinaryDataCallback(Execu
tionContext* context, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientWra
pper> wrapper, PassOwnPtr<Vector<char> > binaryData) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 198 } | 172 } |
| 199 | 173 |
| 200 void ThreadableWebSocketChannelClientWrapper::didReceiveMessageErrorCallback(Exe
cutionContext* context, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientW
rapper> wrapper) | 174 void ThreadableWebSocketChannelClientWrapper::didReceiveMessageErrorCallback(Exe
cutionContext* context, PassRefPtrWillBeRawPtr<ThreadableWebSocketChannelClientW
rapper> wrapper) |
| 201 { | 175 { |
| 202 ASSERT_UNUSED(context, !context); | 176 ASSERT_UNUSED(context, !context); |
| 203 if (wrapper->m_client) | 177 if (wrapper->m_client) |
| 204 wrapper->m_client->didReceiveMessageError(); | 178 wrapper->m_client->didReceiveMessageError(); |
| 205 } | 179 } |
| 206 | 180 |
| 207 } // namespace WebCore | 181 } // namespace WebCore |
| OLD | NEW |