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

Side by Side Diff: content/browser/websockets/websocket_manager.h

Issue 2119973002: Port WebSockets to Mojo IPC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 4 years, 4 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_MANAGER_H_
6 #define CONTENT_BROWSER_WEBSOCKETS_WEBSOCKET_MANAGER_H_
7
8 #include <set>
9
10 #include "base/compiler_specific.h"
11 #include "base/macros.h"
12 #include "base/timer/timer.h"
13 #include "content/browser/websockets/websocket_impl.h"
14 #include "content/common/content_export.h"
15
16 namespace content {
17 class StoragePartition;
18
19 // The WebSocketManager is a per child process instance that manages the
20 // lifecycle of WebSocketImpl objects. It is responsible for creating
21 // WebSocketImpl objects for each WebSocketRequest and throttling the number of
22 // WebSocketImpl objects in use.
23 class CONTENT_EXPORT WebSocketManager
24 : NON_EXPORTED_BASE(public WebSocketImpl::Delegate) {
25 public:
26 static void CreateWebSocket(int process_id, mojom::WebSocketRequest request);
27
28 protected:
29 class Handle;
30 friend class base::DeleteHelper<WebSocketManager>;
31
32 // May be constructed on any thread.
33 WebSocketManager(int process_id, StoragePartition* storage_partition);
34
35 // All other methods must run on the IO thread.
36
37 ~WebSocketManager() override;
38 void DoCreateWebSocket(mojom::WebSocketRequest request);
39 base::TimeDelta CalculateDelay() const;
40 void ThrottlingPeriodTimerCallback();
41
42 // This is virtual to support testing.
43 virtual WebSocketImpl* CreateWebSocketImpl(WebSocketImpl::Delegate* delegate,
44 mojom::WebSocketRequest request,
45 base::TimeDelta delay);
46
47 // WebSocketImpl::Delegate methods:
48 int GetClientProcessId() override;
49 StoragePartition* GetStoragePartition() override;
50 void OnReceivedResponseFromServer(WebSocketImpl* impl) override;
51 void OnLostConnectionToClient(WebSocketImpl* impl) override;
52
53 int process_id_;
54 StoragePartition* storage_partition_;
55
56 std::set<WebSocketImpl*> impls_;
57
58 // Timer and counters for per-renderer WebSocket throttling.
59 base::RepeatingTimer throttling_period_timer_;
60
61 // The current number of pending connections.
62 int num_pending_connections_;
63
64 // The number of handshakes that failed in the current and previous time
65 // period.
66 int64_t num_current_succeeded_connections_;
67 int64_t num_previous_succeeded_connections_;
68
69 // The number of handshakes that succeeded in the current and previous time
70 // period.
71 int64_t num_current_failed_connections_;
72 int64_t num_previous_failed_connections_;
73
74 DISALLOW_COPY_AND_ASSIGN(WebSocketManager);
75 };
76
77 } // namespace content
78
79 #endif // CONTENT_BROWSER_WEBSOCKETS_WEBSOCKET_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698