summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-15 00:20:38 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-15 00:20:38 +0000
commit2a4f9884f3b47a5af5bac0703251efa77810986e (patch)
tree78a2cfaa1fb2f33d4b82ac166eef6f1206794e20
parentaa81a750d6898c19e2d820745670b04a6ba5f61a (diff)
downloadchromium_src-2a4f9884f3b47a5af5bac0703251efa77810986e.zip
chromium_src-2a4f9884f3b47a5af5bac0703251efa77810986e.tar.gz
chromium_src-2a4f9884f3b47a5af5bac0703251efa77810986e.tar.bz2
Cleanup some chromoting code
Renamed SimpleHost to ChromotingHost as it's not simple any more and it's becoming mature enough to be the main host implementation. Review URL: http://codereview.chromium.org/2722010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49748 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--remoting/host/chromoting_host.cc (renamed from remoting/host/simple_host.cc)37
-rw-r--r--remoting/host/chromoting_host.h (renamed from remoting/host/simple_host.h)14
-rw-r--r--remoting/host/simple_host_process.cc45
-rw-r--r--remoting/remoting.gyp4
4 files changed, 36 insertions, 64 deletions
diff --git a/remoting/host/simple_host.cc b/remoting/host/chromoting_host.cc
index ac83d85..f8abdb6 100644
--- a/remoting/host/simple_host.cc
+++ b/remoting/host/chromoting_host.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "remoting/host/simple_host.h"
+#include "remoting/host/chromoting_host.h"
#include "base/stl_util-inl.h"
#include "base/waitable_event.h"
@@ -14,7 +14,7 @@
namespace remoting {
-SimpleHost::SimpleHost(const std::string& username,
+ChromotingHost::ChromotingHost(const std::string& username,
const std::string& auth_token,
Capturer* capturer,
Encoder* encoder,
@@ -40,7 +40,7 @@ SimpleHost::SimpleHost(const std::string& username,
network_thread_.Start();
}
-SimpleHost::~SimpleHost() {
+ChromotingHost::~ChromotingHost() {
// TODO(ajwong): We really need to inject these threads and get rid of these
// start/stops.
main_thread_.Stop();
@@ -49,15 +49,16 @@ SimpleHost::~SimpleHost() {
DCHECK(!capture_thread_.IsRunning());
}
-void SimpleHost::Run() {
+void ChromotingHost::Run() {
// Submit a task to perform host registration. We'll also start
// listening to connection if registration is done.
- message_loop()->PostTask(FROM_HERE,
- NewRunnableMethod(this, &SimpleHost::RegisterHost));
+ message_loop()->PostTask(
+ FROM_HERE,
+ NewRunnableMethod(this, &ChromotingHost::RegisterHost));
}
// This method is called when we need to destroy the host process.
-void SimpleHost::DestroySession() {
+void ChromotingHost::DestroySession() {
DCHECK_EQ(message_loop(), MessageLoop::current());
// First we tell the session to pause and then we wait until all
@@ -76,7 +77,7 @@ void SimpleHost::DestroySession() {
// This method talks to the cloud to register the host process. If
// successful we will start listening to network requests.
-void SimpleHost::RegisterHost() {
+void ChromotingHost::RegisterHost() {
DCHECK_EQ(message_loop(), MessageLoop::current());
DCHECK(!jingle_client_);
@@ -87,7 +88,7 @@ void SimpleHost::RegisterHost() {
}
// This method is called if a client is connected to this object.
-void SimpleHost::OnClientConnected(ClientConnection* client) {
+void ChromotingHost::OnClientConnected(ClientConnection* client) {
DCHECK_EQ(message_loop(), MessageLoop::current());
// Create a new RecordSession if there was none.
@@ -119,7 +120,7 @@ void SimpleHost::OnClientConnected(ClientConnection* client) {
}
}
-void SimpleHost::OnClientDisconnected(ClientConnection* client) {
+void ChromotingHost::OnClientDisconnected(ClientConnection* client) {
DCHECK_EQ(message_loop(), MessageLoop::current());
// Remove the client from the session manager.
@@ -137,7 +138,7 @@ void SimpleHost::OnClientDisconnected(ClientConnection* client) {
////////////////////////////////////////////////////////////////////////////
// ClientConnection::EventHandler implementations
-void SimpleHost::HandleMessages(ClientConnection* client,
+void ChromotingHost::HandleMessages(ClientConnection* client,
ClientMessageList* messages) {
DCHECK_EQ(message_loop(), MessageLoop::current());
@@ -148,7 +149,7 @@ void SimpleHost::HandleMessages(ClientConnection* client,
STLDeleteElements<ClientMessageList>(messages);
}
-void SimpleHost::OnConnectionOpened(ClientConnection* client) {
+void ChromotingHost::OnConnectionOpened(ClientConnection* client) {
DCHECK_EQ(message_loop(), MessageLoop::current());
// Completes the client connection.
@@ -156,7 +157,7 @@ void SimpleHost::OnConnectionOpened(ClientConnection* client) {
OnClientConnected(client_.get());
}
-void SimpleHost::OnConnectionClosed(ClientConnection* client) {
+void ChromotingHost::OnConnectionClosed(ClientConnection* client) {
DCHECK_EQ(message_loop(), MessageLoop::current());
// Completes the client connection.
@@ -164,7 +165,7 @@ void SimpleHost::OnConnectionClosed(ClientConnection* client) {
OnClientDisconnected(client_.get());
}
-void SimpleHost::OnConnectionFailed(ClientConnection* client) {
+void ChromotingHost::OnConnectionFailed(ClientConnection* client) {
DCHECK_EQ(message_loop(), MessageLoop::current());
// The client has disconnected.
@@ -174,7 +175,7 @@ void SimpleHost::OnConnectionFailed(ClientConnection* client) {
////////////////////////////////////////////////////////////////////////////
// JingleClient::Callback implementations
-void SimpleHost::OnStateChange(JingleClient* jingle_client,
+void ChromotingHost::OnStateChange(JingleClient* jingle_client,
JingleClient::State state) {
DCHECK_EQ(jingle_client_.get(), jingle_client);
@@ -196,7 +197,7 @@ void SimpleHost::OnStateChange(JingleClient* jingle_client,
}
}
-bool SimpleHost::OnAcceptConnection(
+bool ChromotingHost::OnAcceptConnection(
JingleClient* jingle_client, const std::string& jid,
JingleChannel::Callback** channel_callback) {
DCHECK_EQ(jingle_client_.get(), jingle_client);
@@ -214,7 +215,7 @@ bool SimpleHost::OnAcceptConnection(
return true;
}
-void SimpleHost::OnNewConnection(JingleClient* jingle_client,
+void ChromotingHost::OnNewConnection(JingleClient* jingle_client,
scoped_refptr<JingleChannel> channel) {
DCHECK_EQ(jingle_client_.get(), jingle_client);
@@ -224,7 +225,7 @@ void SimpleHost::OnNewConnection(JingleClient* jingle_client,
client_->set_jingle_channel(channel);
}
-MessageLoop* SimpleHost::message_loop() {
+MessageLoop* ChromotingHost::message_loop() {
return main_thread_.message_loop();
}
diff --git a/remoting/host/simple_host.h b/remoting/host/chromoting_host.h
index 858a7bb..463d03c 100644
--- a/remoting/host/simple_host.h
+++ b/remoting/host/chromoting_host.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef REMOTING_SIMPLE_HOST_H_
-#define REMOTING_SIMPLE_HOST_H_
+#ifndef REMOTING_CHROMOTING_HOST_H_
+#define REMOTING_CHROMOTING_HOST_H_
#include <string>
@@ -48,14 +48,14 @@ namespace remoting {
// all pending tasks to complete. After all of that completed we
// return to the idle state. We then go to step (2) if there a new
// incoming connection.
-class SimpleHost : public base::RefCountedThreadSafe<SimpleHost>,
+class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>,
public ClientConnection::EventHandler,
public JingleClient::Callback {
public:
- SimpleHost(const std::string& username, const std::string& auth_token,
+ ChromotingHost(const std::string& username, const std::string& auth_token,
Capturer* capturer, Encoder* encoder, EventExecutor* executor,
base::WaitableEvent* host_done);
- virtual ~SimpleHost();
+ virtual ~ChromotingHost();
// Run the host porcess. This method returns only after the message loop
// of the host process exits.
@@ -139,9 +139,9 @@ class SimpleHost : public base::RefCountedThreadSafe<SimpleHost>,
// Signals the host is ready to be destroyed.
base::WaitableEvent* host_done_;
- DISALLOW_COPY_AND_ASSIGN(SimpleHost);
+ DISALLOW_COPY_AND_ASSIGN(ChromotingHost);
};
} // namespace remoting
-#endif // REMOTING_HOST_SIMPLE_HOST_H_
+#endif // REMOTING_HOST_CHROMOTING_HOST_H_
diff --git a/remoting/host/simple_host_process.cc b/remoting/host/simple_host_process.cc
index 79db106..d32547f 100644
--- a/remoting/host/simple_host_process.cc
+++ b/remoting/host/simple_host_process.cc
@@ -25,7 +25,7 @@
#include "base/waitable_event.h"
#include "remoting/host/capturer_fake.h"
#include "remoting/host/encoder_verbatim.h"
-#include "remoting/host/simple_host.h"
+#include "remoting/host/chromoting_host.h"
#if defined(OS_WIN)
#include "remoting/host/capturer_gdi.h"
@@ -38,35 +38,6 @@
#include "remoting/host/event_executor_mac.h"
#endif
-void SetConsoleEcho(bool on) {
-#if defined(OS_WIN)
- HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
- if ((hIn == INVALID_HANDLE_VALUE) || (hIn == NULL))
- return;
-
- DWORD mode;
- if (!GetConsoleMode(hIn, &mode))
- return;
-
- if (on) {
- mode = mode | ENABLE_ECHO_INPUT;
- } else {
- mode = mode & ~ENABLE_ECHO_INPUT;
- }
-
- SetConsoleMode(hIn, mode);
-#elif defined(OS_POSIX)
- struct termios settings;
- tcgetattr(STDIN_FILENO, &settings);
- if (on) {
- settings.c_lflag |= ECHO;
- } else {
- settings.c_lflag &= ~ECHO;
- }
- tcsetattr(STDIN_FILENO, TCSANOW, &settings);
-#endif // defined(OS_WIN)
-}
-
int main(int argc, char** argv) {
base::AtExitManager exit_manager;
@@ -131,15 +102,15 @@ int main(int argc, char** argv) {
capturer.reset(new remoting::CapturerFake());
}
- // Construct a simple host with username and auth_token.
+ // Construct a chromoting host with username and auth_token.
// TODO(hclam): Allow the host to load saved credentials.
base::WaitableEvent host_done(false, false);
- scoped_refptr<remoting::SimpleHost> host
- = new remoting::SimpleHost(username, auth_token,
- capturer.release(),
- encoder.release(),
- executor.release(),
- &host_done);
+ scoped_refptr<remoting::ChromotingHost> host
+ = new remoting::ChromotingHost(username, auth_token,
+ capturer.release(),
+ encoder.release(),
+ executor.release(),
+ &host_done);
host->Run();
host_done.Wait();
return 0;
diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp
index 890f142..0f203a8 100644
--- a/remoting/remoting.gyp
+++ b/remoting/remoting.gyp
@@ -165,6 +165,8 @@
'sources': [
'host/capturer.cc',
'host/capturer.h',
+ 'host/chromoting_host.cc',
+ 'host/chromoting_host.h',
'host/client_connection.cc',
'host/client_connection.h',
'host/differ.h',
@@ -180,8 +182,6 @@
'host/event_executor.h',
'host/session_manager.cc',
'host/session_manager.h',
- 'host/simple_host.cc',
- 'host/simple_host.h',
'host/heartbeat_sender.cc',
'host/heartbeat_sender.h',
],