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

Side by Side Diff: third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.h

Issue 2270693002: WebSocket: Consolidate inter-thread synchronous function calls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comment Created 4 years, 3 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 class Peer final : public GarbageCollectedFinalized<Peer>, public WebSocketC hannelClient, public WorkerThreadLifecycleObserver { 88 class Peer final : public GarbageCollectedFinalized<Peer>, public WebSocketC hannelClient, public WorkerThreadLifecycleObserver {
89 USING_GARBAGE_COLLECTED_MIXIN(Peer); 89 USING_GARBAGE_COLLECTED_MIXIN(Peer);
90 WTF_MAKE_NONCOPYABLE(Peer); 90 WTF_MAKE_NONCOPYABLE(Peer);
91 public: 91 public:
92 Peer(Bridge*, PassRefPtr<WorkerLoaderProxy>, WebSocketChannelSyncHelper* , WorkerThreadLifecycleContext*); 92 Peer(Bridge*, PassRefPtr<WorkerLoaderProxy>, WebSocketChannelSyncHelper* , WorkerThreadLifecycleContext*);
93 ~Peer() override; 93 ~Peer() override;
94 94
95 // SourceLocation parameter may be shown when the connection fails. 95 // SourceLocation parameter may be shown when the connection fails.
96 bool initialize(std::unique_ptr<SourceLocation>, ExecutionContext*); 96 bool initialize(std::unique_ptr<SourceLocation>, ExecutionContext*);
97 97
98 void connect(const KURL&, const String& protocol); 98 bool connect(const KURL&, const String& protocol);
99 void sendTextAsCharVector(std::unique_ptr<Vector<char>>); 99 void sendTextAsCharVector(std::unique_ptr<Vector<char>>);
100 void sendBinaryAsCharVector(std::unique_ptr<Vector<char>>); 100 void sendBinaryAsCharVector(std::unique_ptr<Vector<char>>);
101 void sendBlob(PassRefPtr<BlobDataHandle>); 101 void sendBlob(PassRefPtr<BlobDataHandle>);
102 void close(int code, const String& reason); 102 void close(int code, const String& reason);
103 void fail(const String& reason, MessageLevel, std::unique_ptr<SourceLoca tion>); 103 void fail(const String& reason, MessageLevel, std::unique_ptr<SourceLoca tion>);
104 void disconnect(); 104 void disconnect();
105 105
106 DECLARE_VIRTUAL_TRACE(); 106 DECLARE_VIRTUAL_TRACE();
107 // Promptly clear connection to bridge + loader proxy. 107 // Promptly clear connection to bridge + loader proxy.
108 EAGERLY_FINALIZE(); 108 EAGERLY_FINALIZE();
(...skipping 16 matching lines...) Expand all
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
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698