Chromium Code Reviews| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/threading/sequenced_task_runner_handle.h" | 10 #include "base/threading/sequenced_task_runner_handle.h" |
| 11 #include "blimp/client/core/blimp_client_switches.h" | |
| 12 #include "blimp/client/core/compositor/blimp_compositor_dependencies.h" | |
| 11 #include "blimp/client/core/contents/blimp_contents_impl.h" | 13 #include "blimp/client/core/contents/blimp_contents_impl.h" |
| 12 #include "blimp/client/core/contents/blimp_contents_manager.h" | 14 #include "blimp/client/core/contents/blimp_contents_manager.h" |
| 13 #include "blimp/client/core/contents/ime_feature.h" | 15 #include "blimp/client/core/contents/ime_feature.h" |
| 14 #include "blimp/client/core/contents/navigation_feature.h" | 16 #include "blimp/client/core/contents/navigation_feature.h" |
| 15 #include "blimp/client/core/contents/tab_control_feature.h" | 17 #include "blimp/client/core/contents/tab_control_feature.h" |
| 18 #include "blimp/client/core/render_widget/render_widget_feature.h" | |
| 16 #include "blimp/client/core/session/cross_thread_network_event_observer.h" | 19 #include "blimp/client/core/session/cross_thread_network_event_observer.h" |
| 20 #include "blimp/client/core/settings/settings_feature.h" | |
| 17 #include "blimp/client/public/blimp_client_context_delegate.h" | 21 #include "blimp/client/public/blimp_client_context_delegate.h" |
| 22 #include "blimp/client/public/compositor/compositor_dependencies.h" | |
| 18 | 23 |
| 19 #if defined(OS_ANDROID) | 24 #if defined(OS_ANDROID) |
| 20 #include "blimp/client/core/android/blimp_client_context_impl_android.h" | 25 #include "blimp/client/core/android/blimp_client_context_impl_android.h" |
| 21 #endif // OS_ANDROID | 26 #endif // OS_ANDROID |
| 22 | 27 |
| 23 namespace blimp { | 28 namespace blimp { |
| 24 namespace client { | 29 namespace client { |
| 25 | 30 |
| 26 namespace { | 31 namespace { |
| 27 const char kDefaultAssignerUrl[] = | 32 const char kDefaultAssignerUrl[] = |
| 28 "https://blimp-pa.googleapis.com/v1/assignment"; | 33 "https://blimp-pa.googleapis.com/v1/assignment"; |
| 29 } // namespace | 34 } // namespace |
| 30 | 35 |
| 31 // This function is declared in //blimp/client/public/blimp_client_context.h, | 36 // This function is declared in //blimp/client/public/blimp_client_context.h, |
| 32 // and either this function or the one in | 37 // and either this function or the one in |
| 33 // //blimp/client/core/dummy_blimp_client_context.cc should be linked in to | 38 // //blimp/client/core/dummy_blimp_client_context.cc should be linked in to |
| 34 // any binary using BlimpClientContext::Create. | 39 // any binary using BlimpClientContext::Create. |
| 35 // static | 40 // static |
| 36 BlimpClientContext* BlimpClientContext::Create( | 41 BlimpClientContext* BlimpClientContext::Create( |
| 37 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, | 42 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, |
| 38 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner) { | 43 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, |
| 44 std::unique_ptr<CompositorDependencies> compositor_dependencies) { | |
| 39 #if defined(OS_ANDROID) | 45 #if defined(OS_ANDROID) |
| 40 return new BlimpClientContextImplAndroid(io_thread_task_runner, | 46 return new BlimpClientContextImplAndroid(io_thread_task_runner, |
| 41 file_thread_task_runner); | 47 file_thread_task_runner, |
| 48 std::move(compositor_dependencies)); | |
| 42 #else | 49 #else |
| 43 return new BlimpClientContextImpl(io_thread_task_runner, | 50 return new BlimpClientContextImpl(io_thread_task_runner, |
| 44 file_thread_task_runner); | 51 file_thread_task_runner, |
| 52 std::move(compositor_dependencies)); | |
| 45 #endif // defined(OS_ANDROID) | 53 #endif // defined(OS_ANDROID) |
| 46 } | 54 } |
| 47 | 55 |
| 48 BlimpClientContextImpl::BlimpClientContextImpl( | 56 BlimpClientContextImpl::BlimpClientContextImpl( |
| 49 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, | 57 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, |
| 50 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner) | 58 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, |
| 59 std::unique_ptr<CompositorDependencies> compositor_dependencies) | |
| 51 : BlimpClientContext(), | 60 : BlimpClientContext(), |
| 52 io_thread_task_runner_(io_thread_task_runner), | 61 io_thread_task_runner_(io_thread_task_runner), |
| 53 file_thread_task_runner_(file_thread_task_runner), | 62 file_thread_task_runner_(file_thread_task_runner), |
| 63 blimp_compositor_dependencies_( | |
|
Khushal
2016/08/31 04:30:47
nit: prefer MakeUnique.
David Trainor- moved to gerrit
2016/08/31 05:21:26
Done.
| |
| 64 new BlimpCompositorDependencies(std::move(compositor_dependencies))), | |
| 54 ime_feature_(new ImeFeature), | 65 ime_feature_(new ImeFeature), |
| 55 navigation_feature_(new NavigationFeature), | 66 navigation_feature_(new NavigationFeature), |
| 67 render_widget_feature_(new RenderWidgetFeature), | |
| 68 settings_feature_(new SettingsFeature), | |
| 56 tab_control_feature_(new TabControlFeature), | 69 tab_control_feature_(new TabControlFeature), |
| 57 blimp_contents_manager_( | 70 blimp_contents_manager_( |
| 58 new BlimpContentsManager(ime_feature_.get(), | 71 new BlimpContentsManager(blimp_compositor_dependencies_.get(), |
| 72 ime_feature_.get(), | |
| 59 navigation_feature_.get(), | 73 navigation_feature_.get(), |
| 74 render_widget_feature_.get(), | |
| 60 tab_control_feature_.get())), | 75 tab_control_feature_.get())), |
| 61 weak_factory_(this) { | 76 weak_factory_(this) { |
| 62 net_components_.reset(new ClientNetworkComponents( | 77 net_components_.reset(new ClientNetworkComponents( |
| 63 base::MakeUnique<CrossThreadNetworkEventObserver>( | 78 base::MakeUnique<CrossThreadNetworkEventObserver>( |
| 64 weak_factory_.GetWeakPtr(), base::SequencedTaskRunnerHandle::Get()))); | 79 weak_factory_.GetWeakPtr(), base::SequencedTaskRunnerHandle::Get()))); |
| 65 | 80 |
| 66 // The |thread_pipe_manager_| must be set up correctly before features are | 81 // The |thread_pipe_manager_| must be set up correctly before features are |
| 67 // registered. | 82 // registered. |
| 68 thread_pipe_manager_ = base::MakeUnique<ThreadPipeManager>( | 83 thread_pipe_manager_ = base::MakeUnique<ThreadPipeManager>( |
| 69 io_thread_task_runner_, net_components_->GetBrowserConnectionHandler()); | 84 io_thread_task_runner_, net_components_->GetBrowserConnectionHandler()); |
| 70 | 85 |
| 71 RegisterFeatures(); | 86 RegisterFeatures(); |
| 87 InitializeSettings(); | |
| 72 | 88 |
| 73 // Initialize must only be posted after the calls features have been | 89 // Initialize must only be posted after the calls features have been |
| 74 // registered. | 90 // registered. |
| 75 io_thread_task_runner_->PostTask( | 91 io_thread_task_runner_->PostTask( |
| 76 FROM_HERE, base::Bind(&ClientNetworkComponents::Initialize, | 92 FROM_HERE, base::Bind(&ClientNetworkComponents::Initialize, |
| 77 base::Unretained(net_components_.get()))); | 93 base::Unretained(net_components_.get()))); |
| 78 } | 94 } |
| 79 | 95 |
| 80 BlimpClientContextImpl::~BlimpClientContextImpl() { | 96 BlimpClientContextImpl::~BlimpClientContextImpl() { |
| 81 io_thread_task_runner_->DeleteSoon(FROM_HERE, net_components_.release()); | 97 io_thread_task_runner_->DeleteSoon(FROM_HERE, net_components_.release()); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 } | 168 } |
| 153 | 169 |
| 154 void BlimpClientContextImpl::RegisterFeatures() { | 170 void BlimpClientContextImpl::RegisterFeatures() { |
| 155 // Register features' message senders and receivers. | 171 // Register features' message senders and receivers. |
| 156 ime_feature_->set_outgoing_message_processor( | 172 ime_feature_->set_outgoing_message_processor( |
| 157 thread_pipe_manager_->RegisterFeature(BlimpMessage::kIme, | 173 thread_pipe_manager_->RegisterFeature(BlimpMessage::kIme, |
| 158 ime_feature_.get())); | 174 ime_feature_.get())); |
| 159 navigation_feature_->set_outgoing_message_processor( | 175 navigation_feature_->set_outgoing_message_processor( |
| 160 thread_pipe_manager_->RegisterFeature(BlimpMessage::kNavigation, | 176 thread_pipe_manager_->RegisterFeature(BlimpMessage::kNavigation, |
| 161 navigation_feature_.get())); | 177 navigation_feature_.get())); |
| 178 render_widget_feature_->set_outgoing_input_message_processor( | |
| 179 thread_pipe_manager_->RegisterFeature(BlimpMessage::kInput, | |
| 180 render_widget_feature_.get())); | |
| 181 render_widget_feature_->set_outgoing_compositor_message_processor( | |
| 182 thread_pipe_manager_->RegisterFeature(BlimpMessage::kCompositor, | |
| 183 render_widget_feature_.get())); | |
| 184 thread_pipe_manager_->RegisterFeature(BlimpMessage::kRenderWidget, | |
| 185 render_widget_feature_.get()); | |
| 186 settings_feature_->set_outgoing_message_processor( | |
| 187 thread_pipe_manager_->RegisterFeature(BlimpMessage::kSettings, | |
| 188 settings_feature_.get())); | |
| 162 tab_control_feature_->set_outgoing_message_processor( | 189 tab_control_feature_->set_outgoing_message_processor( |
| 163 thread_pipe_manager_->RegisterFeature(BlimpMessage::kTabControl, | 190 thread_pipe_manager_->RegisterFeature(BlimpMessage::kTabControl, |
| 164 tab_control_feature_.get())); | 191 tab_control_feature_.get())); |
| 165 } | 192 } |
| 166 | 193 |
| 194 void BlimpClientContextImpl::InitializeSettings() { | |
| 195 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 196 switches::kDownloadWholeDocument)) | |
| 197 settings_feature_->SetRecordWholeDocument(true); | |
| 198 } | |
| 199 | |
| 167 void BlimpClientContextImpl::CreateIdentitySource() { | 200 void BlimpClientContextImpl::CreateIdentitySource() { |
| 168 identity_source_ = base::MakeUnique<IdentitySource>( | 201 identity_source_ = base::MakeUnique<IdentitySource>( |
| 169 delegate_, base::Bind(&BlimpClientContextImpl::ConnectToAssignmentSource, | 202 delegate_, base::Bind(&BlimpClientContextImpl::ConnectToAssignmentSource, |
| 170 base::Unretained(this))); | 203 base::Unretained(this))); |
| 171 } | 204 } |
| 172 | 205 |
| 173 } // namespace client | 206 } // namespace client |
| 174 } // namespace blimp | 207 } // namespace blimp |
| OLD | NEW |