| 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/lazy_instance.h" |
| 8 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 9 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 10 #include "base/threading/sequenced_task_runner_handle.h" | 11 #include "base/threading/sequenced_task_runner_handle.h" |
| 11 #include "blimp/client/core/contents/blimp_contents_impl.h" | 12 #include "blimp/client/core/contents/blimp_contents_impl.h" |
| 12 #include "blimp/client/core/contents/blimp_contents_manager.h" | 13 #include "blimp/client/core/contents/blimp_contents_manager.h" |
| 13 #include "blimp/client/core/session/cross_thread_network_event_observer.h" | 14 #include "blimp/client/core/session/cross_thread_network_event_observer.h" |
| 14 #include "blimp/client/public/blimp_client_context_delegate.h" | 15 #include "blimp/client/public/blimp_client_context_delegate.h" |
| 15 | 16 |
| 16 #if defined(OS_ANDROID) | 17 #if defined(OS_ANDROID) |
| 17 #include "blimp/client/core/android/blimp_client_context_impl_android.h" | 18 #include "blimp/client/core/android/blimp_client_context_impl_android.h" |
| 18 #endif // OS_ANDROID | 19 #endif // OS_ANDROID |
| 19 | 20 |
| 20 namespace blimp { | 21 namespace blimp { |
| 21 namespace client { | 22 namespace client { |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 const char kDefaultAssignerUrl[] = | 25 const char kDefaultAssignerUrl[] = |
| 25 "https://blimp-pa.googleapis.com/v1/assignment"; | 26 "https://blimp-pa.googleapis.com/v1/assignment"; |
| 27 |
| 28 // This should go elsewhere when we start setting up the feature code. |
| 29 base::LazyInstance<RenderWidgetFeature> g_render_widget_feature; |
| 26 } // namespace | 30 } // namespace |
| 27 | 31 |
| 28 // This function is declared in //blimp/client/public/blimp_client_context.h, | 32 // This function is declared in //blimp/client/public/blimp_client_context.h, |
| 29 // and either this function or the one in | 33 // and either this function or the one in |
| 30 // //blimp/client/core/dummy_blimp_client_context.cc should be linked in to | 34 // //blimp/client/core/dummy_blimp_client_context.cc should be linked in to |
| 31 // any binary using BlimpClientContext::Create. | 35 // any binary using BlimpClientContext::Create. |
| 32 // static | 36 // static |
| 33 BlimpClientContext* BlimpClientContext::Create( | 37 BlimpClientContext* BlimpClientContext::Create( |
| 34 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, | 38 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, |
| 35 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner) { | 39 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner) { |
| 36 #if defined(OS_ANDROID) | 40 #if defined(OS_ANDROID) |
| 37 return new BlimpClientContextImplAndroid(io_thread_task_runner, | 41 return new BlimpClientContextImplAndroid(io_thread_task_runner, |
| 38 file_thread_task_runner); | 42 file_thread_task_runner); |
| 39 #else | 43 #else |
| 40 return new BlimpClientContextImpl(io_thread_task_runner, | 44 return new BlimpClientContextImpl(io_thread_task_runner, |
| 41 file_thread_task_runner); | 45 file_thread_task_runner); |
| 42 #endif // defined(OS_ANDROID) | 46 #endif // defined(OS_ANDROID) |
| 43 } | 47 } |
| 44 | 48 |
| 45 BlimpClientContextImpl::BlimpClientContextImpl( | 49 BlimpClientContextImpl::BlimpClientContextImpl( |
| 46 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, | 50 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, |
| 47 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner) | 51 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner) |
| 48 : BlimpClientContext(), | 52 : BlimpClientContext(), |
| 49 io_thread_task_runner_(io_thread_task_runner), | 53 io_thread_task_runner_(io_thread_task_runner), |
| 50 file_thread_task_runner_(file_thread_task_runner), | 54 file_thread_task_runner_(file_thread_task_runner), |
| 51 blimp_contents_manager_(new BlimpContentsManager), | 55 blimp_contents_manager_( |
| 56 new BlimpContentsManager(true, g_render_widget_feature.Pointer())), |
| 52 weak_factory_(this) { | 57 weak_factory_(this) { |
| 53 blimp_connection_statistics_ = new BlimpConnectionStatistics(); | 58 blimp_connection_statistics_ = new BlimpConnectionStatistics(); |
| 54 net_components_.reset(new ClientNetworkComponents( | 59 net_components_.reset(new ClientNetworkComponents( |
| 55 base::MakeUnique<CrossThreadNetworkEventObserver>( | 60 base::MakeUnique<CrossThreadNetworkEventObserver>( |
| 56 weak_factory_.GetWeakPtr(), base::SequencedTaskRunnerHandle::Get()), | 61 weak_factory_.GetWeakPtr(), base::SequencedTaskRunnerHandle::Get()), |
| 57 base::WrapUnique(blimp_connection_statistics_))); | 62 base::WrapUnique(blimp_connection_statistics_))); |
| 58 | 63 |
| 59 // The |thread_pipe_manager_| must be set up correctly before features are | 64 // The |thread_pipe_manager_| must be set up correctly before features are |
| 60 // registered. | 65 // registered. |
| 61 thread_pipe_manager_ = base::MakeUnique<ThreadPipeManager>( | 66 thread_pipe_manager_ = base::MakeUnique<ThreadPipeManager>( |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 } | 124 } |
| 120 | 125 |
| 121 io_thread_task_runner_->PostTask( | 126 io_thread_task_runner_->PostTask( |
| 122 FROM_HERE, | 127 FROM_HERE, |
| 123 base::Bind(&ClientNetworkComponents::ConnectWithAssignment, | 128 base::Bind(&ClientNetworkComponents::ConnectWithAssignment, |
| 124 base::Unretained(net_components_.get()), assignment)); | 129 base::Unretained(net_components_.get()), assignment)); |
| 125 } | 130 } |
| 126 | 131 |
| 127 } // namespace client | 132 } // namespace client |
| 128 } // namespace blimp | 133 } // namespace blimp |
| OLD | NEW |