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/browser/websockets/websocket_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_BROWSER_WEBSOCKETS_WEBSOCKET_IMPL_H_
6 #define CONTENT_BROWSER_WEBSOCKETS_WEBSOCKET_IMPL_H_
7
8 #include <stdint.h>
9
10 #include <memory>
11 #include <string>
12 #include <vector>
13
14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h"
16 #include "base/time/time.h"
17 #include "content/common/content_export.h"
18 #include "content/common/websocket.mojom.h"
19 #include "mojo/public/cpp/bindings/binding.h"
20
21 class GURL;
22
23 namespace url {
24 class Origin;
25 } // namespace url
26
27 namespace net {
28 class WebSocketChannel;
29 class URLRequestContext;
30 } // namespace net
31
32 namespace IPC {
33 class Message;
34 } // namespace IPC
35
36 namespace content {
37 class StoragePartition;
38
39 // Host of net::WebSocketChannel.
40 class CONTENT_EXPORT WebSocketImpl : public mojom::WebSocket {
41 public:
42 class Delegate {
43 public:
44 virtual ~Delegate() {}
45 virtual int GetClientProcessId() = 0;
46 virtual StoragePartition* GetStoragePartition() = 0;
47 virtual void OnReceivedResponseFromServer(WebSocketImpl* impl) = 0;
48 virtual void OnLostConnectionToClient(WebSocketImpl* impl) = 0;
49 };
50
51 WebSocketImpl(Delegate* delegate,
52 mojom::WebSocketRequest request,
53 int render_frame_id,
54 base::TimeDelta delay);
55 ~WebSocketImpl() override;
56
57 // mojom::WebSocket methods:
Ben Goodger (Google) 2016/07/07 20:49:19 looks like a stray comment
58
59 // The renderer process is going away.
60 // This function is virtual for testing.
61 virtual void GoAway();
62
63 // mojom::WebSocket methods:
64 void Initialize(mojom::WebSocketClientPtr client) override;
65 void AddChannelRequest(const GURL& url,
66 mojo::Array<mojo::String> requested_protocols,
67 const url::Origin& origin,
68 const mojo::String& user_agent_override) override;
69 void SendFrame(bool fin, mojom::WebSocketMessageType type,
70 mojo::Array<uint8_t> data) override;
71 void SendFlowControl(int64_t quota) override;
72 void StartClosingHandshake(uint16_t code,
73 const mojo::String& reason) override;
74
75 bool handshake_succeeded() const { return handshake_succeeded_; }
76 void OnHandshakeSucceeded() { handshake_succeeded_ = true; }
77
78 private:
79 class WebSocketEventHandler;
80
81 void OnConnectionError();
82 void AddChannel(const GURL& socket_url,
83 const std::vector<std::string>& requested_protocols,
84 const url::Origin& origin,
85 const std::string& user_agent_override);
86
87 Delegate* delegate_;
88 mojo::Binding<mojom::WebSocket> binding_;
89
90 mojom::WebSocketClientPtr client_;
91
92 int render_frame_id_;
93
94 // The channel we use to send events to the network.
95 std::unique_ptr<net::WebSocketChannel> channel_;
96
97 // Delay used for per-renderer WebSocket throttling.
98 base::TimeDelta delay_;
99
100 // SendFlowControl() is delayed when OnFlowControl() is called before
101 // AddChannel() is called.
102 // Zero indicates there is no pending SendFlowControl().
103 int64_t pending_flow_control_quota_;
104
105 // handshake_succeeded_ is set and used by WebSocketDispatcherHost
106 // to manage counters for per-renderer WebSocket throttling.
107 bool handshake_succeeded_;
108
109 base::WeakPtrFactory<WebSocketImpl> weak_ptr_factory_;
110
111 DISALLOW_COPY_AND_ASSIGN(WebSocketImpl);
112 };
113
114 } // namespace content
115
116 #endif // CONTENT_BROWSER_WEBSOCKETS_WEBSOCKET_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698