| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 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 BLIMP_CLIENT_CORE_SESSION_CLIENT_NETWORK_COMPONENTS_H_ | |
| 6 #define BLIMP_CLIENT_CORE_SESSION_CLIENT_NETWORK_COMPONENTS_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/threading/thread_checker.h" | |
| 11 #include "blimp/client/core/session/assignment_source.h" | |
| 12 #include "blimp/client/core/session/network_event_observer.h" | |
| 13 #include "blimp/net/blimp_connection.h" | |
| 14 #include "blimp/net/browser_connection_handler.h" | |
| 15 #include "blimp/net/client_connection_manager.h" | |
| 16 | |
| 17 namespace blimp { | |
| 18 namespace client { | |
| 19 | |
| 20 // This class's functions and destruction must all be invoked on the IO thread | |
| 21 // by the owner. It is OK to construct the object on the main thread. The | |
| 22 // ThreadChecker is initialized in the call to Initialize. | |
| 23 class ClientNetworkComponents : public ConnectionHandler, | |
| 24 public ConnectionErrorObserver { | |
| 25 public: | |
| 26 // Can be created on any thread. | |
| 27 explicit ClientNetworkComponents( | |
| 28 std::unique_ptr<NetworkEventObserver> observer); | |
| 29 ~ClientNetworkComponents() override; | |
| 30 | |
| 31 // Sets up network components. | |
| 32 void Initialize(); | |
| 33 | |
| 34 // Starts the connection to the engine using the given |assignment|. | |
| 35 // It is required to first call Initialize. | |
| 36 void ConnectWithAssignment(const Assignment& assignment); | |
| 37 | |
| 38 BrowserConnectionHandler* GetBrowserConnectionHandler(); | |
| 39 | |
| 40 private: | |
| 41 // ConnectionHandler implementation. | |
| 42 void HandleConnection(std::unique_ptr<BlimpConnection> connection) override; | |
| 43 | |
| 44 // ConnectionErrorObserver implementation. | |
| 45 void OnConnectionError(int error) override; | |
| 46 | |
| 47 // The ThreadChecker is reset during the call to Initialize. | |
| 48 base::ThreadChecker io_thread_checker_; | |
| 49 | |
| 50 BrowserConnectionHandler connection_handler_; | |
| 51 std::unique_ptr<ClientConnectionManager> connection_manager_; | |
| 52 std::unique_ptr<NetworkEventObserver> network_observer_; | |
| 53 | |
| 54 DISALLOW_COPY_AND_ASSIGN(ClientNetworkComponents); | |
| 55 }; | |
| 56 | |
| 57 } // namespace client | |
| 58 } // namespace blimp | |
| 59 | |
| 60 #endif // BLIMP_CLIENT_CORE_SESSION_CLIENT_NETWORK_COMPONENTS_H_ | |
| OLD | NEW |