OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 13 matching lines...) Expand all Loading... |
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 #ifndef WebSocketChannel_h | 31 #ifndef WebSocketChannel_h |
32 #define WebSocketChannel_h | 32 #define WebSocketChannel_h |
33 | 33 |
| 34 #include "core/inspector/ScriptCallFrame.h" |
| 35 #include "core/inspector/ScriptCallStack.h" |
| 36 #include "core/page/ConsoleTypes.h" |
34 #include "wtf/Forward.h" | 37 #include "wtf/Forward.h" |
35 #include "wtf/Noncopyable.h" | 38 #include "wtf/Noncopyable.h" |
| 39 #include "wtf/PassOwnPtr.h" |
36 #include "wtf/PassRefPtr.h" | 40 #include "wtf/PassRefPtr.h" |
| 41 #include "wtf/Vector.h" |
37 | 42 |
38 namespace WebCore { | 43 namespace WebCore { |
39 | 44 |
40 class Blob; | 45 class Blob; |
41 class KURL; | 46 class KURL; |
42 class ScriptExecutionContext; | 47 class ScriptExecutionContext; |
43 class WebSocketChannelClient; | 48 class WebSocketChannelClient; |
44 | 49 |
45 class WebSocketChannel { | 50 class WebSocketChannel { |
46 WTF_MAKE_NONCOPYABLE(WebSocketChannel); | 51 WTF_MAKE_NONCOPYABLE(WebSocketChannel); |
(...skipping 19 matching lines...) Expand all Loading... |
66 CloseEventCodeInvalidFramePayloadData = 1007, | 71 CloseEventCodeInvalidFramePayloadData = 1007, |
67 CloseEventCodePolicyViolation = 1008, | 72 CloseEventCodePolicyViolation = 1008, |
68 CloseEventCodeMessageTooBig = 1009, | 73 CloseEventCodeMessageTooBig = 1009, |
69 CloseEventCodeMandatoryExt = 1010, | 74 CloseEventCodeMandatoryExt = 1010, |
70 CloseEventCodeInternalError = 1011, | 75 CloseEventCodeInternalError = 1011, |
71 CloseEventCodeTLSHandshake = 1015, | 76 CloseEventCodeTLSHandshake = 1015, |
72 CloseEventCodeMinimumUserDefined = 3000, | 77 CloseEventCodeMinimumUserDefined = 3000, |
73 CloseEventCodeMaximumUserDefined = 4999 | 78 CloseEventCodeMaximumUserDefined = 4999 |
74 }; | 79 }; |
75 | 80 |
| 81 // A holder class for Vector<ScriptCallFrame> for readability. |
| 82 class CallStackWrapper { |
| 83 public: |
| 84 CallStackWrapper(const Vector<ScriptCallFrame>& frames): m_frames(frames
) { } |
| 85 PassRefPtr<ScriptCallStack> createCallStack() { return ScriptCallStack::
create(m_frames); } |
| 86 |
| 87 private: |
| 88 Vector<ScriptCallFrame> m_frames; |
| 89 }; |
| 90 |
76 virtual void connect(const KURL&, const String& protocol) = 0; | 91 virtual void connect(const KURL&, const String& protocol) = 0; |
77 virtual String subprotocol() = 0; // Will be available after didConnect() ca
llback is invoked. | 92 virtual String subprotocol() = 0; // Will be available after didConnect() ca
llback is invoked. |
78 virtual String extensions() = 0; // Will be available after didConnect() cal
lback is invoked. | 93 virtual String extensions() = 0; // Will be available after didConnect() cal
lback is invoked. |
79 virtual SendResult send(const String& message) = 0; | 94 virtual SendResult send(const String& message) = 0; |
80 virtual SendResult send(const ArrayBuffer&, unsigned byteOffset, unsigned by
teLength) = 0; | 95 virtual SendResult send(const ArrayBuffer&, unsigned byteOffset, unsigned by
teLength) = 0; |
81 virtual SendResult send(const Blob&) = 0; | 96 virtual SendResult send(const Blob&) = 0; |
82 virtual unsigned long bufferedAmount() const = 0; | 97 virtual unsigned long bufferedAmount() const = 0; |
83 virtual void close(int code, const String& reason) = 0; | 98 virtual void close(int code, const String& reason) = 0; |
| 99 |
84 // Log the reason text and close the connection. Will call didClose(). | 100 // Log the reason text and close the connection. Will call didClose(). |
85 virtual void fail(const String& reason) = 0; | 101 // The MessageLevel parameter will be used for the level of the message |
| 102 // shown at the devtool console. The CallStackWrapper parameter is |
| 103 // callstack information. it may be shown with the reason text at the |
| 104 // devtool console. If the parameter is null, the instance may fill |
| 105 // the callstack information and show it with the reason text if possible. |
| 106 virtual void fail(const String& reason, MessageLevel, PassOwnPtr<CallStackWr
apper>) = 0; |
| 107 |
| 108 // Log the reason text and close the connection. Will call didClose(). |
| 109 // The MessageLevel parameter will be used for the level of the message |
| 110 // shown at the devtool console. The instance may fill the callstack |
| 111 // information and show it with the reason text if possible. |
| 112 virtual void fail(const String& reason, MessageLevel) = 0; |
| 113 |
86 virtual void disconnect() = 0; // Will suppress didClose(). | 114 virtual void disconnect() = 0; // Will suppress didClose(). |
87 | 115 |
88 virtual void suspend() = 0; | 116 virtual void suspend() = 0; |
89 virtual void resume() = 0; | 117 virtual void resume() = 0; |
90 | 118 |
91 void ref() { refWebSocketChannel(); } | 119 void ref() { refWebSocketChannel(); } |
92 void deref() { derefWebSocketChannel(); } | 120 void deref() { derefWebSocketChannel(); } |
93 | 121 |
94 protected: | 122 protected: |
95 virtual ~WebSocketChannel() { } | 123 virtual ~WebSocketChannel() { } |
96 virtual void refWebSocketChannel() = 0; | 124 virtual void refWebSocketChannel() = 0; |
97 virtual void derefWebSocketChannel() = 0; | 125 virtual void derefWebSocketChannel() = 0; |
98 }; | 126 }; |
99 | 127 |
100 } // namespace WebCore | 128 } // namespace WebCore |
101 | 129 |
102 #endif // WebSocketChannel_h | 130 #endif // WebSocketChannel_h |
OLD | NEW |