| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "remoting/client/chromoting_client_runtime.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/logging.h" |
| 9 #include "base/memory/singleton.h" |
| 10 #include "remoting/base/url_request_context_getter.h" |
| 11 |
| 12 namespace remoting { |
| 13 |
| 14 ChromotingClientRuntime::ChromotingClientRuntime() { |
| 15 if (!base::MessageLoop::current()) { |
| 16 VLOG(1) << "Starting main message loop"; |
| 17 ui_loop_ = new base::MessageLoop(base::MessageLoop::TYPE_UI); |
| 18 base::MessageLoopForUI::current()->Attach(); |
| 19 } else { |
| 20 VLOG(1) << "Using existing main message loop"; |
| 21 ui_loop_ = base::MessageLoopForUI::current(); |
| 22 } |
| 23 |
| 24 // |ui_loop_| runs on the main thread, so |ui_task_runner_| will run on the |
| 25 // main thread. We can not kill the main thread when the message loop becomes |
| 26 // idle so the callback function does nothing (as opposed to the typical |
| 27 // base::MessageLoop::QuitClosure()) |
| 28 ui_task_runner_ = new AutoThreadTaskRunner(ui_loop_->task_runner(), |
| 29 base::Bind(&base::DoNothing)); |
| 30 |
| 31 network_task_runner_ = AutoThread::CreateWithType("native_net", |
| 32 ui_task_runner_, |
| 33 base::MessageLoop::TYPE_IO); |
| 34 file_task_runner_ = AutoThread::CreateWithType("native_file", |
| 35 ui_task_runner_, |
| 36 base::MessageLoop::TYPE_IO); |
| 37 |
| 38 url_requester_ = |
| 39 new URLRequestContextGetter(network_task_runner_, file_task_runner_); |
| 40 } |
| 41 |
| 42 // static |
| 43 ChromotingClientRuntime* ChromotingClientRuntime::GetInstance() { |
| 44 return base::Singleton<ChromotingClientRuntime>::get(); |
| 45 } |
| 46 |
| 47 ChromotingClientRuntime::~ChromotingClientRuntime() {} |
| 48 |
| 49 } // namespace remoting |
| OLD | NEW |