| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_CORE_CONTEXT_BLIMP_CLIENT_CONTEXT_IMPL_H_ | 5 #ifndef BLIMP_CLIENT_CORE_CONTEXT_BLIMP_CLIENT_CONTEXT_IMPL_H_ |
| 6 #define BLIMP_CLIENT_CORE_CONTEXT_BLIMP_CLIENT_CONTEXT_IMPL_H_ | 6 #define BLIMP_CLIENT_CORE_CONTEXT_BLIMP_CLIENT_CONTEXT_IMPL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <unordered_map> | 10 #include <unordered_map> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
| 17 #include "blimp/client/core/compositor/blob_image_serialization_processor.h" | 17 #include "blimp/client/core/compositor/blob_image_serialization_processor.h" |
| 18 #include "blimp/client/core/context/assignment_fetcher.h" |
| 18 #include "blimp/client/core/session/client_network_components.h" | 19 #include "blimp/client/core/session/client_network_components.h" |
| 19 #include "blimp/client/core/session/connection_status.h" | 20 #include "blimp/client/core/session/connection_status.h" |
| 20 #include "blimp/client/core/session/identity_source.h" | |
| 21 #include "blimp/client/core/settings/blimp_settings_delegate.h" | 21 #include "blimp/client/core/settings/blimp_settings_delegate.h" |
| 22 #include "blimp/client/public/blimp_client_context.h" | 22 #include "blimp/client/public/blimp_client_context.h" |
| 23 #include "blimp/client/public/contents/blimp_contents.h" | 23 #include "blimp/client/public/contents/blimp_contents.h" |
| 24 #include "blimp/client/public/session/assignment.h" | 24 #include "blimp/client/public/session/assignment.h" |
| 25 #include "blimp/net/thread_pipe_manager.h" | 25 #include "blimp/net/thread_pipe_manager.h" |
| 26 #include "url/gurl.h" | 26 #include "url/gurl.h" |
| 27 | 27 |
| 28 namespace blimp { | 28 namespace blimp { |
| 29 namespace client { | 29 namespace client { |
| 30 | 30 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 protected: | 70 protected: |
| 71 // Returns the URL to use for connections to the assigner. Used to construct | 71 // Returns the URL to use for connections to the assigner. Used to construct |
| 72 // the AssignmentSource. | 72 // the AssignmentSource. |
| 73 virtual GURL GetAssignerURL(); | 73 virtual GURL GetAssignerURL(); |
| 74 | 74 |
| 75 // BlimpSettingsDelegate implementation. | 75 // BlimpSettingsDelegate implementation. |
| 76 IdentitySource* GetIdentitySource() override; | 76 IdentitySource* GetIdentitySource() override; |
| 77 ConnectionStatus* GetConnectionStatus() override; | 77 ConnectionStatus* GetConnectionStatus() override; |
| 78 | 78 |
| 79 private: | 79 private: |
| 80 // Called when an OAuth2 token is received. Will then ask the | |
| 81 // AssignmentSource for an Assignment with this token. | |
| 82 virtual void OnAuthTokenReceived(const std::string& client_auth_token); | |
| 83 | |
| 84 // Called when the AssignmentSource is finished getting an Assignment. Will | 80 // Called when the AssignmentSource is finished getting an Assignment. Will |
| 85 // then call |ConnectWithAssignment| to initiate the actual connection. | 81 // then call |ConnectWithAssignment| to initiate the actual connection. |
| 86 virtual void OnAssignmentReceived(AssignmentRequestResult result, | 82 virtual void OnAssignmentReceived(AssignmentRequestResult result, |
| 87 const Assignment& assignment); | 83 const Assignment& assignment); |
| 88 | 84 |
| 89 void RegisterFeatures(); | 85 void RegisterFeatures(); |
| 90 void InitializeSettings(); | 86 void InitializeSettings(); |
| 91 | 87 |
| 92 // Terminates the active connection held by |net_connections_|. | 88 // Terminates the active connection held by |net_connections_|. |
| 93 // May be called on any thread. | 89 // May be called on any thread. |
| 94 void DropConnection(); | 90 void DropConnection(); |
| 95 | 91 |
| 96 // Create IdentitySource which provides user sign in states and OAuth2 token | |
| 97 // service. | |
| 98 void CreateIdentitySource(); | |
| 99 | |
| 100 // BlobImageSerializationProcessor::ErrorDelegate implementation. | 92 // BlobImageSerializationProcessor::ErrorDelegate implementation. |
| 101 void OnImageDecodeError() override; | 93 void OnImageDecodeError() override; |
| 102 | 94 |
| 103 // NetworkEventObserver implementation. | 95 // NetworkEventObserver implementation. |
| 104 void OnConnected() override; | 96 void OnConnected() override; |
| 105 void OnDisconnected(int result) override; | 97 void OnDisconnected(int result) override; |
| 106 | 98 |
| 107 // Provides functionality from the embedder. | 99 // Provides functionality from the embedder. |
| 108 BlimpClientContextDelegate* delegate_ = nullptr; | 100 BlimpClientContextDelegate* delegate_ = nullptr; |
| 109 | 101 |
| 110 // The task runner to use for IO operations. | 102 // The task runner to use for IO operations. |
| 111 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_; | 103 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_; |
| 112 | 104 |
| 113 // The task runner to use for file operations. | 105 // The task runner to use for file operations. |
| 114 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner_; | 106 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner_; |
| 115 | 107 |
| 116 // The AssignmentSource is used when the user of BlimpClientContextImpl calls | |
| 117 // Connect() to get a valid assignment and later connect to the engine. | |
| 118 std::unique_ptr<AssignmentSource> assignment_source_; | |
| 119 | |
| 120 // A set of dependencies required by all BlimpCompositor instances. | 108 // A set of dependencies required by all BlimpCompositor instances. |
| 121 std::unique_ptr<BlimpCompositorDependencies> blimp_compositor_dependencies_; | 109 std::unique_ptr<BlimpCompositorDependencies> blimp_compositor_dependencies_; |
| 122 | 110 |
| 123 // Features to handle all incoming and outgoing protobuf messages. | 111 // Features to handle all incoming and outgoing protobuf messages. |
| 124 std::unique_ptr<BlobChannelFeature> blob_channel_feature_; | 112 std::unique_ptr<BlobChannelFeature> blob_channel_feature_; |
| 125 std::unique_ptr<GeolocationFeature> geolocation_feature_; | 113 std::unique_ptr<GeolocationFeature> geolocation_feature_; |
| 126 std::unique_ptr<ImeFeature> ime_feature_; | 114 std::unique_ptr<ImeFeature> ime_feature_; |
| 127 std::unique_ptr<NavigationFeature> navigation_feature_; | 115 std::unique_ptr<NavigationFeature> navigation_feature_; |
| 128 std::unique_ptr<RenderWidgetFeature> render_widget_feature_; | 116 std::unique_ptr<RenderWidgetFeature> render_widget_feature_; |
| 129 std::unique_ptr<SettingsFeature> settings_feature_; | 117 std::unique_ptr<SettingsFeature> settings_feature_; |
| 130 std::unique_ptr<TabControlFeature> tab_control_feature_; | 118 std::unique_ptr<TabControlFeature> tab_control_feature_; |
| 131 | 119 |
| 132 std::unique_ptr<BlimpContentsManager> blimp_contents_manager_; | 120 std::unique_ptr<BlimpContentsManager> blimp_contents_manager_; |
| 133 | 121 |
| 134 // Container struct for network components. | 122 // Container struct for network components. |
| 135 // Must be deleted on the IO thread. | 123 // Must be deleted on the IO thread. |
| 136 std::unique_ptr<ClientNetworkComponents> net_components_; | 124 std::unique_ptr<ClientNetworkComponents> net_components_; |
| 137 | 125 |
| 138 std::unique_ptr<ThreadPipeManager> thread_pipe_manager_; | 126 std::unique_ptr<ThreadPipeManager> thread_pipe_manager_; |
| 139 | 127 |
| 140 // Provide OAuth2 token and propagate account sign in states change. | 128 std::unique_ptr<AssignmentFetcher> assignment_fetcher_; |
| 141 std::unique_ptr<IdentitySource> identity_source_; | |
| 142 | 129 |
| 143 // Connection status to the engine. | 130 // Connection status to the engine. |
| 144 ConnectionStatus connection_status_; | 131 ConnectionStatus connection_status_; |
| 145 | 132 |
| 146 base::WeakPtrFactory<BlimpClientContextImpl> weak_factory_; | 133 base::WeakPtrFactory<BlimpClientContextImpl> weak_factory_; |
| 147 | 134 |
| 148 DISALLOW_COPY_AND_ASSIGN(BlimpClientContextImpl); | 135 DISALLOW_COPY_AND_ASSIGN(BlimpClientContextImpl); |
| 149 }; | 136 }; |
| 150 | 137 |
| 151 } // namespace client | 138 } // namespace client |
| 152 } // namespace blimp | 139 } // namespace blimp |
| 153 | 140 |
| 154 #endif // BLIMP_CLIENT_CORE_CONTEXT_BLIMP_CLIENT_CONTEXT_IMPL_H_ | 141 #endif // BLIMP_CLIENT_CORE_CONTEXT_BLIMP_CLIENT_CONTEXT_IMPL_H_ |
| OLD | NEW |