| 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 "remoting/client/chromoting_client_runtime.h" | 5 #include "remoting/client/chromoting_client_runtime.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ptr_util.h" |
| 9 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 10 #include "remoting/base/url_request_context_getter.h" | 11 #include "remoting/base/url_request_context_getter.h" |
| 11 | 12 |
| 12 namespace remoting { | 13 namespace remoting { |
| 13 | 14 |
| 14 scoped_ptr<ChromotingClientRuntime> ChromotingClientRuntime::Create( | 15 std::unique_ptr<ChromotingClientRuntime> ChromotingClientRuntime::Create( |
| 15 base::MessageLoopForUI* ui_loop) { | 16 base::MessageLoopForUI* ui_loop) { |
| 16 DCHECK(ui_loop); | 17 DCHECK(ui_loop); |
| 17 | 18 |
| 18 // |ui_loop_| runs on the main thread, so |ui_task_runner_| will run on the | 19 // |ui_loop_| runs on the main thread, so |ui_task_runner_| will run on the |
| 19 // main thread. We can not kill the main thread when the message loop becomes | 20 // main thread. We can not kill the main thread when the message loop becomes |
| 20 // idle so the callback function does nothing (as opposed to the typical | 21 // idle so the callback function does nothing (as opposed to the typical |
| 21 // base::MessageLoop::QuitClosure()) | 22 // base::MessageLoop::QuitClosure()) |
| 22 scoped_refptr<AutoThreadTaskRunner> ui_task_runner = new AutoThreadTaskRunner( | 23 scoped_refptr<AutoThreadTaskRunner> ui_task_runner = new AutoThreadTaskRunner( |
| 23 ui_loop->task_runner(), base::Bind(&base::DoNothing)); | 24 ui_loop->task_runner(), base::Bind(&base::DoNothing)); |
| 24 | 25 |
| 25 scoped_refptr<AutoThreadTaskRunner> display_task_runner = | 26 scoped_refptr<AutoThreadTaskRunner> display_task_runner = |
| 26 AutoThread::Create("native_disp", ui_task_runner); | 27 AutoThread::Create("native_disp", ui_task_runner); |
| 27 scoped_refptr<AutoThreadTaskRunner> network_task_runner = | 28 scoped_refptr<AutoThreadTaskRunner> network_task_runner = |
| 28 AutoThread::CreateWithType("native_net", ui_task_runner, | 29 AutoThread::CreateWithType("native_net", ui_task_runner, |
| 29 base::MessageLoop::TYPE_IO); | 30 base::MessageLoop::TYPE_IO); |
| 30 scoped_refptr<AutoThreadTaskRunner> file_task_runner = | 31 scoped_refptr<AutoThreadTaskRunner> file_task_runner = |
| 31 AutoThread::CreateWithType("native_file", ui_task_runner, | 32 AutoThread::CreateWithType("native_file", ui_task_runner, |
| 32 base::MessageLoop::TYPE_IO); | 33 base::MessageLoop::TYPE_IO); |
| 33 scoped_refptr<net::URLRequestContextGetter> url_requester = | 34 scoped_refptr<net::URLRequestContextGetter> url_requester = |
| 34 new URLRequestContextGetter(network_task_runner, file_task_runner); | 35 new URLRequestContextGetter(network_task_runner, file_task_runner); |
| 35 | 36 |
| 36 return make_scoped_ptr(new ChromotingClientRuntime( | 37 return base::WrapUnique(new ChromotingClientRuntime( |
| 37 ui_task_runner, display_task_runner, network_task_runner, | 38 ui_task_runner, display_task_runner, network_task_runner, |
| 38 file_task_runner, url_requester)); | 39 file_task_runner, url_requester)); |
| 39 } | 40 } |
| 40 | 41 |
| 41 ChromotingClientRuntime::ChromotingClientRuntime( | 42 ChromotingClientRuntime::ChromotingClientRuntime( |
| 42 scoped_refptr<AutoThreadTaskRunner> ui_task_runner, | 43 scoped_refptr<AutoThreadTaskRunner> ui_task_runner, |
| 43 scoped_refptr<AutoThreadTaskRunner> display_task_runner, | 44 scoped_refptr<AutoThreadTaskRunner> display_task_runner, |
| 44 scoped_refptr<AutoThreadTaskRunner> network_task_runner, | 45 scoped_refptr<AutoThreadTaskRunner> network_task_runner, |
| 45 scoped_refptr<AutoThreadTaskRunner> file_task_runner, | 46 scoped_refptr<AutoThreadTaskRunner> file_task_runner, |
| 46 scoped_refptr<net::URLRequestContextGetter> url_requester) | 47 scoped_refptr<net::URLRequestContextGetter> url_requester) |
| 47 : ui_task_runner_(ui_task_runner), | 48 : ui_task_runner_(ui_task_runner), |
| 48 display_task_runner_(display_task_runner), | 49 display_task_runner_(display_task_runner), |
| 49 network_task_runner_(network_task_runner), | 50 network_task_runner_(network_task_runner), |
| 50 file_task_runner_(file_task_runner), | 51 file_task_runner_(file_task_runner), |
| 51 url_requester_(url_requester) {} | 52 url_requester_(url_requester) {} |
| 52 | 53 |
| 53 ChromotingClientRuntime::~ChromotingClientRuntime() {} | 54 ChromotingClientRuntime::~ChromotingClientRuntime() {} |
| 54 | 55 |
| 55 } // namespace remoting | 56 } // namespace remoting |
| OLD | NEW |