OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/ios/app_runtime.h" | 5 #include "remoting/client/ios/app_runtime.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "remoting/protocol/client_authentication_config.h" | 22 #include "remoting/protocol/client_authentication_config.h" |
23 #include "remoting/protocol/host_stub.h" | 23 #include "remoting/protocol/host_stub.h" |
24 #include "remoting/protocol/negotiating_client_authenticator.h" | 24 #include "remoting/protocol/negotiating_client_authenticator.h" |
25 #include "remoting/protocol/transport_context.h" | 25 #include "remoting/protocol/transport_context.h" |
26 #include "remoting/signaling/delegating_signal_strategy.h" | 26 #include "remoting/signaling/delegating_signal_strategy.h" |
27 | 27 |
28 namespace remoting { | 28 namespace remoting { |
29 namespace ios { | 29 namespace ios { |
30 | 30 |
31 AppRuntime::AppRuntime() { | 31 AppRuntime::AppRuntime() { |
32 // TODO(sergeyu): Consider adding separate pools for different task classes. | |
33 const int kMaxBackgroundThreads = 5; | |
34 if (!base::TaskScheduler::GetInstance()) { | 32 if (!base::TaskScheduler::GetInstance()) { |
35 // Make sure TaskScheduler is initialized. | 33 // Make sure TaskScheduler is initialized. |
36 base::TaskScheduler::CreateAndSetSimpleTaskScheduler(kMaxBackgroundThreads); | 34 base::TaskScheduler::CreateAndSetSimpleTaskScheduler("Remoting"); |
37 } | 35 } |
38 | 36 |
39 // TODO(sergeyu): AppRuntime is not singleton, but it owns MessageLoop for the | 37 // TODO(sergeyu): AppRuntime is not singleton, but it owns MessageLoop for the |
40 // current thread. This means that it's not safe to create multiple AppRuntime | 38 // current thread. This means that it's not safe to create multiple AppRuntime |
41 // instances on the same thread. AppRuntime should be a singleton, or this | 39 // instances on the same thread. AppRuntime should be a singleton, or this |
42 // code needs to be moved somewhere else. | 40 // code needs to be moved somewhere else. |
43 if (!base::MessageLoop::current()) { | 41 if (!base::MessageLoop::current()) { |
44 ui_loop_.reset(new base::MessageLoopForUI()); | 42 ui_loop_.reset(new base::MessageLoopForUI()); |
45 base::MessageLoopForUI::current()->Attach(); | 43 base::MessageLoopForUI::current()->Attach(); |
46 } else { | 44 } else { |
47 ui_loop_.reset(base::MessageLoopForUI::current()); | 45 ui_loop_.reset(base::MessageLoopForUI::current()); |
48 } | 46 } |
49 runtime_ = ChromotingClientRuntime::Create(ui_loop_.get()); | 47 runtime_ = ChromotingClientRuntime::Create(ui_loop_.get()); |
50 } | 48 } |
51 | 49 |
52 AppRuntime::~AppRuntime() { | 50 AppRuntime::~AppRuntime() { |
53 // TODO(nicholss): Shutdown the app. | 51 // TODO(nicholss): Shutdown the app. |
54 } | 52 } |
55 | 53 |
56 } // namespace ios | 54 } // namespace ios |
57 } // namespace remoting | 55 } // namespace remoting |
OLD | NEW |