blob: 2e3480d69d3a1c50f59421615d2aad0d494ce494 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_
#define REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_
#include <string>
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread.h"
namespace base {
class SingleThreadTaskRunner;
} // namespace base
namespace net {
class URLRequestContextGetter;
} // namespace net
namespace remoting {
// A class that manages threads and running context for the chromoting host
// process. This class is virtual only for testing purposes (see below).
class ChromotingHostContext {
public:
// Create a context.
ChromotingHostContext(
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner);
virtual ~ChromotingHostContext();
// TODO(ajwong): Move the Start method out of this class. Then
// create a static factory for construction, and destruction. We
// should be able to remove the need for virtual functions below
// with that design, while preserving the relative simplicity of
// this API.
virtual bool Start();
// Task runner for the thread that is used for the UI. In the NPAPI
// plugin this corresponds to the main plugin thread.
virtual base::SingleThreadTaskRunner* ui_task_runner();
// Task runner for the thread used by the ScreenRecorder to capture
// the screen.
virtual base::SingleThreadTaskRunner* capture_task_runner();
// Task runner for the thread used to encode video streams.
virtual base::SingleThreadTaskRunner* encode_task_runner();
// Task runner for the thread used for network IO. This thread runs
// a libjingle message loop, and is the only thread on which
// libjingle code may be run.
virtual base::SingleThreadTaskRunner* network_task_runner();
// Task runner for the thread that is used by the EventExecutor.
//
// TODO(sergeyu): Do we need a separate thread for EventExecutor?
// Can we use some other thread instead?
virtual base::SingleThreadTaskRunner* desktop_task_runner();
// Task runner for the thread that is used for blocking file
// IO. This thread is used by the URLRequestContext to read proxy
// configuration and by NatConfig to read policy configs.
virtual base::SingleThreadTaskRunner* file_task_runner();
const scoped_refptr<net::URLRequestContextGetter>&
url_request_context_getter();
private:
FRIEND_TEST_ALL_PREFIXES(ChromotingHostContextTest, StartAndStop);
// A thread that hosts all network operations.
base::Thread network_thread_;
// A thread that hosts screen capture.
base::Thread capture_thread_;
// A thread that hosts all encode operations.
base::Thread encode_thread_;
// A thread that hosts input injection.
base::Thread desktop_thread_;
// Thread for blocking IO operations.
base::Thread file_thread_;
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext);
};
} // namespace remoting
#endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_
|