Chromium Code Reviews| 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 { | |
| 13 | |
| 14 void DoNothing() { | |
|
Sergey Ulanov
2016/03/04 22:50:17
Please use base::DoNothing().
nicholss
2016/03/07 18:32:36
Done.
| |
| 15 } | |
| 16 } // namespace | |
| 17 | |
| 18 namespace remoting { | |
| 19 | |
| 20 ChromotingClientRuntime::ChromotingClientRuntime() { | |
| 21 if (!base::MessageLoop::current()) { | |
| 22 VLOG(1) << "Starting main message loop"; | |
| 23 ui_loop_ = new base::MessageLoop(base::MessageLoop::TYPE_UI); | |
| 24 base::MessageLoopForUI::current()->Attach(); | |
| 25 } else { | |
| 26 VLOG(1) << "Using existing main message loop"; | |
| 27 ui_loop_ = base::MessageLoopForUI::current(); | |
| 28 } | |
| 29 | |
| 30 // |ui_loop_| runs on the main thread, so |ui_task_runner_| will run on the | |
| 31 // main thread. We can not kill the main thread when the message loop becomes | |
| 32 // idle so the callback function does nothing (as opposed to the typical | |
| 33 // base::MessageLoop::QuitClosure()) | |
| 34 ui_task_runner_ = new AutoThreadTaskRunner(ui_loop_->task_runner(), | |
| 35 base::Bind(&::DoNothing)); | |
| 36 | |
| 37 network_task_runner_ = AutoThread::CreateWithType( | |
| 38 "native_net", ui_task_runner_, base::MessageLoop::TYPE_IO); | |
| 39 file_task_runner_ = AutoThread::CreateWithType( | |
| 40 "native_file", ui_task_runner_, base::MessageLoop::TYPE_IO); | |
| 41 | |
| 42 url_requester_ = | |
| 43 new URLRequestContextGetter(network_task_runner_, file_task_runner_); | |
| 44 | |
| 45 } | |
| 46 | |
| 47 // static | |
| 48 ChromotingClientRuntime* ChromotingClientRuntime::GetInstance() { | |
| 49 return base::Singleton<ChromotingClientRuntime>::get(); | |
|
Sergey Ulanov
2016/03/04 22:50:17
Does this need to be a singleton?
Potentially ther
nicholss
2016/03/07 18:32:36
It is very convenient if this is a singleton.
It
Sergey Ulanov
2016/03/08 18:53:46
There are cases when we will need to have multiple
nicholss
2016/03/08 21:20:25
Done.
| |
| 50 } | |
| 51 | |
| 52 ChromotingClientRuntime::~ChromotingClientRuntime() { | |
| 53 } | |
| 54 | |
| 55 } // namespace remoting | |
| OLD | NEW |