| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 BLIMP_CLIENT_SESSION_BLIMP_CLIENT_SESSION_H_ | 5 #ifndef BLIMP_CLIENT_SESSION_BLIMP_CLIENT_SESSION_H_ |
| 6 #define BLIMP_CLIENT_SESSION_BLIMP_CLIENT_SESSION_H_ | 6 #define BLIMP_CLIENT_SESSION_BLIMP_CLIENT_SESSION_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
| 14 #include "blimp/client/feature/compositor/client_image_serialization_processor.h
" |
| 14 #include "blimp/client/session/assignment_source.h" | 15 #include "blimp/client/session/assignment_source.h" |
| 15 #include "blimp/common/proto/blimp_message.pb.h" | 16 #include "blimp/common/proto/blimp_message.pb.h" |
| 16 #include "blimp/net/blimp_connection_statistics.h" | 17 #include "blimp/net/blimp_connection_statistics.h" |
| 17 #include "blimp/net/blimp_message_processor.h" | 18 #include "blimp/net/blimp_message_processor.h" |
| 18 | 19 |
| 19 namespace net { | 20 namespace net { |
| 20 class IPEndPoint; | 21 class IPEndPoint; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace blimp { | 24 namespace blimp { |
| 24 | 25 |
| 25 class BlimpMessageProcessor; | 26 class BlimpMessageProcessor; |
| 26 class BlimpMessageThreadPipe; | 27 class BlimpMessageThreadPipe; |
| 28 class BlobChannelReceiver; |
| 27 class BrowserConnectionHandler; | 29 class BrowserConnectionHandler; |
| 28 class ClientConnectionManager; | 30 class ClientConnectionManager; |
| 31 class HeliumBlobReceiverDelegate; |
| 29 class ThreadPipeManager; | 32 class ThreadPipeManager; |
| 30 | 33 |
| 31 namespace client { | 34 namespace client { |
| 32 | 35 |
| 33 class ClientNetworkComponents; | 36 class ClientNetworkComponents; |
| 34 class NavigationFeature; | 37 class NavigationFeature; |
| 35 class ImeFeature; | 38 class ImeFeature; |
| 36 class RenderWidgetFeature; | 39 class RenderWidgetFeature; |
| 37 class SettingsFeature; | 40 class SettingsFeature; |
| 38 class TabControlFeature; | 41 class TabControlFeature; |
| 39 | 42 |
| 40 class NetworkEventObserver { | 43 class NetworkEventObserver { |
| 41 public: | 44 public: |
| 42 NetworkEventObserver() {} | 45 NetworkEventObserver() {} |
| 43 virtual ~NetworkEventObserver() {} | 46 virtual ~NetworkEventObserver() {} |
| 44 | 47 |
| 45 virtual void OnConnected() = 0; | 48 virtual void OnConnected() = 0; |
| 46 virtual void OnDisconnected(int result) = 0; | 49 virtual void OnDisconnected(int result) = 0; |
| 47 }; | 50 }; |
| 48 | 51 |
| 49 // BlimpClientSession represents a single active session of Blimp on the client | 52 // BlimpClientSession represents a single active session of Blimp on the client |
| 50 // regardless of whether or not the client application is in the background or | 53 // regardless of whether or not the client application is in the background or |
| 51 // foreground. The only time this session is invalid is during initialization | 54 // foreground. The only time this session is invalid is during initialization |
| 52 // and shutdown of this particular client process (or Activity on Android). | 55 // and shutdown of this particular client process (or Activity on Android). |
| 53 // | 56 // |
| 54 // This session glues together the feature proxy components and the network | 57 // This session glues together the feature proxy components and the network |
| 55 // layer. The network components must be interacted with on the IO thread. The | 58 // layer. The network components must be interacted with on the IO thread. The |
| 56 // feature proxies must be interacted with on the UI thread. | 59 // feature proxies must be interacted with on the UI thread. |
| 57 class BlimpClientSession : public NetworkEventObserver { | 60 class BlimpClientSession |
| 61 : public NetworkEventObserver, |
| 62 public ClientImageSerializationProcessor::ErrorDelegate { |
| 58 public: | 63 public: |
| 59 explicit BlimpClientSession(const GURL& assigner_endpoint); | 64 explicit BlimpClientSession(const GURL& assigner_endpoint); |
| 60 | 65 |
| 61 // Uses the AssignmentSource to get an Assignment and then uses the assignment | 66 // Uses the AssignmentSource to get an Assignment and then uses the assignment |
| 62 // configuration to connect to the Blimplet. | 67 // configuration to connect to the Blimplet. |
| 63 // |client_auth_token| is the OAuth2 access token to use when querying | 68 // |client_auth_token| is the OAuth2 access token to use when querying |
| 64 // for an assignment. This token needs the OAuth2 scope of userinfo.email and | 69 // for an assignment. This token needs the OAuth2 scope of userinfo.email and |
| 65 // only needs to be an access token, not a refresh token. | 70 // only needs to be an access token, not a refresh token. |
| 66 void Connect(const std::string& client_auth_token); | 71 void Connect(const std::string& client_auth_token); |
| 67 | 72 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 86 virtual void OnAssignmentConnectionAttempted(AssignmentSource::Result result, | 91 virtual void OnAssignmentConnectionAttempted(AssignmentSource::Result result, |
| 87 const Assignment& assignment); | 92 const Assignment& assignment); |
| 88 | 93 |
| 89 private: | 94 private: |
| 90 void RegisterFeatures(); | 95 void RegisterFeatures(); |
| 91 | 96 |
| 92 // NetworkEventObserver implementation. | 97 // NetworkEventObserver implementation. |
| 93 void OnConnected() override; | 98 void OnConnected() override; |
| 94 void OnDisconnected(int result) override; | 99 void OnDisconnected(int result) override; |
| 95 | 100 |
| 101 // ClientImageSerializationProcessor::ErrorDelegate implementation. |
| 102 void OnImageDecodeError() override; |
| 103 |
| 96 base::Thread io_thread_; | 104 base::Thread io_thread_; |
| 105 |
| 106 // Receives blob BlimpMessages and relays them to BlobChannelReceiver. |
| 107 // Owned by BlobChannelReceiver, therefore stored as a raw pointer here. |
| 108 HeliumBlobReceiverDelegate* blob_delegate_ = nullptr; |
| 109 |
| 110 std::unique_ptr<BlobChannelReceiver> blob_receiver_; |
| 97 std::unique_ptr<TabControlFeature> tab_control_feature_; | 111 std::unique_ptr<TabControlFeature> tab_control_feature_; |
| 98 std::unique_ptr<NavigationFeature> navigation_feature_; | 112 std::unique_ptr<NavigationFeature> navigation_feature_; |
| 99 std::unique_ptr<ImeFeature> ime_feature_; | 113 std::unique_ptr<ImeFeature> ime_feature_; |
| 100 std::unique_ptr<RenderWidgetFeature> render_widget_feature_; | 114 std::unique_ptr<RenderWidgetFeature> render_widget_feature_; |
| 101 std::unique_ptr<SettingsFeature> settings_feature_; | 115 std::unique_ptr<SettingsFeature> settings_feature_; |
| 102 | 116 |
| 103 // The AssignmentSource is used when the user of BlimpClientSession calls | 117 // The AssignmentSource is used when the user of BlimpClientSession calls |
| 104 // Connect() to get a valid assignment and later connect to the engine. | 118 // Connect() to get a valid assignment and later connect to the engine. |
| 105 std::unique_ptr<AssignmentSource> assignment_source_; | 119 std::unique_ptr<AssignmentSource> assignment_source_; |
| 106 | 120 |
| 107 // Collects details of network, such as number of commits and bytes | 121 // Collects details of network, such as number of commits and bytes |
| 108 // transferred over network. Ownership is maintained on the IO thread. | 122 // transferred over network. Ownership is maintained on the IO thread. |
| 109 BlimpConnectionStatistics* blimp_connection_statistics_; | 123 BlimpConnectionStatistics* blimp_connection_statistics_; |
| 110 | 124 |
| 111 // Container struct for network components. | 125 // Container struct for network components. |
| 112 // Must be deleted on the IO thread. | 126 // Must be deleted on the IO thread. |
| 113 std::unique_ptr<ClientNetworkComponents> net_components_; | 127 std::unique_ptr<ClientNetworkComponents> net_components_; |
| 114 | 128 |
| 115 std::unique_ptr<ThreadPipeManager> thread_pipe_manager_; | 129 std::unique_ptr<ThreadPipeManager> thread_pipe_manager_; |
| 116 | 130 |
| 117 base::WeakPtrFactory<BlimpClientSession> weak_factory_; | 131 base::WeakPtrFactory<BlimpClientSession> weak_factory_; |
| 118 | 132 |
| 119 DISALLOW_COPY_AND_ASSIGN(BlimpClientSession); | 133 DISALLOW_COPY_AND_ASSIGN(BlimpClientSession); |
| 120 }; | 134 }; |
| 121 | 135 |
| 122 } // namespace client | 136 } // namespace client |
| 123 } // namespace blimp | 137 } // namespace blimp |
| 124 | 138 |
| 125 #endif // BLIMP_CLIENT_SESSION_BLIMP_CLIENT_SESSION_H_ | 139 #endif // BLIMP_CLIENT_SESSION_BLIMP_CLIENT_SESSION_H_ |
| OLD | NEW |