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

Side by Side Diff: third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.h

Issue 1878463002: Move DOMArrayBuffer, DOMArrayBufferViews and DataView to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tidy Created 4 years, 8 months 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 void sendBinaryAsCharVector(PassOwnPtr<Vector<char>> data) override; 83 void sendBinaryAsCharVector(PassOwnPtr<Vector<char>> data) override;
84 // Start closing handshake. Use the CloseEventCodeNotSpecified for the code 84 // Start closing handshake. Use the CloseEventCodeNotSpecified for the code
85 // argument to omit payload. 85 // argument to omit payload.
86 void close(int code, const String& reason) override; 86 void close(int code, const String& reason) override;
87 void fail(const String& reason, MessageLevel, const String&, unsigned lineNu mber) override; 87 void fail(const String& reason, MessageLevel, const String&, unsigned lineNu mber) override;
88 void disconnect() override; 88 void disconnect() override;
89 89
90 DECLARE_VIRTUAL_TRACE(); 90 DECLARE_VIRTUAL_TRACE();
91 91
92 private: 92 private:
93 class BlobLoader;
94 class Message;
95
93 enum MessageType { 96 enum MessageType {
94 MessageTypeText, 97 MessageTypeText,
95 MessageTypeBlob, 98 MessageTypeBlob,
96 MessageTypeArrayBuffer, 99 MessageTypeArrayBuffer,
97 MessageTypeTextAsCharVector, 100 MessageTypeTextAsCharVector,
98 MessageTypeBinaryAsCharVector, 101 MessageTypeBinaryAsCharVector,
99 MessageTypeClose, 102 MessageTypeClose,
100 }; 103 };
101 104
102 struct Message {
103 explicit Message(const CString&);
104 explicit Message(PassRefPtr<BlobDataHandle>);
105 explicit Message(PassRefPtr<DOMArrayBuffer>);
106 // For WorkerWebSocketChannel
107 explicit Message(PassOwnPtr<Vector<char>>, MessageType);
108 // Close message
109 Message(unsigned short code, const String& reason);
110
111 MessageType type;
112
113 CString text;
114 RefPtr<BlobDataHandle> blobDataHandle;
115 RefPtr<DOMArrayBuffer> arrayBuffer;
116 OwnPtr<Vector<char>> vectorData;
117 unsigned short code;
118 String reason;
119 };
120
121 struct ReceivedMessage { 105 struct ReceivedMessage {
122 bool isMessageText; 106 bool isMessageText;
123 Vector<char> data; 107 Vector<char> data;
124 }; 108 };
125 109
126 class BlobLoader;
127
128 DocumentWebSocketChannel(Document*, WebSocketChannelClient*, const String&, unsigned, WebSocketHandle*); 110 DocumentWebSocketChannel(Document*, WebSocketChannelClient*, const String&, unsigned, WebSocketHandle*);
129 void sendInternal(WebSocketHandle::MessageType, const char* data, size_t tot alSize, uint64_t* consumedBufferedAmount); 111 void sendInternal(WebSocketHandle::MessageType, const char* data, size_t tot alSize, uint64_t* consumedBufferedAmount);
130 void processSendQueue(); 112 void processSendQueue();
131 void flowControlIfNecessary(); 113 void flowControlIfNecessary();
132 void failAsError(const String& reason) { fail(reason, ErrorMessageLevel, m_s ourceURLAtConstruction, m_lineNumberAtConstruction); } 114 void failAsError(const String& reason) { fail(reason, ErrorMessageLevel, m_s ourceURLAtConstruction, m_lineNumberAtConstruction); }
133 void abortAsyncOperations(); 115 void abortAsyncOperations();
134 void handleDidClose(bool wasClean, unsigned short code, const String& reason ); 116 void handleDidClose(bool wasClean, unsigned short code, const String& reason );
135 Document* document(); 117 Document* document();
136 118
137 // WebSocketHandleClient functions. 119 // WebSocketHandleClient functions.
138 void didConnect(WebSocketHandle*, const WebString& selectedProtocol, const W ebString& extensions) override; 120 void didConnect(WebSocketHandle*, const WebString& selectedProtocol, const W ebString& extensions) override;
139 void didStartOpeningHandshake(WebSocketHandle*, const WebSocketHandshakeRequ estInfo&) override; 121 void didStartOpeningHandshake(WebSocketHandle*, const WebSocketHandshakeRequ estInfo&) override;
140 void didFinishOpeningHandshake(WebSocketHandle*, const WebSocketHandshakeRes ponseInfo&) override; 122 void didFinishOpeningHandshake(WebSocketHandle*, const WebSocketHandshakeRes ponseInfo&) override;
141 void didFail(WebSocketHandle*, const WebString& message) override; 123 void didFail(WebSocketHandle*, const WebString& message) override;
142 void didReceiveData(WebSocketHandle*, bool fin, WebSocketHandle::MessageType , const char* data, size_t /* size */) override; 124 void didReceiveData(WebSocketHandle*, bool fin, WebSocketHandle::MessageType , const char* data, size_t /* size */) override;
143 void didClose(WebSocketHandle*, bool wasClean, unsigned short code, const We bString& reason) override; 125 void didClose(WebSocketHandle*, bool wasClean, unsigned short code, const We bString& reason) override;
144 void didReceiveFlowControl(WebSocketHandle*, int64_t quota) override; 126 void didReceiveFlowControl(WebSocketHandle*, int64_t quota) override;
145 void didStartClosingHandshake(WebSocketHandle*) override; 127 void didStartClosingHandshake(WebSocketHandle*) override;
146 128
147 // Methods for BlobLoader. 129 // Methods for BlobLoader.
148 void didFinishLoadingBlob(PassRefPtr<DOMArrayBuffer>); 130 void didFinishLoadingBlob(DOMArrayBuffer*);
149 void didFailLoadingBlob(FileError::ErrorCode); 131 void didFailLoadingBlob(FileError::ErrorCode);
150 132
151 // m_handle is a handle of the connection. 133 // m_handle is a handle of the connection.
152 // m_handle == 0 means this channel is closed. 134 // m_handle == 0 means this channel is closed.
153 OwnPtr<WebSocketHandle> m_handle; 135 OwnPtr<WebSocketHandle> m_handle;
154 136
155 // m_client can be deleted while this channel is alive, but this class 137 // m_client can be deleted while this channel is alive, but this class
156 // expects that disconnect() is called before the deletion. 138 // expects that disconnect() is called before the deletion.
157 Member<WebSocketChannelClient> m_client; 139 Member<WebSocketChannelClient> m_client;
158 KURL m_url; 140 KURL m_url;
159 // m_identifier > 0 means calling scriptContextExecution() returns a Documen t. 141 // m_identifier > 0 means calling scriptContextExecution() returns a Documen t.
160 unsigned long m_identifier; 142 unsigned long m_identifier;
161 Member<BlobLoader> m_blobLoader; 143 Member<BlobLoader> m_blobLoader;
162 Deque<OwnPtr<Message>> m_messages; 144 HeapDeque<Member<Message>> m_messages;
163 Vector<char> m_receivingMessageData; 145 Vector<char> m_receivingMessageData;
164 146
165 bool m_receivingMessageTypeIsText; 147 bool m_receivingMessageTypeIsText;
166 uint64_t m_sendingQuota; 148 uint64_t m_sendingQuota;
167 uint64_t m_receivedDataSizeForFlowControl; 149 uint64_t m_receivedDataSizeForFlowControl;
168 size_t m_sentSizeOfTopMessage; 150 size_t m_sentSizeOfTopMessage;
169 151
170 String m_sourceURLAtConstruction; 152 String m_sourceURLAtConstruction;
171 unsigned m_lineNumberAtConstruction; 153 unsigned m_lineNumberAtConstruction;
172 RefPtr<WebSocketHandshakeRequest> m_handshakeRequest; 154 RefPtr<WebSocketHandshakeRequest> m_handshakeRequest;
173 155
174 static const uint64_t receivedDataSizeForFlowControlHighWaterMark = 1 << 15; 156 static const uint64_t receivedDataSizeForFlowControlHighWaterMark = 1 << 15;
175 }; 157 };
176 158
177 } // namespace blink 159 } // namespace blink
178 160
179 #endif // DocumentWebSocketChannel_h 161 #endif // DocumentWebSocketChannel_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698