| 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 29 matching lines...) Expand all Loading... |
| 60 void SetDelegate(BlimpClientContextDelegate* delegate) override; | 60 void SetDelegate(BlimpClientContextDelegate* delegate) override; |
| 61 std::unique_ptr<BlimpContents> CreateBlimpContents( | 61 std::unique_ptr<BlimpContents> CreateBlimpContents( |
| 62 gfx::NativeWindow window) override; | 62 gfx::NativeWindow window) override; |
| 63 void Connect() override; | 63 void Connect() override; |
| 64 void ConnectWithAssignment(const Assignment& assignment) override; | 64 void ConnectWithAssignment(const Assignment& assignment) override; |
| 65 | 65 |
| 66 // Creates a data object containing data about Blimp to be used for feedback. | 66 // Creates a data object containing data about Blimp to be used for feedback. |
| 67 std::unordered_map<std::string, std::string> CreateFeedbackData(); | 67 std::unordered_map<std::string, std::string> CreateFeedbackData(); |
| 68 | 68 |
| 69 protected: | 69 protected: |
| 70 // Returns the URL to use for connections to the assigner. Used to construct | |
| 71 // the AssignmentSource. | |
| 72 virtual GURL GetAssignerURL(); | |
| 73 | |
| 74 // BlimpSettingsDelegate implementation. | 70 // BlimpSettingsDelegate implementation. |
| 75 IdentitySource* GetIdentitySource() override; | 71 IdentitySource* GetIdentitySource() override; |
| 76 ConnectionStatus* GetConnectionStatus() override; | 72 ConnectionStatus* GetConnectionStatus() override; |
| 77 | 73 |
| 78 private: | 74 private: |
| 79 // Called when an OAuth2 token is received. Will then ask the | |
| 80 // AssignmentSource for an Assignment with this token. | |
| 81 virtual void OnAuthTokenReceived(const std::string& client_auth_token); | |
| 82 | |
| 83 // Called when the AssignmentSource is finished getting an Assignment. Will | 75 // Called when the AssignmentSource is finished getting an Assignment. Will |
| 84 // then call |ConnectWithAssignment| to initiate the actual connection. | 76 // then call |ConnectWithAssignment| to initiate the actual connection. |
| 85 virtual void OnAssignmentReceived(AssignmentRequestResult result, | 77 virtual void OnAssignmentReceived(AssignmentRequestResult result, |
| 86 const Assignment& assignment); | 78 const Assignment& assignment); |
| 87 | 79 |
| 88 void RegisterFeatures(); | 80 void RegisterFeatures(); |
| 89 void InitializeSettings(); | 81 void InitializeSettings(); |
| 90 | 82 |
| 91 // Terminates the active connection held by |net_connections_|. | 83 // Terminates the active connection held by |net_connections_|. |
| 92 // May be called on any thread. | 84 // May be called on any thread. |
| 93 void DropConnection(); | 85 void DropConnection(); |
| 94 | 86 |
| 95 // Create IdentitySource which provides user sign in states and OAuth2 token | |
| 96 // service. | |
| 97 void CreateIdentitySource(); | |
| 98 | |
| 99 // BlobImageSerializationProcessor::ErrorDelegate implementation. | 87 // BlobImageSerializationProcessor::ErrorDelegate implementation. |
| 100 void OnImageDecodeError() override; | 88 void OnImageDecodeError() override; |
| 101 | 89 |
| 102 // Provides functionality from the embedder. | 90 // Provides functionality from the embedder. |
| 103 BlimpClientContextDelegate* delegate_ = nullptr; | 91 BlimpClientContextDelegate* delegate_ = nullptr; |
| 104 | 92 |
| 105 // The task runner to use for IO operations. | 93 // The task runner to use for IO operations. |
| 106 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_; | 94 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_; |
| 107 | 95 |
| 108 // The task runner to use for file operations. | 96 // The task runner to use for file operations. |
| 109 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner_; | 97 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner_; |
| 110 | 98 |
| 111 // The AssignmentSource is used when the user of BlimpClientContextImpl calls | |
| 112 // Connect() to get a valid assignment and later connect to the engine. | |
| 113 std::unique_ptr<AssignmentSource> assignment_source_; | |
| 114 | |
| 115 // A set of dependencies required by all BlimpCompositor instances. | 99 // A set of dependencies required by all BlimpCompositor instances. |
| 116 std::unique_ptr<BlimpCompositorDependencies> blimp_compositor_dependencies_; | 100 std::unique_ptr<BlimpCompositorDependencies> blimp_compositor_dependencies_; |
| 117 | 101 |
| 118 // Features to handle all incoming and outgoing protobuf messages. | 102 // Features to handle all incoming and outgoing protobuf messages. |
| 119 std::unique_ptr<BlobChannelFeature> blob_channel_feature_; | 103 std::unique_ptr<BlobChannelFeature> blob_channel_feature_; |
| 120 std::unique_ptr<GeolocationFeature> geolocation_feature_; | 104 std::unique_ptr<GeolocationFeature> geolocation_feature_; |
| 121 std::unique_ptr<ImeFeature> ime_feature_; | 105 std::unique_ptr<ImeFeature> ime_feature_; |
| 122 std::unique_ptr<NavigationFeature> navigation_feature_; | 106 std::unique_ptr<NavigationFeature> navigation_feature_; |
| 123 std::unique_ptr<RenderWidgetFeature> render_widget_feature_; | 107 std::unique_ptr<RenderWidgetFeature> render_widget_feature_; |
| 124 std::unique_ptr<SettingsFeature> settings_feature_; | 108 std::unique_ptr<SettingsFeature> settings_feature_; |
| 125 std::unique_ptr<TabControlFeature> tab_control_feature_; | 109 std::unique_ptr<TabControlFeature> tab_control_feature_; |
| 126 | 110 |
| 127 std::unique_ptr<BlimpContentsManager> blimp_contents_manager_; | 111 std::unique_ptr<BlimpContentsManager> blimp_contents_manager_; |
| 128 | 112 |
| 129 // Container struct for network components. | 113 // Container struct for network components. |
| 130 // Must be deleted on the IO thread. | 114 // Must be deleted on the IO thread. |
| 131 std::unique_ptr<ClientNetworkComponents> net_components_; | 115 std::unique_ptr<ClientNetworkComponents> net_components_; |
| 132 | 116 |
| 133 std::unique_ptr<ThreadPipeManager> thread_pipe_manager_; | 117 std::unique_ptr<ThreadPipeManager> thread_pipe_manager_; |
| 134 | 118 |
| 135 // Provide OAuth2 token and propagate account sign in states change. | 119 std::unique_ptr<AssignmentFetcher> assignment_fetcher_; |
| 136 std::unique_ptr<IdentitySource> identity_source_; | |
| 137 | 120 |
| 138 // Connection status to the engine. | 121 // Connection status to the engine. |
| 139 ConnectionStatus connection_status_; | 122 ConnectionStatus connection_status_; |
| 140 | 123 |
| 141 base::WeakPtrFactory<BlimpClientContextImpl> weak_factory_; | 124 base::WeakPtrFactory<BlimpClientContextImpl> weak_factory_; |
| 142 | 125 |
| 143 DISALLOW_COPY_AND_ASSIGN(BlimpClientContextImpl); | 126 DISALLOW_COPY_AND_ASSIGN(BlimpClientContextImpl); |
| 144 }; | 127 }; |
| 145 | 128 |
| 146 } // namespace client | 129 } // namespace client |
| 147 } // namespace blimp | 130 } // namespace blimp |
| 148 | 131 |
| 149 #endif // BLIMP_CLIENT_CORE_CONTEXT_BLIMP_CLIENT_CONTEXT_IMPL_H_ | 132 #endif // BLIMP_CLIENT_CORE_CONTEXT_BLIMP_CLIENT_CONTEXT_IMPL_H_ |
| OLD | NEW |