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

Side by Side Diff: remoting/host/chromoting_host_context.h

Issue 7655006: Revert 97050 - Add PluginMessageLoopProxy and use it for Host plugin UI thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/base/plugin_message_loop_proxy.cc ('k') | remoting/host/chromoting_host_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ 5 #ifndef REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_
6 #define REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ 6 #define REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/threading/platform_thread.h" 12 #include "base/threading/platform_thread.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "remoting/jingle_glue/jingle_thread.h" 14 #include "remoting/jingle_glue/jingle_thread.h"
15 15
16 class Task; 16 class Task;
17 17
18 namespace tracked_objects { 18 namespace tracked_objects {
19 class Location; 19 class Location;
20 } 20 }
21 21
22 namespace remoting { 22 namespace remoting {
23 23
24 // A class that manages threads and running context for the chromoting host 24 // A class that manages threads and running context for the chromoting host
25 // process. This class is virtual only for testing purposes (see below). 25 // process. This class is virtual only for testing purposes (see below).
26 class ChromotingHostContext { 26 class ChromotingHostContext {
27 public: 27 public:
28 typedef base::Callback<void(
29 const tracked_objects::Location& from_here,
30 const base::Closure& task)> UIThreadPostTaskFunction;
31
28 // Create a context. 32 // Create a context.
29 ChromotingHostContext(base::MessageLoopProxy* ui_message_loop); 33 ChromotingHostContext();
30 virtual ~ChromotingHostContext(); 34 virtual ~ChromotingHostContext();
31 35
32 // TODO(ajwong): Move the Start/Stop methods out of this class. Then 36 // TODO(ajwong): Move the Start/Stop methods out of this class. Then
33 // create a static factory for construction, and destruction. We 37 // create a static factory for construction, and destruction. We
34 // should be able to remove the need for virtual functions below with that 38 // should be able to remove the need for virtual functions below with that
35 // design, while preserving the relative simplicity of this API. 39 // design, while preserving the relative simplicity of this API.
36 virtual void Start(); 40 virtual void Start();
37 virtual void Stop(); 41 virtual void Stop();
38 42
39 virtual JingleThread* jingle_thread(); 43 virtual JingleThread* jingle_thread();
40 44
41 virtual base::MessageLoopProxy* ui_message_loop();
42 virtual MessageLoop* main_message_loop(); 45 virtual MessageLoop* main_message_loop();
43 virtual MessageLoop* encode_message_loop(); 46 virtual MessageLoop* encode_message_loop();
44 virtual base::MessageLoopProxy* network_message_loop(); 47 virtual base::MessageLoopProxy* network_message_loop();
45 virtual MessageLoop* desktop_message_loop(); 48 virtual MessageLoop* desktop_message_loop();
46 49
50 // Must be called from the main GUI thread.
51 void SetUITaskPostFunction(const UIThreadPostTaskFunction& poster);
52
53 void PostTaskToUIThread(const tracked_objects::Location& from_here,
54 const base::Closure& task);
55 void PostDelayedTaskToUIThread(const tracked_objects::Location& from_here,
56 const base::Closure& task,
57 int delay_ms);
58 bool IsUIThread() const;
59
47 private: 60 private:
48 FRIEND_TEST_ALL_PREFIXES(ChromotingHostContextTest, StartAndStop); 61 FRIEND_TEST_ALL_PREFIXES(ChromotingHostContextTest, StartAndStop);
49 62
50 // A thread that hosts all network operations. 63 // A thread that hosts all network operations.
51 JingleThread jingle_thread_; 64 JingleThread jingle_thread_;
52 65
53 // A thread that hosts ChromotingHost and performs rate control. 66 // A thread that hosts ChromotingHost and performs rate control.
54 base::Thread main_thread_; 67 base::Thread main_thread_;
55 68
56 // A thread that hosts all encode operations. 69 // A thread that hosts all encode operations.
57 base::Thread encode_thread_; 70 base::Thread encode_thread_;
58 71
59 // A thread that hosts desktop integration (capture, input injection, etc) 72 // A thread that hosts desktop integration (capture, input injection, etc)
60 // This is NOT a Chrome-style UI thread. 73 // This is NOT a Chrome-style UI thread.
61 base::Thread desktop_thread_; 74 base::Thread desktop_thread_;
62 75
63 scoped_refptr<base::MessageLoopProxy> ui_message_loop_; 76 UIThreadPostTaskFunction ui_poster_;
77 // This IS the main Chrome GUI thread that |ui_poster_| will post to.
78 base::PlatformThreadId ui_main_thread_id_;
79
64 80
65 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext); 81 DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext);
66 }; 82 };
67 83
68 } // namespace remoting 84 } // namespace remoting
69 85
70 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_ 86 #endif // REMOTING_HOST_CHROMOTING_HOST_CONTEXT_H_
OLDNEW
« no previous file with comments | « remoting/base/plugin_message_loop_proxy.cc ('k') | remoting/host/chromoting_host_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698