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_feature_(base::MakeUnique<GeolocationFeature>( |
| 74 base::MakeUnique<device::LocationArbitrator>( |
| 75 base::MakeUnique<device::GeolocationDelegate>()))), |
68 ime_feature_(new ImeFeature), | 76 ime_feature_(new ImeFeature), |
69 navigation_feature_(new NavigationFeature), | 77 navigation_feature_(new NavigationFeature), |
70 render_widget_feature_(new RenderWidgetFeature), | 78 render_widget_feature_(new RenderWidgetFeature), |
71 settings_feature_(new SettingsFeature), | 79 settings_feature_(new SettingsFeature), |
72 tab_control_feature_(new TabControlFeature), | 80 tab_control_feature_(new TabControlFeature), |
73 blimp_contents_manager_( | 81 blimp_contents_manager_( |
74 new BlimpContentsManager(blimp_compositor_dependencies_.get(), | 82 new BlimpContentsManager(blimp_compositor_dependencies_.get(), |
75 ime_feature_.get(), | 83 ime_feature_.get(), |
76 navigation_feature_.get(), | 84 navigation_feature_.get(), |
77 render_widget_feature_.get(), | 85 render_widget_feature_.get(), |
78 tab_control_feature_.get())), | 86 tab_control_feature_.get())), |
79 weak_factory_(this) { | 87 weak_factory_(this) { |
80 net_components_.reset(new ClientNetworkComponents( | 88 net_components_.reset(new ClientNetworkComponents( |
81 base::MakeUnique<CrossThreadNetworkEventObserver>( | 89 base::MakeUnique<CrossThreadNetworkEventObserver>( |
82 weak_factory_.GetWeakPtr(), base::SequencedTaskRunnerHandle::Get()))); | 90 weak_factory_.GetWeakPtr(), base::SequencedTaskRunnerHandle::Get()))); |
83 | 91 |
84 // The |thread_pipe_manager_| must be set up correctly before features are | 92 // The |thread_pipe_manager_| must be set up correctly before features are |
85 // registered. | 93 // registered. |
86 thread_pipe_manager_ = base::MakeUnique<ThreadPipeManager>( | 94 thread_pipe_manager_ = base::MakeUnique<ThreadPipeManager>( |
87 io_thread_task_runner_, net_components_->GetBrowserConnectionHandler()); | 95 io_thread_task_runner_, net_components_->GetBrowserConnectionHandler()); |
88 | 96 |
89 RegisterFeatures(); | 97 RegisterFeatures(); |
90 InitializeSettings(); | 98 InitializeSettings(); |
91 | 99 |
92 // Initialize must only be posted after the calls features have been | 100 // Initialize must only be posted after the features have been |
93 // registered. | 101 // registered. |
94 io_thread_task_runner_->PostTask( | 102 io_thread_task_runner_->PostTask( |
95 FROM_HERE, base::Bind(&ClientNetworkComponents::Initialize, | 103 FROM_HERE, base::Bind(&ClientNetworkComponents::Initialize, |
96 base::Unretained(net_components_.get()))); | 104 base::Unretained(net_components_.get()))); |
97 } | 105 } |
98 | 106 |
99 BlimpClientContextImpl::~BlimpClientContextImpl() { | 107 BlimpClientContextImpl::~BlimpClientContextImpl() { |
100 io_thread_task_runner_->DeleteSoon(FROM_HERE, net_components_.release()); | 108 io_thread_task_runner_->DeleteSoon(FROM_HERE, net_components_.release()); |
101 } | 109 } |
102 | 110 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 } | 171 } |
164 | 172 |
165 io_thread_task_runner_->PostTask( | 173 io_thread_task_runner_->PostTask( |
166 FROM_HERE, | 174 FROM_HERE, |
167 base::Bind(&ClientNetworkComponents::ConnectWithAssignment, | 175 base::Bind(&ClientNetworkComponents::ConnectWithAssignment, |
168 base::Unretained(net_components_.get()), assignment)); | 176 base::Unretained(net_components_.get()), assignment)); |
169 } | 177 } |
170 | 178 |
171 void BlimpClientContextImpl::RegisterFeatures() { | 179 void BlimpClientContextImpl::RegisterFeatures() { |
172 // Register features' message senders and receivers. | 180 // Register features' message senders and receivers. |
| 181 geolocation_feature_->set_outgoing_message_processor( |
| 182 thread_pipe_manager_->RegisterFeature(BlimpMessage::kGeolocation, |
| 183 geolocation_feature_.get())); |
173 ime_feature_->set_outgoing_message_processor( | 184 ime_feature_->set_outgoing_message_processor( |
174 thread_pipe_manager_->RegisterFeature(BlimpMessage::kIme, | 185 thread_pipe_manager_->RegisterFeature(BlimpMessage::kIme, |
175 ime_feature_.get())); | 186 ime_feature_.get())); |
176 navigation_feature_->set_outgoing_message_processor( | 187 navigation_feature_->set_outgoing_message_processor( |
177 thread_pipe_manager_->RegisterFeature(BlimpMessage::kNavigation, | 188 thread_pipe_manager_->RegisterFeature(BlimpMessage::kNavigation, |
178 navigation_feature_.get())); | 189 navigation_feature_.get())); |
179 render_widget_feature_->set_outgoing_input_message_processor( | 190 render_widget_feature_->set_outgoing_input_message_processor( |
180 thread_pipe_manager_->RegisterFeature(BlimpMessage::kInput, | 191 thread_pipe_manager_->RegisterFeature(BlimpMessage::kInput, |
181 render_widget_feature_.get())); | 192 render_widget_feature_.get())); |
182 render_widget_feature_->set_outgoing_compositor_message_processor( | 193 render_widget_feature_->set_outgoing_compositor_message_processor( |
(...skipping 16 matching lines...) Expand all Loading... |
199 } | 210 } |
200 | 211 |
201 void BlimpClientContextImpl::CreateIdentitySource() { | 212 void BlimpClientContextImpl::CreateIdentitySource() { |
202 identity_source_ = base::MakeUnique<IdentitySource>( | 213 identity_source_ = base::MakeUnique<IdentitySource>( |
203 delegate_, base::Bind(&BlimpClientContextImpl::ConnectToAssignmentSource, | 214 delegate_, base::Bind(&BlimpClientContextImpl::ConnectToAssignmentSource, |
204 base::Unretained(this))); | 215 base::Unretained(this))); |
205 } | 216 } |
206 | 217 |
207 } // namespace client | 218 } // namespace client |
208 } // namespace blimp | 219 } // namespace blimp |
OLD | NEW |