OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/client/chromoting_client_runtime.h" | 5 #include "remoting/client/chromoting_client_runtime.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 } // namespace | 21 } // namespace |
22 | 22 |
23 namespace remoting { | 23 namespace remoting { |
24 | 24 |
25 // static | 25 // static |
26 ChromotingClientRuntime* ChromotingClientRuntime::GetInstance() { | 26 ChromotingClientRuntime* ChromotingClientRuntime::GetInstance() { |
27 return base::Singleton<ChromotingClientRuntime>::get(); | 27 return base::Singleton<ChromotingClientRuntime>::get(); |
28 } | 28 } |
29 | 29 |
30 ChromotingClientRuntime::ChromotingClientRuntime() { | 30 ChromotingClientRuntime::ChromotingClientRuntime() { |
31 // TODO(sergeyu): Consider adding separate pools for different task classes. | 31 base::TaskScheduler::CreateAndSetSimpleTaskScheduler("Remoting"); |
32 const int kMaxBackgroundThreads = 5; | |
33 if (!base::TaskScheduler::GetInstance()) { | |
34 // Make sure TaskScheduler is initialized. | |
35 base::TaskScheduler::CreateAndSetSimpleTaskScheduler(kMaxBackgroundThreads); | |
36 } | |
37 | 32 |
38 if (!base::MessageLoop::current()) { | 33 if (!base::MessageLoop::current()) { |
39 VLOG(1) << "Starting main message loop"; | 34 VLOG(1) << "Starting main message loop"; |
40 ui_loop_.reset(new base::MessageLoopForUI()); | 35 ui_loop_.reset(new base::MessageLoopForUI()); |
41 #if defined(OS_ANDROID) | 36 #if defined(OS_ANDROID) |
42 // On Android, the UI thread is managed by Java, so we need to attach and | 37 // On Android, the UI thread is managed by Java, so we need to attach and |
43 // start a special type of message loop to allow Chromium code to run tasks. | 38 // start a special type of message loop to allow Chromium code to run tasks. |
44 ui_loop_->Start(); | 39 ui_loop_->Start(); |
45 #elif defined(OS_IOS) | 40 #elif defined(OS_IOS) |
46 base::MessageLoopForUI::current()->Attach(); | 41 base::MessageLoopForUI::current()->Attach(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } | 110 } |
116 } | 111 } |
117 | 112 |
118 ChromotingEventLogWriter* ChromotingClientRuntime::log_writer() { | 113 ChromotingEventLogWriter* ChromotingClientRuntime::log_writer() { |
119 DCHECK(network_task_runner()->BelongsToCurrentThread()); | 114 DCHECK(network_task_runner()->BelongsToCurrentThread()); |
120 return log_writer_.get(); | 115 return log_writer_.get(); |
121 } | 116 } |
122 | 117 |
123 | 118 |
124 } // namespace remoting | 119 } // namespace remoting |
OLD | NEW |