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/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/message_loop/message_loop.h" | |
| 8 #include "base/supports_user_data.h" | 10 #include "base/supports_user_data.h" |
| 11 #include "base/threading/sequenced_task_runner_handle.h" | |
| 9 #include "blimp/client/core/contents/blimp_contents_impl.h" | 12 #include "blimp/client/core/contents/blimp_contents_impl.h" |
| 13 #include "blimp/client/core/session/cross_thread_network_event_observer.h" | |
| 10 #include "blimp/client/public/blimp_client_context_delegate.h" | 14 #include "blimp/client/public/blimp_client_context_delegate.h" |
| 11 | 15 |
| 12 #if defined(OS_ANDROID) | 16 #if defined(OS_ANDROID) |
| 13 #include "blimp/client/core/android/blimp_client_context_impl_android.h" | 17 #include "blimp/client/core/android/blimp_client_context_impl_android.h" |
| 14 #endif // OS_ANDROID | 18 #endif // OS_ANDROID |
| 15 | 19 |
| 16 namespace blimp { | 20 namespace blimp { |
| 17 namespace client { | 21 namespace client { |
| 18 | 22 |
| 19 namespace { | 23 namespace { |
| 20 | 24 |
| 21 #if defined(OS_ANDROID) | 25 #if defined(OS_ANDROID) |
| 22 const char kBlimpClientContextImplAndroidKey[] = | 26 const char kBlimpClientContextImplAndroidKey[] = |
| 23 "blimp_client_context_impl_android"; | 27 "blimp_client_context_impl_android"; |
| 24 #endif // OS_ANDROID | 28 #endif // OS_ANDROID |
| 25 } | 29 } |
| 26 | 30 |
| 27 // This function is declared in //blimp/client/public/blimp_client_context.h, | 31 // This function is declared in //blimp/client/public/blimp_client_context.h, |
| 28 // and either this function or the one in | 32 // and either this function or the one in |
| 29 // //blimp/client/core/dummy_blimp_client_context.cc should be linked in to | 33 // //blimp/client/core/dummy_blimp_client_context.cc should be linked in to |
| 30 // any binary using BlimpClientContext::Create. | 34 // any binary using BlimpClientContext::Create. |
| 31 // static | 35 // static |
| 32 BlimpClientContext* BlimpClientContext::Create() { | 36 BlimpClientContext* BlimpClientContext::Create( |
| 33 return new BlimpClientContextImpl(); | 37 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner) { |
| 38 return new BlimpClientContextImpl(io_thread_task_runner); | |
| 34 } | 39 } |
| 35 | 40 |
| 36 BlimpClientContextImpl::BlimpClientContextImpl() : BlimpClientContext() {} | 41 BlimpClientContextImpl::BlimpClientContextImpl( |
| 42 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner) | |
| 43 : BlimpClientContext(), | |
| 44 io_thread_task_runner_(io_thread_task_runner), | |
| 45 weak_factory_(this) { | |
| 46 blimp_connection_statistics_ = new BlimpConnectionStatistics(); | |
| 47 net_components_.reset(new ClientNetworkComponents( | |
| 48 base::WrapUnique(new CrossThreadNetworkEventObserver( | |
| 49 weak_factory_.GetWeakPtr(), base::SequencedTaskRunnerHandle::Get())), | |
| 50 base::WrapUnique(blimp_connection_statistics_))); | |
| 37 | 51 |
| 38 BlimpClientContextImpl::~BlimpClientContextImpl() {} | 52 RegisterFeatures(); |
|
Kevin M
2016/07/29 19:23:17
* This seems like a misnomer, since this is really
nyquist
2016/07/29 22:26:57
True. How about this; I'll move the threadpipemana
| |
| 53 | |
| 54 // Initialize must only be posted after the RegisterFeature calls have | |
| 55 // completed. | |
| 56 io_thread_task_runner_->PostTask( | |
| 57 FROM_HERE, base::Bind(&ClientNetworkComponents::Initialize, | |
| 58 base::Unretained(net_components_.get()))); | |
| 59 } | |
| 60 | |
| 61 BlimpClientContextImpl::~BlimpClientContextImpl() { | |
| 62 io_thread_task_runner_->DeleteSoon(FROM_HERE, net_components_.release()); | |
| 63 } | |
| 64 | |
| 65 void BlimpClientContextImpl::RegisterFeatures() { | |
| 66 thread_pipe_manager_ = base::WrapUnique(new ThreadPipeManager( | |
| 67 io_thread_task_runner_, net_components_->GetBrowserConnectionHandler())); | |
| 68 } | |
| 39 | 69 |
| 40 #if defined(OS_ANDROID) | 70 #if defined(OS_ANDROID) |
| 41 | 71 |
| 42 base::android::ScopedJavaLocalRef<jobject> | 72 base::android::ScopedJavaLocalRef<jobject> |
| 43 BlimpClientContextImpl::GetJavaObject() { | 73 BlimpClientContextImpl::GetJavaObject() { |
| 44 return GetBlimpClientContextImplAndroid()->GetJavaObject(); | 74 return GetBlimpClientContextImplAndroid()->GetJavaObject(); |
| 45 } | 75 } |
| 46 | 76 |
| 47 BlimpClientContextImplAndroid* | 77 BlimpClientContextImplAndroid* |
| 48 BlimpClientContextImpl::GetBlimpClientContextImplAndroid() { | 78 BlimpClientContextImpl::GetBlimpClientContextImplAndroid() { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 64 delegate_ = delegate; | 94 delegate_ = delegate; |
| 65 } | 95 } |
| 66 | 96 |
| 67 std::unique_ptr<BlimpContents> BlimpClientContextImpl::CreateBlimpContents() { | 97 std::unique_ptr<BlimpContents> BlimpClientContextImpl::CreateBlimpContents() { |
| 68 std::unique_ptr<BlimpContents> blimp_contents = | 98 std::unique_ptr<BlimpContents> blimp_contents = |
| 69 base::WrapUnique(new BlimpContentsImpl); | 99 base::WrapUnique(new BlimpContentsImpl); |
| 70 delegate_->AttachBlimpContentsHelpers(blimp_contents.get()); | 100 delegate_->AttachBlimpContentsHelpers(blimp_contents.get()); |
| 71 return blimp_contents; | 101 return blimp_contents; |
| 72 } | 102 } |
| 73 | 103 |
| 104 void BlimpClientContextImpl::OnConnected() {} | |
| 105 | |
| 106 void BlimpClientContextImpl::OnDisconnected(int result) {} | |
| 107 | |
| 74 } // namespace client | 108 } // namespace client |
| 75 } // namespace blimp | 109 } // namespace blimp |
| OLD | NEW |