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 <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 20 matching lines...) Expand all Loading... |
31 #include "ui/gfx/native_widget_types.h" | 31 #include "ui/gfx/native_widget_types.h" |
32 | 32 |
33 #if defined(OS_ANDROID) | 33 #if defined(OS_ANDROID) |
34 #include "blimp/client/core/android/blimp_client_context_impl_android.h" | 34 #include "blimp/client/core/android/blimp_client_context_impl_android.h" |
35 #endif // OS_ANDROID | 35 #endif // OS_ANDROID |
36 | 36 |
37 namespace blimp { | 37 namespace blimp { |
38 namespace client { | 38 namespace client { |
39 | 39 |
40 namespace { | 40 namespace { |
| 41 |
41 const char kDefaultAssignerUrl[] = | 42 const char kDefaultAssignerUrl[] = |
42 "https://blimp-pa.googleapis.com/v1/assignment"; | 43 "https://blimp-pa.googleapis.com/v1/assignment"; |
| 44 |
| 45 void DropConnectionOnIOThread(ClientNetworkComponents* net_components) { |
| 46 net_components->GetBrowserConnectionHandler()->DropCurrentConnection(); |
| 47 } |
| 48 |
43 } // namespace | 49 } // namespace |
44 | 50 |
45 // This function is declared in //blimp/client/public/blimp_client_context.h, | 51 // This function is declared in //blimp/client/public/blimp_client_context.h, |
46 // and either this function or the one in | 52 // and either this function or the one in |
47 // //blimp/client/core/dummy_blimp_client_context.cc should be linked in to | 53 // //blimp/client/core/dummy_blimp_client_context.cc should be linked in to |
48 // any binary using BlimpClientContext::Create. | 54 // any binary using BlimpClientContext::Create. |
49 // static | 55 // static |
50 BlimpClientContext* BlimpClientContext::Create( | 56 BlimpClientContext* BlimpClientContext::Create( |
51 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, | 57 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, |
52 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, | 58 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 thread_pipe_manager_->RegisterFeature(BlimpMessage::kTabControl, | 225 thread_pipe_manager_->RegisterFeature(BlimpMessage::kTabControl, |
220 tab_control_feature_.get())); | 226 tab_control_feature_.get())); |
221 } | 227 } |
222 | 228 |
223 void BlimpClientContextImpl::InitializeSettings() { | 229 void BlimpClientContextImpl::InitializeSettings() { |
224 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 230 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
225 switches::kDownloadWholeDocument)) | 231 switches::kDownloadWholeDocument)) |
226 settings_feature_->SetRecordWholeDocument(true); | 232 settings_feature_->SetRecordWholeDocument(true); |
227 } | 233 } |
228 | 234 |
| 235 void BlimpClientContextImpl::DropConnection() { |
| 236 io_thread_task_runner_->PostTask( |
| 237 FROM_HERE, base::Bind(&DropConnectionOnIOThread, net_components_.get())); |
| 238 } |
| 239 |
229 void BlimpClientContextImpl::CreateIdentitySource() { | 240 void BlimpClientContextImpl::CreateIdentitySource() { |
230 identity_source_ = base::MakeUnique<IdentitySource>( | 241 identity_source_ = base::MakeUnique<IdentitySource>( |
231 delegate_, base::Bind(&BlimpClientContextImpl::OnAuthTokenReceived, | 242 delegate_, base::Bind(&BlimpClientContextImpl::OnAuthTokenReceived, |
232 base::Unretained(this))); | 243 base::Unretained(this))); |
233 } | 244 } |
234 | 245 |
235 void BlimpClientContextImpl::OnImageDecodeError() { | 246 void BlimpClientContextImpl::OnImageDecodeError() { |
236 // Currently we just drop the connection on image decoding error. | 247 // Currently we just drop the connection on image decoding error. |
237 io_thread_task_runner_->PostTask( | 248 DropConnection(); |
238 FROM_HERE, | |
239 base::Bind( | |
240 &BrowserConnectionHandler::DropCurrentConnection, | |
241 base::Unretained(net_components_->GetBrowserConnectionHandler()))); | |
242 } | 249 } |
243 | 250 |
244 } // namespace client | 251 } // namespace client |
245 } // namespace blimp | 252 } // namespace blimp |
OLD | NEW |