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/contents/blimp_contents_impl.h" | 11 #include "blimp/client/core/contents/blimp_contents_impl.h" |
| 12 #include "blimp/client/core/contents/blimp_contents_manager.h" | |
| 12 #include "blimp/client/core/session/cross_thread_network_event_observer.h" | 13 #include "blimp/client/core/session/cross_thread_network_event_observer.h" |
| 13 #include "blimp/client/public/blimp_client_context_delegate.h" | 14 #include "blimp/client/public/blimp_client_context_delegate.h" |
| 14 | 15 |
| 15 #if defined(OS_ANDROID) | 16 #if defined(OS_ANDROID) |
| 16 #include "blimp/client/core/android/blimp_client_context_impl_android.h" | 17 #include "blimp/client/core/android/blimp_client_context_impl_android.h" |
| 17 #endif // OS_ANDROID | 18 #endif // OS_ANDROID |
| 18 | 19 |
| 19 namespace blimp { | 20 namespace blimp { |
| 20 namespace client { | 21 namespace client { |
| 21 | 22 |
| 22 // This function is declared in //blimp/client/public/blimp_client_context.h, | 23 // This function is declared in //blimp/client/public/blimp_client_context.h, |
| 23 // and either this function or the one in | 24 // and either this function or the one in |
| 24 // //blimp/client/core/dummy_blimp_client_context.cc should be linked in to | 25 // //blimp/client/core/dummy_blimp_client_context.cc should be linked in to |
| 25 // any binary using BlimpClientContext::Create. | 26 // any binary using BlimpClientContext::Create. |
| 26 // static | 27 // static |
| 27 BlimpClientContext* BlimpClientContext::Create( | 28 BlimpClientContext* BlimpClientContext::Create( |
| 28 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner) { | 29 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner) { |
| 29 #if defined(OS_ANDROID) | 30 #if defined(OS_ANDROID) |
| 30 return new BlimpClientContextImplAndroid(io_thread_task_runner); | 31 return new BlimpClientContextImplAndroid(io_thread_task_runner); |
| 31 #else | 32 #else |
| 32 return new BlimpClientContextImpl(io_thread_task_runner); | 33 return new BlimpClientContextImpl(io_thread_task_runner); |
| 33 #endif // defined(OS_ANDROID) | 34 #endif // defined(OS_ANDROID) |
| 34 } | 35 } |
| 35 | 36 |
| 36 BlimpClientContextImpl::BlimpClientContextImpl( | 37 BlimpClientContextImpl::BlimpClientContextImpl( |
| 37 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner) | 38 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner) |
| 38 : BlimpClientContext(), | 39 : BlimpClientContext(), |
| 39 io_thread_task_runner_(io_thread_task_runner), | 40 io_thread_task_runner_(io_thread_task_runner), |
| 41 blimp_contents_manager_(new BlimpContentsManager), | |
| 40 weak_factory_(this) { | 42 weak_factory_(this) { |
| 41 blimp_connection_statistics_ = new BlimpConnectionStatistics(); | 43 blimp_connection_statistics_ = new BlimpConnectionStatistics(); |
| 42 net_components_.reset(new ClientNetworkComponents( | 44 net_components_.reset(new ClientNetworkComponents( |
| 43 base::MakeUnique<CrossThreadNetworkEventObserver>( | 45 base::MakeUnique<CrossThreadNetworkEventObserver>( |
| 44 weak_factory_.GetWeakPtr(), base::SequencedTaskRunnerHandle::Get()), | 46 weak_factory_.GetWeakPtr(), base::SequencedTaskRunnerHandle::Get()), |
| 45 base::WrapUnique(blimp_connection_statistics_))); | 47 base::WrapUnique(blimp_connection_statistics_))); |
| 46 | 48 |
| 47 // The |thread_pipe_manager_| must be set up correctly before features are | 49 // The |thread_pipe_manager_| must be set up correctly before features are |
| 48 // registered. | 50 // registered. |
| 49 thread_pipe_manager_ = base::MakeUnique<ThreadPipeManager>( | 51 thread_pipe_manager_ = base::MakeUnique<ThreadPipeManager>( |
| 50 io_thread_task_runner_, net_components_->GetBrowserConnectionHandler()); | 52 io_thread_task_runner_, net_components_->GetBrowserConnectionHandler()); |
| 51 | 53 |
| 52 // Initialize must only be posted after the calls features have been | 54 // Initialize must only be posted after the calls features have been |
| 53 // registered. | 55 // registered. |
| 54 io_thread_task_runner_->PostTask( | 56 io_thread_task_runner_->PostTask( |
| 55 FROM_HERE, base::Bind(&ClientNetworkComponents::Initialize, | 57 FROM_HERE, base::Bind(&ClientNetworkComponents::Initialize, |
| 56 base::Unretained(net_components_.get()))); | 58 base::Unretained(net_components_.get()))); |
| 57 } | 59 } |
| 58 | 60 |
| 59 BlimpClientContextImpl::~BlimpClientContextImpl() { | 61 BlimpClientContextImpl::~BlimpClientContextImpl() { |
| 60 io_thread_task_runner_->DeleteSoon(FROM_HERE, net_components_.release()); | 62 io_thread_task_runner_->DeleteSoon(FROM_HERE, net_components_.release()); |
| 61 } | 63 } |
| 62 | 64 |
| 63 void BlimpClientContextImpl::SetDelegate(BlimpClientContextDelegate* delegate) { | 65 void BlimpClientContextImpl::SetDelegate(BlimpClientContextDelegate* delegate) { |
| 64 delegate_ = delegate; | 66 delegate_ = delegate; |
| 65 } | 67 } |
| 66 | 68 |
| 67 std::unique_ptr<BlimpContents> BlimpClientContextImpl::CreateBlimpContents() { | 69 std::unique_ptr<BlimpContents> BlimpClientContextImpl::CreateBlimpContents() { |
| 68 std::unique_ptr<BlimpContents> blimp_contents = | 70 std::unique_ptr<BlimpContents> blimp_contents = |
| 69 base::MakeUnique<BlimpContentsImpl>(); | 71 blimp_contents_manager_->CreateBlimpContents(); |
| 70 delegate_->AttachBlimpContentsHelpers(blimp_contents.get()); | 72 delegate_->AttachBlimpContentsHelpers(blimp_contents.get()); |
|
nyquist
2016/08/05 23:03:22
This call to the delegate is part of the public AP
Menglin
2016/08/05 23:37:15
Maybe define BlimpContentsManager::CreateBlimpCont
David Trainor- moved to gerrit
2016/08/06 04:25:39
Saw you two talked about it and decided this was o
| |
| 71 return blimp_contents; | 73 return blimp_contents; |
| 72 } | 74 } |
| 73 | 75 |
| 74 void BlimpClientContextImpl::OnConnected() {} | 76 void BlimpClientContextImpl::OnConnected() {} |
| 75 | 77 |
| 76 void BlimpClientContextImpl::OnDisconnected(int result) {} | 78 void BlimpClientContextImpl::OnDisconnected(int result) {} |
| 77 | 79 |
| 78 } // namespace client | 80 } // namespace client |
| 79 } // namespace blimp | 81 } // namespace blimp |
| OLD | NEW |