| 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/context/blimp_client_context_impl.h" | 5 #include "blimp/client/core/context/blimp_client_context_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 base::SequencedTaskRunnerHandle::Get()))); | 101 base::SequencedTaskRunnerHandle::Get()))); |
| 102 | 102 |
| 103 // The |thread_pipe_manager_| must be set up correctly before features are | 103 // The |thread_pipe_manager_| must be set up correctly before features are |
| 104 // registered. | 104 // registered. |
| 105 thread_pipe_manager_ = base::MakeUnique<ThreadPipeManager>( | 105 thread_pipe_manager_ = base::MakeUnique<ThreadPipeManager>( |
| 106 io_thread_task_runner_, net_components_->GetBrowserConnectionHandler()); | 106 io_thread_task_runner_, net_components_->GetBrowserConnectionHandler()); |
| 107 | 107 |
| 108 RegisterFeatures(); | 108 RegisterFeatures(); |
| 109 InitializeSettings(); | 109 InitializeSettings(); |
| 110 | 110 |
| 111 connection_status_.AddObserver(this); |
| 112 |
| 111 // Initialize must only be posted after the features have been | 113 // Initialize must only be posted after the features have been |
| 112 // registered. | 114 // registered. |
| 113 io_thread_task_runner_->PostTask( | 115 io_thread_task_runner_->PostTask( |
| 114 FROM_HERE, base::Bind(&ClientNetworkComponents::Initialize, | 116 FROM_HERE, base::Bind(&ClientNetworkComponents::Initialize, |
| 115 base::Unretained(net_components_.get()))); | 117 base::Unretained(net_components_.get()))); |
| 116 | 118 |
| 117 UMA_HISTOGRAM_BOOLEAN("Blimp.Supported", true); | 119 UMA_HISTOGRAM_BOOLEAN("Blimp.Supported", true); |
| 118 } | 120 } |
| 119 | 121 |
| 120 BlimpClientContextImpl::~BlimpClientContextImpl() { | 122 BlimpClientContextImpl::~BlimpClientContextImpl() { |
| 121 io_thread_task_runner_->DeleteSoon(FROM_HERE, net_components_.release()); | 123 io_thread_task_runner_->DeleteSoon(FROM_HERE, net_components_.release()); |
| 124 connection_status_.RemoveObserver(this); |
| 122 } | 125 } |
| 123 | 126 |
| 124 void BlimpClientContextImpl::SetDelegate(BlimpClientContextDelegate* delegate) { | 127 void BlimpClientContextImpl::SetDelegate(BlimpClientContextDelegate* delegate) { |
| 125 delegate_ = delegate; | 128 delegate_ = delegate; |
| 126 } | 129 } |
| 127 | 130 |
| 128 std::unique_ptr<BlimpContents> BlimpClientContextImpl::CreateBlimpContents( | 131 std::unique_ptr<BlimpContents> BlimpClientContextImpl::CreateBlimpContents( |
| 129 gfx::NativeWindow window) { | 132 gfx::NativeWindow window) { |
| 130 std::unique_ptr<BlimpContents> blimp_contents = | 133 std::unique_ptr<BlimpContents> blimp_contents = |
| 131 blimp_contents_manager_->CreateBlimpContents(window); | 134 blimp_contents_manager_->CreateBlimpContents(window); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 identity_source_ = base::MakeUnique<IdentitySource>( | 250 identity_source_ = base::MakeUnique<IdentitySource>( |
| 248 delegate_, base::Bind(&BlimpClientContextImpl::OnAuthTokenReceived, | 251 delegate_, base::Bind(&BlimpClientContextImpl::OnAuthTokenReceived, |
| 249 base::Unretained(this))); | 252 base::Unretained(this))); |
| 250 } | 253 } |
| 251 | 254 |
| 252 void BlimpClientContextImpl::OnImageDecodeError() { | 255 void BlimpClientContextImpl::OnImageDecodeError() { |
| 253 // Currently we just drop the connection on image decoding error. | 256 // Currently we just drop the connection on image decoding error. |
| 254 DropConnection(); | 257 DropConnection(); |
| 255 } | 258 } |
| 256 | 259 |
| 260 void BlimpClientContextImpl::OnConnected() { |
| 261 if (delegate_) { |
| 262 delegate_->OnConnected(); |
| 263 } |
| 264 } |
| 265 |
| 266 void BlimpClientContextImpl::OnDisconnected(int result) { |
| 267 if (delegate_) { |
| 268 if (result >= 0) { |
| 269 delegate_->OnEngineDisconnected(result); |
| 270 } else { |
| 271 delegate_->OnNetworkDisconnected(result); |
| 272 } |
| 273 } |
| 274 } |
| 275 |
| 257 } // namespace client | 276 } // namespace client |
| 258 } // namespace blimp | 277 } // namespace blimp |
| OLD | NEW |