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 "remoting/base/url_request_context_getter.h" | |
| 10 | |
| 11 namespace remoting { | |
| 12 | |
| 13 scoped_ptr<ChromotingClientRuntime> ChromotingClientRuntime::Create() { | |
| 14 return make_scoped_ptr(new ChromotingClientRuntime()); | |
| 15 } | |
| 16 | |
| 17 ChromotingClientRuntime::ChromotingClientRuntime() { | |
| 18 if (!base::MessageLoop::current()) { | |
|
Sergey Ulanov
2016/03/11 01:22:34
Maybe just replace it with a DCHECK and make the c
nicholss
2016/03/11 21:23:02
Ok, I moved this out, it is starting to look more
| |
| 19 VLOG(1) << "Starting main message loop"; | |
| 20 ui_loop_.reset(new base::MessageLoopForUI()); | |
| 21 #if defined(OS_IOS) | |
| 22 // On iOS we created a new message loop and now attach it. | |
| 23 base::MessageLoopForUI::current()->Attach(); | |
|
Lambros
2016/03/10 00:52:15
ui_loop_->Attach(); maybe?
nicholss
2016/03/11 21:23:02
Done.
| |
| 24 #elif defined(OS_ANDROID) | |
| 25 // On Android, the UI thread is managed by Java, so we need to attach and | |
| 26 // start a special type of message loop to allow Chromium code to run tasks. | |
| 27 ui_loop_->Start(); | |
| 28 #else | |
| 29 NOTREACHED(); | |
|
Lambros
2016/03/10 00:52:15
This file seems to be specific to mobile clients.
nicholss
2016/03/11 21:23:02
This is fixed with the moving of the main thread g
| |
| 30 #endif | |
| 31 } else { | |
| 32 VLOG(1) << "Using existing main message loop"; | |
| 33 ui_loop_.reset(base::MessageLoopForUI::current()); | |
| 34 } | |
| 35 | |
| 36 // |ui_loop_| runs on the main thread, so |ui_task_runner_| will run on the | |
| 37 // main thread. We can not kill the main thread when the message loop becomes | |
| 38 // idle so the callback function does nothing (as opposed to the typical | |
| 39 // base::MessageLoop::QuitClosure()) | |
| 40 ui_task_runner_ = new AutoThreadTaskRunner(ui_loop_->task_runner(), | |
| 41 base::Bind(&base::DoNothing)); | |
| 42 | |
| 43 display_task_runner_ = AutoThread::Create("native_disp", ui_task_runner_); | |
| 44 network_task_runner_ = AutoThread::CreateWithType( | |
| 45 "native_net", ui_task_runner_, base::MessageLoop::TYPE_IO); | |
| 46 file_task_runner_ = AutoThread::CreateWithType("native_file", ui_task_runner_, | |
|
Lambros
2016/03/10 00:52:15
Adding a new thread (and passing it to URLRequestC
nicholss
2016/03/11 21:23:02
Testing now.
| |
| 47 base::MessageLoop::TYPE_IO); | |
| 48 url_requester_ = | |
| 49 new URLRequestContextGetter(network_task_runner_, file_task_runner_); | |
| 50 } | |
| 51 | |
| 52 ChromotingClientRuntime::~ChromotingClientRuntime() {} | |
| 53 | |
| 54 } // namespace remoting | |
| OLD | NEW |