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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 #include "wtf/text/WTFString.h" | 51 #include "wtf/text/WTFString.h" |
52 | 52 |
53 namespace blink { | 53 namespace blink { |
54 | 54 |
55 class Document; | 55 class Document; |
56 class WebSocketHandshakeRequest; | 56 class WebSocketHandshakeRequest; |
57 class WebSocketHandshakeRequestInfo; | 57 class WebSocketHandshakeRequestInfo; |
58 class WebSocketHandshakeResponseInfo; | 58 class WebSocketHandshakeResponseInfo; |
59 | 59 |
60 // This class may replace MainThreadWebSocketChannel. | 60 // This class may replace MainThreadWebSocketChannel. |
61 class NewWebSocketChannelImpl FINAL : public WebSocketChannel, public WebSocketH
andleClient, public ContextLifecycleObserver { | 61 class NewWebSocketChannelImpl final : public WebSocketChannel, public WebSocketH
andleClient, public ContextLifecycleObserver { |
62 public: | 62 public: |
63 // You can specify the source file and the line number information | 63 // You can specify the source file and the line number information |
64 // explicitly by passing the last parameter. | 64 // explicitly by passing the last parameter. |
65 // In the usual case, they are set automatically and you don't have to | 65 // In the usual case, they are set automatically and you don't have to |
66 // pass it. | 66 // pass it. |
67 // Specify handle explicitly only in tests. | 67 // Specify handle explicitly only in tests. |
68 static NewWebSocketChannelImpl* create(ExecutionContext* context, WebSocketC
hannelClient* client, const String& sourceURL = String(), unsigned lineNumber =
0, WebSocketHandle *handle = 0) | 68 static NewWebSocketChannelImpl* create(ExecutionContext* context, WebSocketC
hannelClient* client, const String& sourceURL = String(), unsigned lineNumber =
0, WebSocketHandle *handle = 0) |
69 { | 69 { |
70 return adoptRefCountedGarbageCollected(new NewWebSocketChannelImpl(conte
xt, client, sourceURL, lineNumber, handle)); | 70 return adoptRefCountedGarbageCollected(new NewWebSocketChannelImpl(conte
xt, client, sourceURL, lineNumber, handle)); |
71 } | 71 } |
72 virtual ~NewWebSocketChannelImpl(); | 72 virtual ~NewWebSocketChannelImpl(); |
73 | 73 |
74 // WebSocketChannel functions. | 74 // WebSocketChannel functions. |
75 virtual bool connect(const KURL&, const String& protocol) OVERRIDE; | 75 virtual bool connect(const KURL&, const String& protocol) override; |
76 virtual void send(const String& message) OVERRIDE; | 76 virtual void send(const String& message) override; |
77 virtual void send(const ArrayBuffer&, unsigned byteOffset, unsigned byteLeng
th) OVERRIDE; | 77 virtual void send(const ArrayBuffer&, unsigned byteOffset, unsigned byteLeng
th) override; |
78 virtual void send(PassRefPtr<BlobDataHandle>) OVERRIDE; | 78 virtual void send(PassRefPtr<BlobDataHandle>) override; |
79 virtual void send(PassOwnPtr<Vector<char> > data) OVERRIDE; | 79 virtual void send(PassOwnPtr<Vector<char> > data) override; |
80 // Start closing handshake. Use the CloseEventCodeNotSpecified for the code | 80 // Start closing handshake. Use the CloseEventCodeNotSpecified for the code |
81 // argument to omit payload. | 81 // argument to omit payload. |
82 virtual void close(int code, const String& reason) OVERRIDE; | 82 virtual void close(int code, const String& reason) override; |
83 virtual void fail(const String& reason, MessageLevel, const String&, unsigne
d lineNumber) OVERRIDE; | 83 virtual void fail(const String& reason, MessageLevel, const String&, unsigne
d lineNumber) override; |
84 virtual void disconnect() OVERRIDE; | 84 virtual void disconnect() override; |
85 | 85 |
86 virtual void suspend() OVERRIDE; | 86 virtual void suspend() override; |
87 virtual void resume() OVERRIDE; | 87 virtual void resume() override; |
88 | 88 |
89 virtual void trace(Visitor*) OVERRIDE; | 89 virtual void trace(Visitor*) override; |
90 | 90 |
91 private: | 91 private: |
92 enum MessageType { | 92 enum MessageType { |
93 MessageTypeText, | 93 MessageTypeText, |
94 MessageTypeBlob, | 94 MessageTypeBlob, |
95 MessageTypeArrayBuffer, | 95 MessageTypeArrayBuffer, |
96 MessageTypeVector, | 96 MessageTypeVector, |
97 MessageTypeClose, | 97 MessageTypeClose, |
98 }; | 98 }; |
99 | 99 |
(...skipping 23 matching lines...) Expand all Loading... |
123 | 123 |
124 NewWebSocketChannelImpl(ExecutionContext*, WebSocketChannelClient*, const St
ring&, unsigned, WebSocketHandle*); | 124 NewWebSocketChannelImpl(ExecutionContext*, WebSocketChannelClient*, const St
ring&, unsigned, WebSocketHandle*); |
125 void sendInternal(); | 125 void sendInternal(); |
126 void flowControlIfNecessary(); | 126 void flowControlIfNecessary(); |
127 void failAsError(const String& reason) { fail(reason, ErrorMessageLevel, m_s
ourceURLAtConstruction, m_lineNumberAtConstruction); } | 127 void failAsError(const String& reason) { fail(reason, ErrorMessageLevel, m_s
ourceURLAtConstruction, m_lineNumberAtConstruction); } |
128 void abortAsyncOperations(); | 128 void abortAsyncOperations(); |
129 void handleDidClose(bool wasClean, unsigned short code, const String& reason
); | 129 void handleDidClose(bool wasClean, unsigned short code, const String& reason
); |
130 Document* document(); // can be called only when m_identifier > 0. | 130 Document* document(); // can be called only when m_identifier > 0. |
131 | 131 |
132 // WebSocketHandleClient functions. | 132 // WebSocketHandleClient functions. |
133 virtual void didConnect(WebSocketHandle*, bool fail, const WebString& select
edProtocol, const WebString& extensions) OVERRIDE; | 133 virtual void didConnect(WebSocketHandle*, bool fail, const WebString& select
edProtocol, const WebString& extensions) override; |
134 virtual void didStartOpeningHandshake(WebSocketHandle*, const WebSocketHands
hakeRequestInfo&) OVERRIDE; | 134 virtual void didStartOpeningHandshake(WebSocketHandle*, const WebSocketHands
hakeRequestInfo&) override; |
135 virtual void didFinishOpeningHandshake(WebSocketHandle*, const WebSocketHand
shakeResponseInfo&) OVERRIDE; | 135 virtual void didFinishOpeningHandshake(WebSocketHandle*, const WebSocketHand
shakeResponseInfo&) override; |
136 virtual void didFail(WebSocketHandle*, const WebString& message) OVERRIDE; | 136 virtual void didFail(WebSocketHandle*, const WebString& message) override; |
137 virtual void didReceiveData(WebSocketHandle*, bool fin, WebSocketHandle::Mes
sageType, const char* data, size_t /* size */) OVERRIDE; | 137 virtual void didReceiveData(WebSocketHandle*, bool fin, WebSocketHandle::Mes
sageType, const char* data, size_t /* size */) override; |
138 virtual void didClose(WebSocketHandle*, bool wasClean, unsigned short code,
const WebString& reason) OVERRIDE; | 138 virtual void didClose(WebSocketHandle*, bool wasClean, unsigned short code,
const WebString& reason) override; |
139 virtual void didReceiveFlowControl(WebSocketHandle*, int64_t quota) OVERRIDE
; | 139 virtual void didReceiveFlowControl(WebSocketHandle*, int64_t quota) override
; |
140 virtual void didStartClosingHandshake(WebSocketHandle*) OVERRIDE; | 140 virtual void didStartClosingHandshake(WebSocketHandle*) override; |
141 | 141 |
142 // Methods for BlobLoader. | 142 // Methods for BlobLoader. |
143 void didFinishLoadingBlob(PassRefPtr<ArrayBuffer>); | 143 void didFinishLoadingBlob(PassRefPtr<ArrayBuffer>); |
144 void didFailLoadingBlob(FileError::ErrorCode); | 144 void didFailLoadingBlob(FileError::ErrorCode); |
145 | 145 |
146 // LifecycleObserver functions. | 146 // LifecycleObserver functions. |
147 virtual void contextDestroyed() OVERRIDE | 147 virtual void contextDestroyed() override |
148 { | 148 { |
149 // In oilpan we cannot assume this channel's finalizer has been called | 149 // In oilpan we cannot assume this channel's finalizer has been called |
150 // before the document it is observing is dead and finalized since there | 150 // before the document it is observing is dead and finalized since there |
151 // is no eager finalization. Instead the finalization happens at the | 151 // is no eager finalization. Instead the finalization happens at the |
152 // next GC which could be long enough after the Peer::destroy call for | 152 // next GC which could be long enough after the Peer::destroy call for |
153 // the context (ie. Document) to be dead too. If the context's finalizer | 153 // the context (ie. Document) to be dead too. If the context's finalizer |
154 // is run first this method gets called. Instead we assert the channel | 154 // is run first this method gets called. Instead we assert the channel |
155 // has been disconnected which happens in Peer::destroy. | 155 // has been disconnected which happens in Peer::destroy. |
156 ASSERT(!m_handle); | 156 ASSERT(!m_handle); |
157 ASSERT(!m_client); | 157 ASSERT(!m_client); |
(...skipping 23 matching lines...) Expand all Loading... |
181 String m_sourceURLAtConstruction; | 181 String m_sourceURLAtConstruction; |
182 unsigned m_lineNumberAtConstruction; | 182 unsigned m_lineNumberAtConstruction; |
183 RefPtr<WebSocketHandshakeRequest> m_handshakeRequest; | 183 RefPtr<WebSocketHandshakeRequest> m_handshakeRequest; |
184 | 184 |
185 static const int64_t receivedDataSizeForFlowControlHighWaterMark = 1 << 15; | 185 static const int64_t receivedDataSizeForFlowControlHighWaterMark = 1 << 15; |
186 }; | 186 }; |
187 | 187 |
188 } // namespace blink | 188 } // namespace blink |
189 | 189 |
190 #endif // NewWebSocketChannelImpl_h | 190 #endif // NewWebSocketChannelImpl_h |
OLD | NEW |