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

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

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
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 #include "remoting/host/chromoting_host_context.h" 5 #include "remoting/host/chromoting_host_context.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
11 #include "remoting/jingle_glue/jingle_thread.h" 11 #include "remoting/jingle_glue/jingle_thread.h"
12 12
13 namespace remoting { 13 namespace remoting {
14 14
15 ChromotingHostContext::ChromotingHostContext( 15 ChromotingHostContext::ChromotingHostContext()
16 base::MessageLoopProxy* ui_message_loop)
17 : main_thread_("ChromotingMainThread"), 16 : main_thread_("ChromotingMainThread"),
18 encode_thread_("ChromotingEncodeThread"), 17 encode_thread_("ChromotingEncodeThread"),
19 desktop_thread_("ChromotingDesktopThread"), 18 desktop_thread_("ChromotingDesktopThread") {
20 ui_message_loop_(ui_message_loop) {
21 } 19 }
22 20
23 ChromotingHostContext::~ChromotingHostContext() { 21 ChromotingHostContext::~ChromotingHostContext() {
24 } 22 }
25 23
26 void ChromotingHostContext::Start() { 24 void ChromotingHostContext::Start() {
27 // Start all the threads. 25 // Start all the threads.
28 main_thread_.Start(); 26 main_thread_.Start();
29 encode_thread_.Start(); 27 encode_thread_.Start();
30 jingle_thread_.Start(); 28 jingle_thread_.Start();
31 desktop_thread_.Start(); 29 desktop_thread_.Start();
32 } 30 }
33 31
34 void ChromotingHostContext::Stop() { 32 void ChromotingHostContext::Stop() {
35 // Stop all the threads. 33 // Stop all the threads.
36 jingle_thread_.Stop(); 34 jingle_thread_.Stop();
37 encode_thread_.Stop(); 35 encode_thread_.Stop();
38 main_thread_.Stop(); 36 main_thread_.Stop();
39 desktop_thread_.Stop(); 37 desktop_thread_.Stop();
40 } 38 }
41 39
42 JingleThread* ChromotingHostContext::jingle_thread() { 40 JingleThread* ChromotingHostContext::jingle_thread() {
43 return &jingle_thread_; 41 return &jingle_thread_;
44 } 42 }
45 43
46 base::MessageLoopProxy* ChromotingHostContext::ui_message_loop() {
47 return ui_message_loop_;
48 }
49
50 MessageLoop* ChromotingHostContext::main_message_loop() { 44 MessageLoop* ChromotingHostContext::main_message_loop() {
51 return main_thread_.message_loop(); 45 return main_thread_.message_loop();
52 } 46 }
53 47
54 MessageLoop* ChromotingHostContext::encode_message_loop() { 48 MessageLoop* ChromotingHostContext::encode_message_loop() {
55 return encode_thread_.message_loop(); 49 return encode_thread_.message_loop();
56 } 50 }
57 51
58 base::MessageLoopProxy* ChromotingHostContext::network_message_loop() { 52 base::MessageLoopProxy* ChromotingHostContext::network_message_loop() {
59 return jingle_thread_.message_loop_proxy(); 53 return jingle_thread_.message_loop_proxy();
60 } 54 }
61 55
62 MessageLoop* ChromotingHostContext::desktop_message_loop() { 56 MessageLoop* ChromotingHostContext::desktop_message_loop() {
63 return desktop_thread_.message_loop(); 57 return desktop_thread_.message_loop();
64 } 58 }
65 59
60 void ChromotingHostContext::SetUITaskPostFunction(
61 const UIThreadPostTaskFunction& poster) {
62 ui_poster_ = poster;
63 ui_main_thread_id_ = base::PlatformThread::CurrentId();
64 }
65
66 void ChromotingHostContext::PostTaskToUIThread(
67 const tracked_objects::Location& from_here, const base::Closure& task) {
68 ui_poster_.Run(from_here, task);
69 }
70
71 void ChromotingHostContext::PostDelayedTaskToUIThread(
72 const tracked_objects::Location& from_here,
73 const base::Closure& task,
74 int delay_ms) {
75 // Post delayed task on the main thread that will post task on UI
76 // thread. It is safe to use base::Unretained() here because
77 // ChromotingHostContext owns |main_thread_|.
78 main_message_loop()->PostDelayedTask(from_here, base::Bind(
79 &ChromotingHostContext::PostTaskToUIThread, base::Unretained(this),
80 from_here, task), delay_ms);
81 }
82
83 bool ChromotingHostContext::IsUIThread() const {
84 return ui_main_thread_id_ == base::PlatformThread::CurrentId();
85 }
86
66 } // namespace remoting 87 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/chromoting_host_context.h ('k') | remoting/host/chromoting_host_context_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698