| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 Member<WebSocketChannel> m_mainWebSocketChannel; | 125 Member<WebSocketChannel> m_mainWebSocketChannel; |
| 126 Member<WebSocketChannelSyncHelper> m_syncHelper; | 126 Member<WebSocketChannelSyncHelper> m_syncHelper; |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 // Bridge for Peer. Running on the worker thread. | 129 // Bridge for Peer. Running on the worker thread. |
| 130 class Bridge final : public GarbageCollectedFinalized<Bridge> { | 130 class Bridge final : public GarbageCollectedFinalized<Bridge> { |
| 131 WTF_MAKE_NONCOPYABLE(Bridge); | 131 WTF_MAKE_NONCOPYABLE(Bridge); |
| 132 public: | 132 public: |
| 133 Bridge(WebSocketChannelClient*, WorkerGlobalScope&); | 133 Bridge(WebSocketChannelClient*, WorkerGlobalScope&); |
| 134 ~Bridge(); | 134 ~Bridge(); |
| 135 |
| 135 // SourceLocation parameter may be shown when the connection fails. | 136 // SourceLocation parameter may be shown when the connection fails. |
| 136 void initialize(std::unique_ptr<SourceLocation>); | 137 bool connect(std::unique_ptr<SourceLocation>, const KURL&, const String&
protocol); |
| 137 bool connect(const KURL&, const String& protocol); | 138 |
| 138 void send(const CString& message); | 139 void send(const CString& message); |
| 139 void send(const DOMArrayBuffer&, unsigned byteOffset, unsigned byteLengt
h); | 140 void send(const DOMArrayBuffer&, unsigned byteOffset, unsigned byteLengt
h); |
| 140 void send(PassRefPtr<BlobDataHandle>); | 141 void send(PassRefPtr<BlobDataHandle>); |
| 141 void close(int code, const String& reason); | 142 void close(int code, const String& reason); |
| 142 void fail(const String& reason, MessageLevel, std::unique_ptr<SourceLoca
tion>); | 143 void fail(const String& reason, MessageLevel, std::unique_ptr<SourceLoca
tion>); |
| 143 void disconnect(); | 144 void disconnect(); |
| 144 | 145 |
| 145 void createPeerOnMainThread(std::unique_ptr<SourceLocation>, WorkerThrea
dLifecycleContext*, ExecutionContext*); | 146 void connectOnMainThread(std::unique_ptr<SourceLocation>, WorkerThreadLi
fecycleContext*, const KURL&, const String& protocol, ExecutionContext*); |
| 146 | 147 |
| 147 // Returns null when |disconnect| has already been called. | 148 // Returns null when |disconnect| has already been called. |
| 148 WebSocketChannelClient* client() { return m_client; } | 149 WebSocketChannelClient* client() { return m_client; } |
| 149 | 150 |
| 150 DECLARE_TRACE(); | 151 DECLARE_TRACE(); |
| 151 // Promptly clear connection to peer + loader proxy. | 152 // Promptly clear connection to peer + loader proxy. |
| 152 EAGERLY_FINALIZE(); | 153 EAGERLY_FINALIZE(); |
| 153 | 154 |
| 154 private: | 155 private: |
| 155 // Returns false if shutdown event is received before method completion. | 156 // Returns false if shutdown event is received before method completion. |
| 156 bool waitForMethodCompletion(const WebTraceLocation&, std::unique_ptr<Ex
ecutionContextTask>); | 157 bool waitForMethodCompletion(const WebTraceLocation&, std::unique_ptr<Ex
ecutionContextTask>); |
| 157 | 158 |
| 158 Member<WebSocketChannelClient> m_client; | 159 Member<WebSocketChannelClient> m_client; |
| 159 Member<WorkerGlobalScope> m_workerGlobalScope; | 160 Member<WorkerGlobalScope> m_workerGlobalScope; |
| 160 RefPtr<WorkerLoaderProxy> m_loaderProxy; | 161 RefPtr<WorkerLoaderProxy> m_loaderProxy; |
| 161 Member<WebSocketChannelSyncHelper> m_syncHelper; | 162 Member<WebSocketChannelSyncHelper> m_syncHelper; |
| 162 CrossThreadPersistent<Peer> m_peer; | 163 CrossThreadPersistent<Peer> m_peer; |
| 163 }; | 164 }; |
| 164 | 165 |
| 165 private: | 166 private: |
| 166 WorkerWebSocketChannel(WorkerGlobalScope&, WebSocketChannelClient*, std::uni
que_ptr<SourceLocation>); | 167 WorkerWebSocketChannel(WorkerGlobalScope&, WebSocketChannelClient*, std::uni
que_ptr<SourceLocation>); |
| 167 | 168 |
| 168 Member<Bridge> m_bridge; | 169 Member<Bridge> m_bridge; |
| 169 std::unique_ptr<SourceLocation> m_locationAtConnection; | 170 std::unique_ptr<SourceLocation> m_locationAtConnection; |
| 170 }; | 171 }; |
| 171 | 172 |
| 172 } // namespace blink | 173 } // namespace blink |
| 173 | 174 |
| 174 #endif // WorkerWebSocketChannel_h | 175 #endif // WorkerWebSocketChannel_h |
| OLD | NEW |