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

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: 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_MANAGER_H_
6 #define CONTENT_BROWSER_WEBSOCKETS_WEBSOCKET_MANAGER_H_
7
8 #include <set>
9
10 #include "base/macros.h"
11 #include "base/timer/timer.h"
12 #include "content/browser/websockets/websocket_impl.h"
13 #include "content/common/content_export.h"
14
15 namespace content {
16
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 : public WebSocketImpl::Delegate {
24 public:
25 // May be constructed on any thread.
26 WebSocketManager(int process_id, StoragePartition* storage_partition);
27
28 // Call these on the IO thread.
29 ~WebSocketManager() override;
30 void CreateWebSocket(int render_frame_id, mojom::WebSocketRequest request);
31
32 private:
33 base::TimeDelta CalculateDelay() const;
34 void ThrottlingPeriodTimerCallback();
35
36 // WebSocketImpl::Delegate methods:
37 int GetClientProcessId() override;
38 StoragePartition* GetStoragePartition() override;
39 void OnReceivedResponseFromServer(WebSocketImpl* impl) override;
40 void OnLostConnectionToClient(WebSocketImpl* impl) override;
41
42 int process_id_;
43 StoragePartition* storage_partition_;
44
45 std::set<WebSocketImpl*> impls_;
46
47 // Timer and counters for per-renderer WebSocket throttling.
48 base::RepeatingTimer throttling_period_timer_;
49
50 // The current number of pending connections.
51 int num_pending_connections_;
52
53 // The number of handshakes that failed in the current and previous time
54 // period.
55 int64_t num_current_succeeded_connections_;
56 int64_t num_previous_succeeded_connections_;
57
58 // The number of handshakes that succeeded in the current and previous time
59 // period.
60 int64_t num_current_failed_connections_;
61 int64_t num_previous_failed_connections_;
62
63 DISALLOW_COPY_AND_ASSIGN(WebSocketManager);
64 };
65
66 } // namespace content
67
68 #endif // CONTENT_BROWSER_WEBSOCKETS_WEBSOCKET_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698