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

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: Updated based on feedback. Removed unused includes. 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
« no previous file with comments | « remoting/client/chromoting_client_runtime.h ('k') | remoting/remoting_srcs.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
OLDNEW
« no previous file with comments | « remoting/client/chromoting_client_runtime.h ('k') | remoting/remoting_srcs.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698