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/contents/blimp_contents_manager.h" |
13 #include "blimp/client/core/contents/ime_feature.h" | |
14 #include "blimp/client/core/contents/navigation_feature.h" | |
13 #include "blimp/client/core/session/cross_thread_network_event_observer.h" | 15 #include "blimp/client/core/session/cross_thread_network_event_observer.h" |
14 #include "blimp/client/public/blimp_client_context_delegate.h" | 16 #include "blimp/client/public/blimp_client_context_delegate.h" |
15 | 17 |
16 #if defined(OS_ANDROID) | 18 #if defined(OS_ANDROID) |
17 #include "blimp/client/core/android/blimp_client_context_impl_android.h" | 19 #include "blimp/client/core/android/blimp_client_context_impl_android.h" |
18 #endif // OS_ANDROID | 20 #endif // OS_ANDROID |
19 | 21 |
20 namespace blimp { | 22 namespace blimp { |
21 namespace client { | 23 namespace client { |
22 | 24 |
(...skipping 19 matching lines...) Expand all Loading... | |
42 #endif // defined(OS_ANDROID) | 44 #endif // defined(OS_ANDROID) |
43 } | 45 } |
44 | 46 |
45 BlimpClientContextImpl::BlimpClientContextImpl( | 47 BlimpClientContextImpl::BlimpClientContextImpl( |
46 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, | 48 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, |
47 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner) | 49 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner) |
48 : BlimpClientContext(), | 50 : BlimpClientContext(), |
49 io_thread_task_runner_(io_thread_task_runner), | 51 io_thread_task_runner_(io_thread_task_runner), |
50 file_thread_task_runner_(file_thread_task_runner), | 52 file_thread_task_runner_(file_thread_task_runner), |
51 blimp_contents_manager_(new BlimpContentsManager), | 53 blimp_contents_manager_(new BlimpContentsManager), |
54 navigation_feature_(new NavigationFeature), | |
55 ime_feature_(new ImeFeature), | |
52 weak_factory_(this) { | 56 weak_factory_(this) { |
53 blimp_connection_statistics_ = new BlimpConnectionStatistics(); | 57 blimp_connection_statistics_ = new BlimpConnectionStatistics(); |
54 net_components_.reset(new ClientNetworkComponents( | 58 net_components_.reset(new ClientNetworkComponents( |
55 base::MakeUnique<CrossThreadNetworkEventObserver>( | 59 base::MakeUnique<CrossThreadNetworkEventObserver>( |
56 weak_factory_.GetWeakPtr(), base::SequencedTaskRunnerHandle::Get()), | 60 weak_factory_.GetWeakPtr(), base::SequencedTaskRunnerHandle::Get()), |
57 base::WrapUnique(blimp_connection_statistics_))); | 61 base::WrapUnique(blimp_connection_statistics_))); |
58 | 62 |
59 // The |thread_pipe_manager_| must be set up correctly before features are | 63 // The |thread_pipe_manager_| must be set up correctly before features are |
60 // registered. | 64 // registered. |
61 thread_pipe_manager_ = base::MakeUnique<ThreadPipeManager>( | 65 thread_pipe_manager_ = base::MakeUnique<ThreadPipeManager>( |
62 io_thread_task_runner_, net_components_->GetBrowserConnectionHandler()); | 66 io_thread_task_runner_, net_components_->GetBrowserConnectionHandler()); |
63 | 67 |
nyquist
2016/08/24 20:49:11
Should you register the features here?
| |
64 // Initialize must only be posted after the calls features have been | 68 // Initialize must only be posted after the calls features have been |
65 // registered. | 69 // registered. |
66 io_thread_task_runner_->PostTask( | 70 io_thread_task_runner_->PostTask( |
67 FROM_HERE, base::Bind(&ClientNetworkComponents::Initialize, | 71 FROM_HERE, base::Bind(&ClientNetworkComponents::Initialize, |
68 base::Unretained(net_components_.get()))); | 72 base::Unretained(net_components_.get()))); |
69 } | 73 } |
70 | 74 |
71 BlimpClientContextImpl::~BlimpClientContextImpl() { | 75 BlimpClientContextImpl::~BlimpClientContextImpl() { |
72 io_thread_task_runner_->DeleteSoon(FROM_HERE, net_components_.release()); | 76 io_thread_task_runner_->DeleteSoon(FROM_HERE, net_components_.release()); |
73 } | 77 } |
74 | 78 |
75 void BlimpClientContextImpl::SetDelegate(BlimpClientContextDelegate* delegate) { | 79 void BlimpClientContextImpl::SetDelegate(BlimpClientContextDelegate* delegate) { |
76 delegate_ = delegate; | 80 delegate_ = delegate; |
77 } | 81 } |
78 | 82 |
79 std::unique_ptr<BlimpContents> BlimpClientContextImpl::CreateBlimpContents() { | 83 std::unique_ptr<BlimpContents> BlimpClientContextImpl::CreateBlimpContents() { |
80 std::unique_ptr<BlimpContents> blimp_contents = | 84 std::unique_ptr<BlimpContentsImpl> blimp_contents = |
81 blimp_contents_manager_->CreateBlimpContents(); | 85 blimp_contents_manager_->CreateBlimpContents(navigation_feature_.get(), |
86 ime_feature_.get()); | |
82 delegate_->AttachBlimpContentsHelpers(blimp_contents.get()); | 87 delegate_->AttachBlimpContentsHelpers(blimp_contents.get()); |
83 return blimp_contents; | 88 return blimp_contents; |
84 } | 89 } |
85 | 90 |
86 void BlimpClientContextImpl::Connect(const std::string& client_auth_token) { | 91 void BlimpClientContextImpl::Connect(const std::string& client_auth_token) { |
87 if (!assignment_source_) { | 92 if (!assignment_source_) { |
88 assignment_source_.reset(new AssignmentSource( | 93 assignment_source_.reset(new AssignmentSource( |
89 GetAssignerURL(), io_thread_task_runner_, file_thread_task_runner_)); | 94 GetAssignerURL(), io_thread_task_runner_, file_thread_task_runner_)); |
90 } | 95 } |
91 | 96 |
(...skipping 27 matching lines...) Expand all 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 |