| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_WEBSOCKETS_WEBSOCKET_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_WEBSOCKETS_WEBSOCKET_MANAGER_H_ |
| 6 #define CONTENT_BROWSER_WEBSOCKETS_WEBSOCKET_MANAGER_H_ | 6 #define CONTENT_BROWSER_WEBSOCKETS_WEBSOCKET_MANAGER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
| 13 #include "content/browser/websockets/websocket_impl.h" | 13 #include "content/browser/websockets/websocket_impl.h" |
| 14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
| 15 | 15 |
| 16 namespace shell { |
| 17 class InterfaceRegistry; |
| 18 } // namespace shell |
| 19 |
| 16 namespace content { | 20 namespace content { |
| 17 class StoragePartition; | 21 class StoragePartition; |
| 18 | 22 |
| 19 // The WebSocketManager is a per child process instance that manages the | 23 // The WebSocketManager is a per child process instance that manages the |
| 20 // lifecycle of WebSocketImpl objects. It is responsible for creating | 24 // lifecycle of WebSocketImpl objects. It is responsible for creating |
| 21 // WebSocketImpl objects for each WebSocketRequest and throttling the number of | 25 // WebSocketImpl objects for each WebSocketRequest and throttling the number of |
| 22 // WebSocketImpl objects in use. | 26 // WebSocketImpl objects in use. |
| 23 class CONTENT_EXPORT WebSocketManager | 27 class CONTENT_EXPORT WebSocketManager |
| 24 : NON_EXPORTED_BASE(public WebSocketImpl::Delegate) { | 28 : NON_EXPORTED_BASE(public WebSocketImpl::Delegate) { |
| 25 public: | 29 public: |
| 26 // Called on the UI thread: | 30 // Called on the UI thread: |
| 27 static void CreateWebSocket(int process_id, int frame_id, | 31 static void CreateWebSocket(int process_id, int frame_id, |
| 28 blink::mojom::WebSocketRequest request); | 32 mojom::WebSocketRequest request); |
| 29 | 33 |
| 30 protected: | 34 protected: |
| 31 class Handle; | 35 class Handle; |
| 32 friend class base::DeleteHelper<WebSocketManager>; | 36 friend class base::DeleteHelper<WebSocketManager>; |
| 33 | 37 |
| 34 // Called on the UI thread: | 38 // Called on the UI thread: |
| 35 WebSocketManager(int process_id, StoragePartition* storage_partition); | 39 WebSocketManager(int process_id, StoragePartition* storage_partition); |
| 36 | 40 |
| 37 // All other methods must run on the IO thread. | 41 // All other methods must run on the IO thread. |
| 38 | 42 |
| 39 ~WebSocketManager() override; | 43 ~WebSocketManager() override; |
| 40 void DoCreateWebSocket(int frame_id, blink::mojom::WebSocketRequest request); | 44 void DoCreateWebSocket(int frame_id, mojom::WebSocketRequest request); |
| 41 base::TimeDelta CalculateDelay() const; | 45 base::TimeDelta CalculateDelay() const; |
| 42 void ThrottlingPeriodTimerCallback(); | 46 void ThrottlingPeriodTimerCallback(); |
| 43 | 47 |
| 44 // This is virtual to support testing. | 48 // This is virtual to support testing. |
| 45 virtual WebSocketImpl* CreateWebSocketImpl( | 49 virtual WebSocketImpl* CreateWebSocketImpl(WebSocketImpl::Delegate* delegate, |
| 46 WebSocketImpl::Delegate* delegate, | 50 mojom::WebSocketRequest request, |
| 47 blink::mojom::WebSocketRequest request, | 51 int frame_id, |
| 48 int frame_id, | 52 base::TimeDelta delay); |
| 49 base::TimeDelta delay); | |
| 50 | 53 |
| 51 // WebSocketImpl::Delegate methods: | 54 // WebSocketImpl::Delegate methods: |
| 52 int GetClientProcessId() override; | 55 int GetClientProcessId() override; |
| 53 StoragePartition* GetStoragePartition() override; | 56 StoragePartition* GetStoragePartition() override; |
| 54 void OnReceivedResponseFromServer(WebSocketImpl* impl) override; | 57 void OnReceivedResponseFromServer(WebSocketImpl* impl) override; |
| 55 void OnLostConnectionToClient(WebSocketImpl* impl) override; | 58 void OnLostConnectionToClient(WebSocketImpl* impl) override; |
| 56 | 59 |
| 57 int process_id_; | 60 int process_id_; |
| 58 StoragePartition* storage_partition_; | 61 StoragePartition* storage_partition_; |
| 59 | 62 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 74 // period. | 77 // period. |
| 75 int64_t num_current_failed_connections_; | 78 int64_t num_current_failed_connections_; |
| 76 int64_t num_previous_failed_connections_; | 79 int64_t num_previous_failed_connections_; |
| 77 | 80 |
| 78 DISALLOW_COPY_AND_ASSIGN(WebSocketManager); | 81 DISALLOW_COPY_AND_ASSIGN(WebSocketManager); |
| 79 }; | 82 }; |
| 80 | 83 |
| 81 } // namespace content | 84 } // namespace content |
| 82 | 85 |
| 83 #endif // CONTENT_BROWSER_WEBSOCKETS_WEBSOCKET_MANAGER_H_ | 86 #endif // CONTENT_BROWSER_WEBSOCKETS_WEBSOCKET_MANAGER_H_ |
| OLD | NEW |