OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 namespace WebCore { | 47 namespace WebCore { |
48 | 48 |
49 class BlobDataHandle; | 49 class BlobDataHandle; |
50 class KURL; | 50 class KURL; |
51 class ExecutionContext; | 51 class ExecutionContext; |
52 class ThreadableWebSocketChannelClientWrapper; | 52 class ThreadableWebSocketChannelClientWrapper; |
53 class WorkerGlobalScope; | 53 class WorkerGlobalScope; |
54 class WorkerLoaderProxy; | 54 class WorkerLoaderProxy; |
55 class WorkerRunLoop; | 55 class WorkerRunLoop; |
56 | 56 |
57 class WorkerThreadableWebSocketChannel : public RefCounted<WorkerThreadableWebSo
cketChannel>, public WebSocketChannel { | 57 class WorkerThreadableWebSocketChannel FINAL : public RefCounted<WorkerThreadabl
eWebSocketChannel>, public WebSocketChannel { |
58 WTF_MAKE_FAST_ALLOCATED; | 58 WTF_MAKE_FAST_ALLOCATED; |
59 public: | 59 public: |
60 static PassRefPtr<WebSocketChannel> create(WorkerGlobalScope* workerGlobalSc
ope, WebSocketChannelClient* client, const String& taskMode, const String& sourc
eURL, unsigned lineNumber) | 60 static PassRefPtr<WebSocketChannel> create(WorkerGlobalScope* workerGlobalSc
ope, WebSocketChannelClient* client, const String& taskMode, const String& sourc
eURL, unsigned lineNumber) |
61 { | 61 { |
62 return adoptRef(new WorkerThreadableWebSocketChannel(workerGlobalScope,
client, taskMode, sourceURL, lineNumber)); | 62 return adoptRef(new WorkerThreadableWebSocketChannel(workerGlobalScope,
client, taskMode, sourceURL, lineNumber)); |
63 } | 63 } |
64 virtual ~WorkerThreadableWebSocketChannel(); | 64 virtual ~WorkerThreadableWebSocketChannel(); |
65 | 65 |
66 // WebSocketChannel functions. | 66 // WebSocketChannel functions. |
67 virtual void connect(const KURL&, const String& protocol) OVERRIDE; | 67 virtual void connect(const KURL&, const String& protocol) OVERRIDE; |
68 virtual String subprotocol() OVERRIDE; | 68 virtual String subprotocol() OVERRIDE; |
69 virtual String extensions() OVERRIDE; | 69 virtual String extensions() OVERRIDE; |
70 virtual WebSocketChannel::SendResult send(const String& message) OVERRIDE; | 70 virtual WebSocketChannel::SendResult send(const String& message) OVERRIDE; |
71 virtual WebSocketChannel::SendResult send(const ArrayBuffer&, unsigned byteO
ffset, unsigned byteLength) OVERRIDE; | 71 virtual WebSocketChannel::SendResult send(const ArrayBuffer&, unsigned byteO
ffset, unsigned byteLength) OVERRIDE; |
72 virtual WebSocketChannel::SendResult send(PassRefPtr<BlobDataHandle>) OVERRI
DE; | 72 virtual WebSocketChannel::SendResult send(PassRefPtr<BlobDataHandle>) OVERRI
DE; |
73 virtual unsigned long bufferedAmount() const OVERRIDE; | 73 virtual unsigned long bufferedAmount() const OVERRIDE; |
74 virtual void close(int code, const String& reason) OVERRIDE; | 74 virtual void close(int code, const String& reason) OVERRIDE; |
75 virtual void fail(const String& reason, MessageLevel, const String&, unsigne
d) OVERRIDE; | 75 virtual void fail(const String& reason, MessageLevel, const String&, unsigne
d) OVERRIDE; |
76 virtual void disconnect() OVERRIDE; // Will suppress didClose(). | 76 virtual void disconnect() OVERRIDE; // Will suppress didClose(). |
77 virtual void suspend() OVERRIDE; | 77 virtual void suspend() OVERRIDE; |
78 virtual void resume() OVERRIDE; | 78 virtual void resume() OVERRIDE; |
79 | 79 |
80 // Generated by the bridge. The Peer and its bridge should have identical | 80 // Generated by the bridge. The Peer and its bridge should have identical |
81 // lifetimes. | 81 // lifetimes. |
82 class Peer : public WebSocketChannelClient { | 82 class Peer FINAL : public WebSocketChannelClient { |
83 WTF_MAKE_NONCOPYABLE(Peer); WTF_MAKE_FAST_ALLOCATED; | 83 WTF_MAKE_NONCOPYABLE(Peer); WTF_MAKE_FAST_ALLOCATED; |
84 public: | 84 public: |
85 // sourceURLAtConnection and lineNumberAtConnection parameters may | 85 // sourceURLAtConnection and lineNumberAtConnection parameters may |
86 // be shown when the connection fails. | 86 // be shown when the connection fails. |
87 static Peer* create(PassRefPtr<ThreadableWebSocketChannelClientWrapper>
clientWrapper, WorkerLoaderProxy& loaderProxy, ExecutionContext* context, const
String& taskMode, const String& sourceURLAtConnection, unsigned lineNumberAtConn
ection) | 87 static Peer* create(PassRefPtr<ThreadableWebSocketChannelClientWrapper>
clientWrapper, WorkerLoaderProxy& loaderProxy, ExecutionContext* context, const
String& taskMode, const String& sourceURLAtConnection, unsigned lineNumberAtConn
ection) |
88 { | 88 { |
89 return new Peer(clientWrapper, loaderProxy, context, taskMode, sourc
eURLAtConnection, lineNumberAtConnection); | 89 return new Peer(clientWrapper, loaderProxy, context, taskMode, sourc
eURLAtConnection, lineNumberAtConnection); |
90 } | 90 } |
91 ~Peer(); | 91 virtual ~Peer(); |
92 | 92 |
93 void connect(const KURL&, const String& protocol); | 93 void connect(const KURL&, const String& protocol); |
94 void send(const String& message); | 94 void send(const String& message); |
95 void send(const ArrayBuffer&); | 95 void send(const ArrayBuffer&); |
96 void send(PassRefPtr<BlobDataHandle>); | 96 void send(PassRefPtr<BlobDataHandle>); |
97 void bufferedAmount(); | 97 void bufferedAmount(); |
98 void close(int code, const String& reason); | 98 void close(int code, const String& reason); |
99 void fail(const String& reason, MessageLevel, const String& sourceURL, u
nsigned lineNumber); | 99 void fail(const String& reason, MessageLevel, const String& sourceURL, u
nsigned lineNumber); |
100 void disconnect(); | 100 void disconnect(); |
101 void suspend(); | 101 void suspend(); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 RefPtr<WorkerGlobalScope> m_workerGlobalScope; | 195 RefPtr<WorkerGlobalScope> m_workerGlobalScope; |
196 RefPtr<ThreadableWebSocketChannelClientWrapper> m_workerClientWrapper; | 196 RefPtr<ThreadableWebSocketChannelClientWrapper> m_workerClientWrapper; |
197 RefPtr<Bridge> m_bridge; | 197 RefPtr<Bridge> m_bridge; |
198 String m_sourceURLAtConnection; | 198 String m_sourceURLAtConnection; |
199 unsigned m_lineNumberAtConnection; | 199 unsigned m_lineNumberAtConnection; |
200 }; | 200 }; |
201 | 201 |
202 } // namespace WebCore | 202 } // namespace WebCore |
203 | 203 |
204 #endif // WorkerThreadableWebSocketChannel_h | 204 #endif // WorkerThreadableWebSocketChannel_h |
OLD | NEW |