| OLD | NEW | 
|---|
| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 71     { | 71     { | 
| 72         return new DocumentWebSocketChannel(context, client, sourceURL, lineNumb
     er, handle); | 72         return new DocumentWebSocketChannel(context, client, sourceURL, lineNumb
     er, handle); | 
| 73     } | 73     } | 
| 74     virtual ~DocumentWebSocketChannel(); | 74     virtual ~DocumentWebSocketChannel(); | 
| 75 | 75 | 
| 76     // WebSocketChannel functions. | 76     // WebSocketChannel functions. | 
| 77     virtual bool connect(const KURL&, const String& protocol) override; | 77     virtual bool connect(const KURL&, const String& protocol) override; | 
| 78     virtual void send(const String& message) override; | 78     virtual void send(const String& message) override; | 
| 79     virtual void send(const DOMArrayBuffer&, unsigned byteOffset, unsigned byteL
     ength) override; | 79     virtual void send(const DOMArrayBuffer&, unsigned byteOffset, unsigned byteL
     ength) override; | 
| 80     virtual void send(PassRefPtr<BlobDataHandle>) override; | 80     virtual void send(PassRefPtr<BlobDataHandle>) override; | 
| 81     virtual void send(PassOwnPtr<Vector<char> > data) override; | 81     virtual void send(PassOwnPtr<Vector<char>> data) override; | 
| 82     // Start closing handshake. Use the CloseEventCodeNotSpecified for the code | 82     // Start closing handshake. Use the CloseEventCodeNotSpecified for the code | 
| 83     // argument to omit payload. | 83     // argument to omit payload. | 
| 84     virtual void close(int code, const String& reason) override; | 84     virtual void close(int code, const String& reason) override; | 
| 85     virtual void fail(const String& reason, MessageLevel, const String&, unsigne
     d lineNumber) override; | 85     virtual void fail(const String& reason, MessageLevel, const String&, unsigne
     d lineNumber) override; | 
| 86     virtual void disconnect() override; | 86     virtual void disconnect() override; | 
| 87 | 87 | 
| 88     virtual void trace(Visitor*) override; | 88     virtual void trace(Visitor*) override; | 
| 89 | 89 | 
| 90 private: | 90 private: | 
| 91     enum MessageType { | 91     enum MessageType { | 
| 92         MessageTypeText, | 92         MessageTypeText, | 
| 93         MessageTypeBlob, | 93         MessageTypeBlob, | 
| 94         MessageTypeArrayBuffer, | 94         MessageTypeArrayBuffer, | 
| 95         MessageTypeVector, | 95         MessageTypeVector, | 
| 96         MessageTypeClose, | 96         MessageTypeClose, | 
| 97     }; | 97     }; | 
| 98 | 98 | 
| 99     struct Message { | 99     struct Message { | 
| 100         explicit Message(const String&); | 100         explicit Message(const String&); | 
| 101         explicit Message(PassRefPtr<BlobDataHandle>); | 101         explicit Message(PassRefPtr<BlobDataHandle>); | 
| 102         explicit Message(PassRefPtr<DOMArrayBuffer>); | 102         explicit Message(PassRefPtr<DOMArrayBuffer>); | 
| 103         explicit Message(PassOwnPtr<Vector<char> >); | 103         explicit Message(PassOwnPtr<Vector<char>>); | 
| 104         Message(unsigned short code, const String& reason); | 104         Message(unsigned short code, const String& reason); | 
| 105 | 105 | 
| 106         MessageType type; | 106         MessageType type; | 
| 107 | 107 | 
| 108         CString text; | 108         CString text; | 
| 109         RefPtr<BlobDataHandle> blobDataHandle; | 109         RefPtr<BlobDataHandle> blobDataHandle; | 
| 110         RefPtr<DOMArrayBuffer> arrayBuffer; | 110         RefPtr<DOMArrayBuffer> arrayBuffer; | 
| 111         OwnPtr<Vector<char> > vectorData; | 111         OwnPtr<Vector<char>> vectorData; | 
| 112         unsigned short code; | 112         unsigned short code; | 
| 113         String reason; | 113         String reason; | 
| 114     }; | 114     }; | 
| 115 | 115 | 
| 116     struct ReceivedMessage { | 116     struct ReceivedMessage { | 
| 117         bool isMessageText; | 117         bool isMessageText; | 
| 118         Vector<char> data; | 118         Vector<char> data; | 
| 119     }; | 119     }; | 
| 120 | 120 | 
| 121     class BlobLoader; | 121     class BlobLoader; | 
| (...skipping 24 matching lines...) Expand all  Loading... | 
| 146     // m_handle == 0 means this channel is closed. | 146     // m_handle == 0 means this channel is closed. | 
| 147     OwnPtr<WebSocketHandle> m_handle; | 147     OwnPtr<WebSocketHandle> m_handle; | 
| 148 | 148 | 
| 149     // m_client can be deleted while this channel is alive, but this class | 149     // m_client can be deleted while this channel is alive, but this class | 
| 150     // expects that disconnect() is called before the deletion. | 150     // expects that disconnect() is called before the deletion. | 
| 151     Member<WebSocketChannelClient> m_client; | 151     Member<WebSocketChannelClient> m_client; | 
| 152     KURL m_url; | 152     KURL m_url; | 
| 153     // m_identifier > 0 means calling scriptContextExecution() returns a Documen
     t. | 153     // m_identifier > 0 means calling scriptContextExecution() returns a Documen
     t. | 
| 154     unsigned long m_identifier; | 154     unsigned long m_identifier; | 
| 155     Member<BlobLoader> m_blobLoader; | 155     Member<BlobLoader> m_blobLoader; | 
| 156     Deque<OwnPtr<Message> > m_messages; | 156     Deque<OwnPtr<Message>> m_messages; | 
| 157     Vector<char> m_receivingMessageData; | 157     Vector<char> m_receivingMessageData; | 
| 158 | 158 | 
| 159     bool m_receivingMessageTypeIsText; | 159     bool m_receivingMessageTypeIsText; | 
| 160     uint64_t m_sendingQuota; | 160     uint64_t m_sendingQuota; | 
| 161     uint64_t m_receivedDataSizeForFlowControl; | 161     uint64_t m_receivedDataSizeForFlowControl; | 
| 162     size_t m_sentSizeOfTopMessage; | 162     size_t m_sentSizeOfTopMessage; | 
| 163 | 163 | 
| 164     String m_sourceURLAtConstruction; | 164     String m_sourceURLAtConstruction; | 
| 165     unsigned m_lineNumberAtConstruction; | 165     unsigned m_lineNumberAtConstruction; | 
| 166     RefPtr<WebSocketHandshakeRequest> m_handshakeRequest; | 166     RefPtr<WebSocketHandshakeRequest> m_handshakeRequest; | 
| 167 | 167 | 
| 168     static const uint64_t receivedDataSizeForFlowControlHighWaterMark = 1 << 15; | 168     static const uint64_t receivedDataSizeForFlowControlHighWaterMark = 1 << 15; | 
| 169 }; | 169 }; | 
| 170 | 170 | 
| 171 } // namespace blink | 171 } // namespace blink | 
| 172 | 172 | 
| 173 #endif // DocumentWebSocketChannel_h | 173 #endif // DocumentWebSocketChannel_h | 
| OLD | NEW | 
|---|