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

Side by Side Diff: Source/modules/websockets/WebSocketChannel.h

Issue 14657008: Make websocket error messages look better at the devtools console. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 7 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) 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
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
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> callStack() { return ScriptCallStack::create (m_frames); }
tkent 2013/05/06 22:56:40 The function name should be start with 'create'.
yhirano 2013/05/07 01:08:08 Done.
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 show n at the devtool console.
102 // The CallStackWrapper parameter is callstack information. it may be shown with the reason text at the devtool console.
103 // If the parameter is null, the instance may fill the callstack information and show it with the reason text if possible.
104 virtual void fail(const String& reason, MessageLevel, PassOwnPtr<CallStackWr apper>) = 0;
105
106 // Log the reason text and close the connection. Will call didClose().
107 // The MessageLevel parameter will be used for the level of the message show n at the devtool console.
108 // The instance may fill the callstack information and show it with the reas on text if possible.
109 virtual void fail(const String& reason, MessageLevel) = 0;
110
86 virtual void disconnect() = 0; // Will suppress didClose(). 111 virtual void disconnect() = 0; // Will suppress didClose().
87 112
88 virtual void suspend() = 0; 113 virtual void suspend() = 0;
89 virtual void resume() = 0; 114 virtual void resume() = 0;
90 115
91 void ref() { refWebSocketChannel(); } 116 void ref() { refWebSocketChannel(); }
92 void deref() { derefWebSocketChannel(); } 117 void deref() { derefWebSocketChannel(); }
93 118
94 protected: 119 protected:
95 virtual ~WebSocketChannel() { } 120 virtual ~WebSocketChannel() { }
96 virtual void refWebSocketChannel() = 0; 121 virtual void refWebSocketChannel() = 0;
97 virtual void derefWebSocketChannel() = 0; 122 virtual void derefWebSocketChannel() = 0;
98 }; 123 };
99 124
100 } // namespace WebCore 125 } // namespace WebCore
101 126
102 #endif // WebSocketChannel_h 127 #endif // WebSocketChannel_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698