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

Side by Side Diff: content/renderer/websockethandle_impl.h

Issue 2119973002: Port WebSockets to Mojo IPC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused code Created 4 years, 5 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
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_RENDERER_WEBSOCKETHANDLE_IMPL_H_
6 #define CONTENT_RENDERER_WEBSOCKETHANDLE_IMPl_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10 #include <string>
11 #include <vector>
12
13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h"
15 #include "content/common/websocket.mojom.h"
16 #include "mojo/public/cpp/bindings/binding.h"
17 #include "third_party/WebKit/public/platform/WebVector.h"
18 #include "third_party/WebKit/public/platform/modules/websockets/WebSocketHandle. h"
19
20 namespace blink {
21 class WebSecurityOrigin;
22 class WebString;
23 class WebURL;
24 } // namespace blink
25
26 namespace shell {
27 class InterfaceProvider;
28 }
29
30 namespace content {
31
32 class WebSocketHandleImpl : public blink::WebSocketHandle,
33 public mojom::WebSocketClient {
34 public:
35 WebSocketHandleImpl();
36
37 // This must be called before connect() and may be called more than once.
38 // This serves as a way to lazily construct the WebSocketPtr to support
39 // SharedWorkers, which do not have an associated WebFrame and hence no
40 // willOpenSocketHandle notification.
41 void SetInterfaceProvider(
42 const base::WeakPtr<shell::InterfaceProvider>& interface_provider);
43
44 // blink::WebSocketHandle methods:
45 void connect(const blink::WebURL& url,
46 const blink::WebVector<blink::WebString>& protocols,
47 const blink::WebSecurityOrigin& origin,
48 const blink::WebString& user_agent_override,
49 blink::WebSocketHandleClient* client) override;
50 void send(bool fin,
51 WebSocketHandle::MessageType type,
52 const char* data,
53 size_t size) override;
54 void flowControl(int64_t quota) override;
55 void close(unsigned short code, const blink::WebString& reason) override;
56
57 private:
58 ~WebSocketHandleImpl() override;
59 void Disconnect();
60 void OnConnectionError();
61
62 // mojom::WebSocketClient methods:
63 void OnFailChannel(const mojo::String& reason) override;
64 void OnStartOpeningHandshake(
65 mojom::WebSocketHandshakeRequestPtr request) override;
66 void OnFinishOpeningHandshake(
67 mojom::WebSocketHandshakeResponsePtr response) override;
68 void OnAddChannelResponse(const mojo::String& selected_protocol,
69 const mojo::String& extensions) override;
70 void OnDataFrame(bool fin, mojom::WebSocketMessageType type,
71 mojo::Array<uint8_t> data) override;
72 void OnFlowControl(int64_t quota) override;
73 void OnDropChannel(bool was_clean, uint16_t code,
74 const mojo::String& reason) override;
75 void OnClosingHandshake() override;
76
77 base::WeakPtr<shell::InterfaceProvider> interface_provider_;
78
79 blink::WebSocketHandleClient* client_;
80
81 mojom::WebSocketPtr websocket_;
82 mojo::Binding<mojom::WebSocketClient> client_binding_;
83
84 DISALLOW_COPY_AND_ASSIGN(WebSocketHandleImpl);
85 };
86
87 } // namespace content
88
89 #endif // CONTENT_RENDERER_WEBSOCKETHANDLE_IMPl_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698