Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Side by Side Diff: remoting/client/chromoting_client_runtime.cc

Issue 1764503002: Adding container class for chromoting client runtimes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Jni runtime now holds a scoped_ptr<ChromotingClientRuntime>. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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()) {
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();
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();
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_,
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698