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

Unified Diff: remoting/host/chromoting_host_context.h

Issue 11419265: Revert 170360 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | remoting/host/chromoting_host_context.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/chromoting_host_context.h
===================================================================
--- remoting/host/chromoting_host_context.h (revision 170590)
+++ remoting/host/chromoting_host_context.h (working copy)
@@ -7,8 +7,12 @@
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/threading/thread.h"
+namespace base {
+class SingleThreadTaskRunner;
+} // namespace base
+
namespace net {
class URLRequestContextGetter;
} // namespace net
@@ -21,72 +25,83 @@
// process. This class is virtual only for testing purposes (see below).
class ChromotingHostContext {
public:
+ // Create a context.
+ ChromotingHostContext(
+ scoped_refptr<AutoThreadTaskRunner> ui_task_runner);
virtual ~ChromotingHostContext();
- // Create threads and URLRequestContextGetter for use by a host.
- // During shutdown the caller should tear-down the ChromotingHostContext and
- // then continue to run until |ui_task_runner| is no longer referenced.
- // NULL is returned if any threads fail to start.
- static scoped_ptr<ChromotingHostContext> Create(
- scoped_refptr<AutoThreadTaskRunner> ui_task_runner);
+ // 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 used for audio capture and encoding.
- scoped_refptr<AutoThreadTaskRunner> audio_task_runner();
+ virtual base::SingleThreadTaskRunner* audio_task_runner();
// Task runner for the thread used by the ScreenRecorder to capture
// the screen.
- scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner();
+ virtual base::SingleThreadTaskRunner* video_capture_task_runner();
// Task runner for the thread used to encode video streams.
- scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner();
+ virtual base::SingleThreadTaskRunner* video_encode_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.
- scoped_refptr<AutoThreadTaskRunner> file_task_runner();
+ virtual base::SingleThreadTaskRunner* file_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?
- scoped_refptr<AutoThreadTaskRunner> input_task_runner();
+ virtual base::SingleThreadTaskRunner* input_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.
- scoped_refptr<AutoThreadTaskRunner> network_task_runner();
+ virtual base::SingleThreadTaskRunner* network_task_runner();
// Task runner for the thread that is used for the UI. In the NPAPI
// plugin this corresponds to the main plugin thread.
- scoped_refptr<AutoThreadTaskRunner> ui_task_runner();
+ virtual base::SingleThreadTaskRunner* ui_task_runner();
- scoped_refptr<net::URLRequestContextGetter> url_request_context_getter();
+ const scoped_refptr<net::URLRequestContextGetter>&
+ url_request_context_getter();
private:
- ChromotingHostContext(AutoThreadTaskRunner* ui_task_runner);
+ FRIEND_TEST_ALL_PREFIXES(ChromotingHostContextTest, StartAndStop);
- // Thread for audio capture and encoding.
- scoped_refptr<AutoThreadTaskRunner> audio_task_runner_;
+ // A thread that hosts audio capture and encoding.
+ base::Thread audio_thread_;
- // Thread for screen capture.
- scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner_;
+ // A thread that hosts screen capture.
+ base::Thread video_capture_thread_;
- // Thread for video encoding.
- scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner_;
+ // A thread that hosts video encode operations.
+ base::Thread video_encode_thread_;
- // Thread for I/O operations.
- scoped_refptr<AutoThreadTaskRunner> file_task_runner_;
+ // Thread for blocking IO operations.
+ base::Thread file_thread_;
- // Thread for input injection.
- scoped_refptr<AutoThreadTaskRunner> input_task_runner_;
+ // A thread that hosts input injection.
+ base::Thread input_thread_;
- // Thread for network operations.
- scoped_refptr<AutoThreadTaskRunner> network_task_runner_;
+ // A thread that hosts all network operations.
+ base::Thread network_thread_;
- // Caller-supplied UI thread. This is usually the application main thread.
+ // Task runners wrapping the above threads. These should be declared after
+ // the corresponding threads to guarantee proper order of destruction.
+ scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner_;
+ scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner_;
+ scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner_;
+ scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
+ scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_;
+ scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
+
scoped_refptr<AutoThreadTaskRunner> ui_task_runner_;
- // Serves URLRequestContexts that use the network and UI task runners.
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext);
« no previous file with comments | « no previous file | remoting/host/chromoting_host_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698