Roll third_party/android_tools to the latest: updated the support library to 19.0.1
[chromium-blink-merge.git] / remoting / host / chromoting_host_context.h
blob6dabfb1766912314e8721ddeea7fe3372c0a9d51
1 // Copyright (c) 2012 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.
5 #ifndef REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_
6 #define REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_
8 #include "base/gtest_prod_util.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
12 namespace net {
13 class URLRequestContextGetter;
14 } // namespace net
16 namespace remoting {
18 class AutoThreadTaskRunner;
20 // A class that manages threads and running context for the chromoting host
21 // process. This class is virtual only for testing purposes (see below).
22 class ChromotingHostContext {
23 public:
24 ~ChromotingHostContext();
26 // Create threads and URLRequestContextGetter for use by a host.
27 // During shutdown the caller should tear-down the ChromotingHostContext and
28 // then continue to run until |ui_task_runner| is no longer referenced.
29 // NULL is returned if any threads fail to start.
30 static scoped_ptr<ChromotingHostContext> Create(
31 scoped_refptr<AutoThreadTaskRunner> ui_task_runner);
33 // Task runner for the thread used for audio capture and encoding.
34 scoped_refptr<AutoThreadTaskRunner> audio_task_runner();
36 // Task runner for the thread that is used for blocking file
37 // IO. This thread is used by the URLRequestContext to read proxy
38 // configuration and by NatConfig to read policy configs.
39 scoped_refptr<AutoThreadTaskRunner> file_task_runner();
41 // Task runner for the thread that is used by the InputInjector.
43 // TODO(sergeyu): Do we need a separate thread for InputInjector?
44 // Can we use some other thread instead?
45 scoped_refptr<AutoThreadTaskRunner> input_task_runner();
47 // Task runner for the thread used for network IO. This thread runs
48 // a libjingle message loop, and is the only thread on which
49 // libjingle code may be run.
50 scoped_refptr<AutoThreadTaskRunner> network_task_runner();
52 // Task runner for the thread that is used for the UI. In the NPAPI
53 // plugin this corresponds to the main plugin thread.
54 scoped_refptr<AutoThreadTaskRunner> ui_task_runner();
56 // Task runner for the thread used by the ScreenRecorder to capture
57 // the screen.
58 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner();
60 // Task runner for the thread used to encode video streams.
61 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner();
63 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter();
65 private:
66 ChromotingHostContext(AutoThreadTaskRunner* ui_task_runner);
68 // Thread for audio capture and encoding.
69 scoped_refptr<AutoThreadTaskRunner> audio_task_runner_;
71 // Thread for I/O operations.
72 scoped_refptr<AutoThreadTaskRunner> file_task_runner_;
74 // Thread for input injection.
75 scoped_refptr<AutoThreadTaskRunner> input_task_runner_;
77 // Thread for network operations.
78 scoped_refptr<AutoThreadTaskRunner> network_task_runner_;
80 // Caller-supplied UI thread. This is usually the application main thread.
81 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_;
83 // Thread for screen capture.
84 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner_;
86 // Thread for video encoding.
87 scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner_;
89 // Serves URLRequestContexts that use the network and UI task runners.
90 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
92 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext);
95 } // namespace remoting
97 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_