| 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 #include "blimp/client/core/blimp_client_context_impl.h" | 5 #include "blimp/client/core/blimp_client_context_impl.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 9 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 10 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 11 #include "base/threading/sequenced_task_runner_handle.h" | 13 #include "base/threading/sequenced_task_runner_handle.h" |
| 12 #include "blimp/client/core/blimp_client_switches.h" | 14 #include "blimp/client/core/blimp_client_switches.h" |
| 13 #include "blimp/client/core/compositor/blimp_compositor_dependencies.h" | 15 #include "blimp/client/core/compositor/blimp_compositor_dependencies.h" |
| 14 #include "blimp/client/core/contents/blimp_contents_impl.h" | 16 #include "blimp/client/core/contents/blimp_contents_impl.h" |
| 15 #include "blimp/client/core/contents/blimp_contents_manager.h" | 17 #include "blimp/client/core/contents/blimp_contents_manager.h" |
| 16 #include "blimp/client/core/contents/ime_feature.h" | 18 #include "blimp/client/core/contents/ime_feature.h" |
| 17 #include "blimp/client/core/contents/navigation_feature.h" | 19 #include "blimp/client/core/contents/navigation_feature.h" |
| 18 #include "blimp/client/core/contents/tab_control_feature.h" | 20 #include "blimp/client/core/contents/tab_control_feature.h" |
| 21 #include "blimp/client/core/geolocation/geolocation_feature.h" |
| 19 #include "blimp/client/core/render_widget/render_widget_feature.h" | 22 #include "blimp/client/core/render_widget/render_widget_feature.h" |
| 20 #include "blimp/client/core/session/cross_thread_network_event_observer.h" | 23 #include "blimp/client/core/session/cross_thread_network_event_observer.h" |
| 21 #include "blimp/client/core/settings/settings_feature.h" | 24 #include "blimp/client/core/settings/settings_feature.h" |
| 22 #include "blimp/client/public/blimp_client_context_delegate.h" | 25 #include "blimp/client/public/blimp_client_context_delegate.h" |
| 23 #include "blimp/client/public/compositor/compositor_dependencies.h" | 26 #include "blimp/client/public/compositor/compositor_dependencies.h" |
| 27 #include "device/geolocation/geolocation_delegate.h" |
| 28 #include "device/geolocation/location_arbitrator.h" |
| 24 #include "ui/gfx/native_widget_types.h" | 29 #include "ui/gfx/native_widget_types.h" |
| 25 | 30 |
| 26 #if defined(OS_ANDROID) | 31 #if defined(OS_ANDROID) |
| 27 #include "blimp/client/core/android/blimp_client_context_impl_android.h" | 32 #include "blimp/client/core/android/blimp_client_context_impl_android.h" |
| 28 #endif // OS_ANDROID | 33 #endif // OS_ANDROID |
| 29 | 34 |
| 30 namespace blimp { | 35 namespace blimp { |
| 31 namespace client { | 36 namespace client { |
| 32 | 37 |
| 33 namespace { | 38 namespace { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 58 BlimpClientContextImpl::BlimpClientContextImpl( | 63 BlimpClientContextImpl::BlimpClientContextImpl( |
| 59 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, | 64 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, |
| 60 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, | 65 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, |
| 61 std::unique_ptr<CompositorDependencies> compositor_dependencies) | 66 std::unique_ptr<CompositorDependencies> compositor_dependencies) |
| 62 : BlimpClientContext(), | 67 : BlimpClientContext(), |
| 63 io_thread_task_runner_(io_thread_task_runner), | 68 io_thread_task_runner_(io_thread_task_runner), |
| 64 file_thread_task_runner_(file_thread_task_runner), | 69 file_thread_task_runner_(file_thread_task_runner), |
| 65 blimp_compositor_dependencies_( | 70 blimp_compositor_dependencies_( |
| 66 base::MakeUnique<BlimpCompositorDependencies>( | 71 base::MakeUnique<BlimpCompositorDependencies>( |
| 67 std::move(compositor_dependencies))), | 72 std::move(compositor_dependencies))), |
| 73 geolocation_delegate_(base::MakeUnique<device::GeolocationDelegate>()), |
| 74 geolocation_feature_(base::MakeUnique<GeolocationFeature>( |
| 75 base::MakeUnique<device::LocationArbitrator>( |
| 76 geolocation_delegate_.get()))), |
| 68 ime_feature_(new ImeFeature), | 77 ime_feature_(new ImeFeature), |
| 69 navigation_feature_(new NavigationFeature), | 78 navigation_feature_(new NavigationFeature), |
| 70 render_widget_feature_(new RenderWidgetFeature), | 79 render_widget_feature_(new RenderWidgetFeature), |
| 71 settings_feature_(new SettingsFeature), | 80 settings_feature_(new SettingsFeature), |
| 72 tab_control_feature_(new TabControlFeature), | 81 tab_control_feature_(new TabControlFeature), |
| 73 blimp_contents_manager_( | 82 blimp_contents_manager_( |
| 74 new BlimpContentsManager(blimp_compositor_dependencies_.get(), | 83 new BlimpContentsManager(blimp_compositor_dependencies_.get(), |
| 75 ime_feature_.get(), | 84 ime_feature_.get(), |
| 76 navigation_feature_.get(), | 85 navigation_feature_.get(), |
| 77 render_widget_feature_.get(), | 86 render_widget_feature_.get(), |
| 78 tab_control_feature_.get())), | 87 tab_control_feature_.get())), |
| 79 weak_factory_(this) { | 88 weak_factory_(this) { |
| 80 net_components_.reset(new ClientNetworkComponents( | 89 net_components_.reset(new ClientNetworkComponents( |
| 81 base::MakeUnique<CrossThreadNetworkEventObserver>( | 90 base::MakeUnique<CrossThreadNetworkEventObserver>( |
| 82 weak_factory_.GetWeakPtr(), base::SequencedTaskRunnerHandle::Get()))); | 91 weak_factory_.GetWeakPtr(), base::SequencedTaskRunnerHandle::Get()))); |
| 83 | 92 |
| 84 // The |thread_pipe_manager_| must be set up correctly before features are | 93 // The |thread_pipe_manager_| must be set up correctly before features are |
| 85 // registered. | 94 // registered. |
| 86 thread_pipe_manager_ = base::MakeUnique<ThreadPipeManager>( | 95 thread_pipe_manager_ = base::MakeUnique<ThreadPipeManager>( |
| 87 io_thread_task_runner_, net_components_->GetBrowserConnectionHandler()); | 96 io_thread_task_runner_, net_components_->GetBrowserConnectionHandler()); |
| 88 | 97 |
| 89 RegisterFeatures(); | 98 RegisterFeatures(); |
| 90 InitializeSettings(); | 99 InitializeSettings(); |
| 91 | 100 |
| 92 // Initialize must only be posted after the calls features have been | 101 // Initialize must only be posted after the features have been |
| 93 // registered. | 102 // registered. |
| 94 io_thread_task_runner_->PostTask( | 103 io_thread_task_runner_->PostTask( |
| 95 FROM_HERE, base::Bind(&ClientNetworkComponents::Initialize, | 104 FROM_HERE, base::Bind(&ClientNetworkComponents::Initialize, |
| 96 base::Unretained(net_components_.get()))); | 105 base::Unretained(net_components_.get()))); |
| 97 } | 106 } |
| 98 | 107 |
| 99 BlimpClientContextImpl::~BlimpClientContextImpl() { | 108 BlimpClientContextImpl::~BlimpClientContextImpl() { |
| 100 io_thread_task_runner_->DeleteSoon(FROM_HERE, net_components_.release()); | 109 io_thread_task_runner_->DeleteSoon(FROM_HERE, net_components_.release()); |
| 101 } | 110 } |
| 102 | 111 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 } | 176 } |
| 168 | 177 |
| 169 io_thread_task_runner_->PostTask( | 178 io_thread_task_runner_->PostTask( |
| 170 FROM_HERE, | 179 FROM_HERE, |
| 171 base::Bind(&ClientNetworkComponents::ConnectWithAssignment, | 180 base::Bind(&ClientNetworkComponents::ConnectWithAssignment, |
| 172 base::Unretained(net_components_.get()), assignment)); | 181 base::Unretained(net_components_.get()), assignment)); |
| 173 } | 182 } |
| 174 | 183 |
| 175 void BlimpClientContextImpl::RegisterFeatures() { | 184 void BlimpClientContextImpl::RegisterFeatures() { |
| 176 // Register features' message senders and receivers. | 185 // Register features' message senders and receivers. |
| 186 geolocation_feature_->set_outgoing_message_processor( |
| 187 thread_pipe_manager_->RegisterFeature(BlimpMessage::kGeolocation, |
| 188 geolocation_feature_.get())); |
| 177 ime_feature_->set_outgoing_message_processor( | 189 ime_feature_->set_outgoing_message_processor( |
| 178 thread_pipe_manager_->RegisterFeature(BlimpMessage::kIme, | 190 thread_pipe_manager_->RegisterFeature(BlimpMessage::kIme, |
| 179 ime_feature_.get())); | 191 ime_feature_.get())); |
| 180 navigation_feature_->set_outgoing_message_processor( | 192 navigation_feature_->set_outgoing_message_processor( |
| 181 thread_pipe_manager_->RegisterFeature(BlimpMessage::kNavigation, | 193 thread_pipe_manager_->RegisterFeature(BlimpMessage::kNavigation, |
| 182 navigation_feature_.get())); | 194 navigation_feature_.get())); |
| 183 render_widget_feature_->set_outgoing_input_message_processor( | 195 render_widget_feature_->set_outgoing_input_message_processor( |
| 184 thread_pipe_manager_->RegisterFeature(BlimpMessage::kInput, | 196 thread_pipe_manager_->RegisterFeature(BlimpMessage::kInput, |
| 185 render_widget_feature_.get())); | 197 render_widget_feature_.get())); |
| 186 render_widget_feature_->set_outgoing_compositor_message_processor( | 198 render_widget_feature_->set_outgoing_compositor_message_processor( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 203 } | 215 } |
| 204 | 216 |
| 205 void BlimpClientContextImpl::CreateIdentitySource() { | 217 void BlimpClientContextImpl::CreateIdentitySource() { |
| 206 identity_source_ = base::MakeUnique<IdentitySource>( | 218 identity_source_ = base::MakeUnique<IdentitySource>( |
| 207 delegate_, base::Bind(&BlimpClientContextImpl::ConnectToAssignmentSource, | 219 delegate_, base::Bind(&BlimpClientContextImpl::ConnectToAssignmentSource, |
| 208 base::Unretained(this))); | 220 base::Unretained(this))); |
| 209 } | 221 } |
| 210 | 222 |
| 211 } // namespace client | 223 } // namespace client |
| 212 } // namespace blimp | 224 } // namespace blimp |
| OLD | NEW |