Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1137)

Side by Side Diff: Source/modules/websockets/WorkerWebSocketChannel.cpp

Issue 711763002: bindings: Transition from ArrayBuffer to DOMArrayBuffer, part 2 (2nd round) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixes Win x64 build. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/modules/websockets/WorkerWebSocketChannel.h ('k') | Source/web/WebSocketImpl.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 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 11 matching lines...) Expand all
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32
33 #include "modules/websockets/WorkerWebSocketChannel.h" 32 #include "modules/websockets/WorkerWebSocketChannel.h"
34 33
35 #include "bindings/core/v8/ScriptCallStackFactory.h" 34 #include "bindings/core/v8/ScriptCallStackFactory.h"
36 #include "core/dom/CrossThreadTask.h" 35 #include "core/dom/CrossThreadTask.h"
36 #include "core/dom/DOMArrayBuffer.h"
37 #include "core/dom/Document.h" 37 #include "core/dom/Document.h"
38 #include "core/dom/ExecutionContext.h" 38 #include "core/dom/ExecutionContext.h"
39 #include "core/dom/ExecutionContextTask.h" 39 #include "core/dom/ExecutionContextTask.h"
40 #include "core/fileapi/Blob.h" 40 #include "core/fileapi/Blob.h"
41 #include "core/inspector/ScriptCallFrame.h" 41 #include "core/inspector/ScriptCallFrame.h"
42 #include "core/inspector/ScriptCallStack.h" 42 #include "core/inspector/ScriptCallStack.h"
43 #include "core/workers/WorkerGlobalScope.h" 43 #include "core/workers/WorkerGlobalScope.h"
44 #include "core/workers/WorkerLoaderProxy.h" 44 #include "core/workers/WorkerLoaderProxy.h"
45 #include "core/workers/WorkerThread.h" 45 #include "core/workers/WorkerThread.h"
46 #include "modules/websockets/DocumentWebSocketChannel.h" 46 #include "modules/websockets/DocumentWebSocketChannel.h"
47 #include "public/platform/Platform.h" 47 #include "public/platform/Platform.h"
48 #include "public/platform/WebWaitableEvent.h" 48 #include "public/platform/WebWaitableEvent.h"
49 #include "wtf/ArrayBuffer.h"
50 #include "wtf/Assertions.h" 49 #include "wtf/Assertions.h"
51 #include "wtf/Functional.h" 50 #include "wtf/Functional.h"
52 #include "wtf/MainThread.h" 51 #include "wtf/MainThread.h"
53 #include "wtf/text/WTFString.h" 52 #include "wtf/text/WTFString.h"
54 53
55 namespace blink { 54 namespace blink {
56 55
57 typedef WorkerWebSocketChannel::Bridge Bridge; 56 typedef WorkerWebSocketChannel::Bridge Bridge;
58 typedef WorkerWebSocketChannel::Peer Peer; 57 typedef WorkerWebSocketChannel::Peer Peer;
59 58
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 ASSERT(m_bridge); 124 ASSERT(m_bridge);
126 return m_bridge->connect(url, protocol); 125 return m_bridge->connect(url, protocol);
127 } 126 }
128 127
129 void WorkerWebSocketChannel::send(const String& message) 128 void WorkerWebSocketChannel::send(const String& message)
130 { 129 {
131 ASSERT(m_bridge); 130 ASSERT(m_bridge);
132 m_bridge->send(message); 131 m_bridge->send(message);
133 } 132 }
134 133
135 void WorkerWebSocketChannel::send(const ArrayBuffer& binaryData, unsigned byteOf fset, unsigned byteLength) 134 void WorkerWebSocketChannel::send(const DOMArrayBuffer& binaryData, unsigned byt eOffset, unsigned byteLength)
136 { 135 {
137 ASSERT(m_bridge); 136 ASSERT(m_bridge);
138 m_bridge->send(binaryData, byteOffset, byteLength); 137 m_bridge->send(binaryData, byteOffset, byteLength);
139 } 138 }
140 139
141 void WorkerWebSocketChannel::send(PassRefPtr<BlobDataHandle> blobData) 140 void WorkerWebSocketChannel::send(PassRefPtr<BlobDataHandle> blobData)
142 { 141 {
143 ASSERT(m_bridge); 142 ASSERT(m_bridge);
144 m_bridge->send(blobData); 143 m_bridge->send(blobData);
145 } 144 }
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 402
404 return m_syncHelper->connectRequestResult(); 403 return m_syncHelper->connectRequestResult();
405 } 404 }
406 405
407 void Bridge::send(const String& message) 406 void Bridge::send(const String& message)
408 { 407 {
409 ASSERT(m_peer); 408 ASSERT(m_peer);
410 m_loaderProxy.postTaskToLoader(createCrossThreadTask(&Peer::send, m_peer.get (), message)); 409 m_loaderProxy.postTaskToLoader(createCrossThreadTask(&Peer::send, m_peer.get (), message));
411 } 410 }
412 411
413 void Bridge::send(const ArrayBuffer& binaryData, unsigned byteOffset, unsigned b yteLength) 412 void Bridge::send(const DOMArrayBuffer& binaryData, unsigned byteOffset, unsigne d byteLength)
414 { 413 {
415 ASSERT(m_peer); 414 ASSERT(m_peer);
416 // ArrayBuffer isn't thread-safe, hence the content of ArrayBuffer is copied into Vector<char>. 415 // ArrayBuffer isn't thread-safe, hence the content of ArrayBuffer is copied into Vector<char>.
417 OwnPtr<Vector<char> > data = adoptPtr(new Vector<char>(byteLength)); 416 OwnPtr<Vector<char> > data = adoptPtr(new Vector<char>(byteLength));
418 if (binaryData.byteLength()) 417 if (binaryData.byteLength())
419 memcpy(data->data(), static_cast<const char*>(binaryData.data()) + byteO ffset, byteLength); 418 memcpy(data->data(), static_cast<const char*>(binaryData.data()) + byteO ffset, byteLength);
420 419
421 m_loaderProxy.postTaskToLoader(createCrossThreadTask(&Peer::sendArrayBuffer, m_peer.get(), data.release())); 420 m_loaderProxy.postTaskToLoader(createCrossThreadTask(&Peer::sendArrayBuffer, m_peer.get(), data.release()));
422 } 421 }
423 422
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 472
474 void Bridge::trace(Visitor* visitor) 473 void Bridge::trace(Visitor* visitor)
475 { 474 {
476 visitor->trace(m_client); 475 visitor->trace(m_client);
477 visitor->trace(m_workerGlobalScope); 476 visitor->trace(m_workerGlobalScope);
478 visitor->trace(m_syncHelper); 477 visitor->trace(m_syncHelper);
479 visitor->trace(m_peer); 478 visitor->trace(m_peer);
480 } 479 }
481 480
482 } // namespace blink 481 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/websockets/WorkerWebSocketChannel.h ('k') | Source/web/WebSocketImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698