summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-27 21:33:49 +0000
committerajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-27 21:33:49 +0000
commit1c085a63a3d62c0bf5043a8336dce0e9923917f8 (patch)
tree3909ce2a3a51ec2f5173d63c97952eed0a128313 /remoting
parent9e7fbfea4a79dbb7f3aa8e71f41b3ca4e40fe3b7 (diff)
downloadchromium_src-1c085a63a3d62c0bf5043a8336dce0e9923917f8.zip
chromium_src-1c085a63a3d62c0bf5043a8336dce0e9923917f8.tar.gz
chromium_src-1c085a63a3d62c0bf5043a8336dce0e9923917f8.tar.bz2
Change ClientConfig to be a struct since it's just a dumb data carrier.
Also, the old method of passing around a pointer was not safe due to object lifetime issues. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53851 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/client/chromoting_client.cc3
-rw-r--r--remoting/client/chromoting_client.h6
-rw-r--r--remoting/client/client_config.h22
-rw-r--r--remoting/client/client_util.cc12
-rw-r--r--remoting/client/client_util_unittest.cc9
-rw-r--r--remoting/client/host_connection.h2
-rw-r--r--remoting/client/jingle_host_connection.cc8
-rw-r--r--remoting/client/jingle_host_connection.h4
-rw-r--r--remoting/client/plugin/chromoting_plugin.cc2
-rw-r--r--remoting/client/x11_client.cc2
10 files changed, 27 insertions, 43 deletions
diff --git a/remoting/client/chromoting_client.cc b/remoting/client/chromoting_client.cc
index 7b77ee7..76f5b0c8 100644
--- a/remoting/client/chromoting_client.cc
+++ b/remoting/client/chromoting_client.cc
@@ -6,7 +6,6 @@
#include "base/message_loop.h"
#include "remoting/client/chromoting_view.h"
-#include "remoting/client/client_config.h"
#include "remoting/client/client_context.h"
#include "remoting/client/host_connection.h"
#include "remoting/client/input_handler.h"
@@ -17,7 +16,7 @@ static const uint32 kFailedColor = 0xffcc00ff;
namespace remoting {
-ChromotingClient::ChromotingClient(ClientConfig* config,
+ChromotingClient::ChromotingClient(const ClientConfig& config,
ClientContext* context,
HostConnection* connection,
ChromotingView* view,
diff --git a/remoting/client/chromoting_client.h b/remoting/client/chromoting_client.h
index 331c805..bdc2e26 100644
--- a/remoting/client/chromoting_client.h
+++ b/remoting/client/chromoting_client.h
@@ -9,20 +9,20 @@
#include "base/task.h"
#include "remoting/client/host_connection.h"
+#include "remoting/client/client_config.h"
class MessageLoop;
namespace remoting {
class ChromotingView;
-class ClientConfig;
class ClientContext;
class InputHandler;
class ChromotingClient : public HostConnection::HostEventCallback {
public:
// Objects passed in are not owned by this class.
- ChromotingClient(ClientConfig* config,
+ ChromotingClient(const ClientConfig& config,
ClientContext* context,
HostConnection* connection,
ChromotingView* view,
@@ -71,7 +71,7 @@ class ChromotingClient : public HostConnection::HostEventCallback {
void EndUpdate(HostMessage* msg);
// The following are not owned by this class.
- ClientConfig* config_;
+ ClientConfig config_;
ClientContext* context_;
HostConnection* connection_;
ChromotingView* view_;
diff --git a/remoting/client/client_config.h b/remoting/client/client_config.h
index a02d9e8..2546ae4 100644
--- a/remoting/client/client_config.h
+++ b/remoting/client/client_config.h
@@ -11,24 +11,10 @@
namespace remoting {
-class ClientConfig {
- public:
- ClientConfig() { }
-
- const std::string host_jid() { return host_jid_; }
- const std::string username() { return username_; }
- const std::string auth_token() { return auth_token_; }
-
- void set_host_jid(std::string val) { host_jid_ = val; }
- void set_username(std::string val) { username_ = val; }
- void set_auth_token(std::string val) { auth_token_ = val; }
-
- private:
- std::string host_jid_;
- std::string username_;
- std::string auth_token_;
-
- DISALLOW_COPY_AND_ASSIGN(ClientConfig);
+struct ClientConfig {
+ std::string host_jid;
+ std::string username;
+ std::string auth_token;
};
} // namespace remoting
diff --git a/remoting/client/client_util.cc b/remoting/client/client_util.cc
index 9e53682..215ae9c 100644
--- a/remoting/client/client_util.cc
+++ b/remoting/client/client_util.cc
@@ -72,9 +72,9 @@ bool GetLoginInfoFromArgs(int argc, char** argv, ClientConfig* config) {
return false;
}
- config->set_host_jid(host_jid);
- config->set_username(username);
- config->set_auth_token(auth_token);
+ config->host_jid = host_jid;
+ config->username = username;
+ config->auth_token = auth_token;
return true;
}
@@ -110,9 +110,9 @@ bool GetLoginInfoFromUrlParams(const std::string& url, ClientConfig* config) {
}
std::string host_jid = parts[2].substr(pos + 1);
- config->set_host_jid(host_jid);
- config->set_username(username);
- config->set_auth_token(auth_token);
+ config->host_jid = host_jid;
+ config->username = username;
+ config->auth_token = auth_token;
return true;
}
diff --git a/remoting/client/client_util_unittest.cc b/remoting/client/client_util_unittest.cc
index d9f2e7c..4277769 100644
--- a/remoting/client/client_util_unittest.cc
+++ b/remoting/client/client_util_unittest.cc
@@ -25,12 +25,11 @@ TEST_F(ClientUtilTest, GetLoginInfoFromUrlParams) {
std::string host_jid;
ClientConfig config;
- ASSERT_TRUE(
- GetLoginInfoFromUrlParams(url, &config));
+ ASSERT_TRUE(GetLoginInfoFromUrlParams(url, &config));
- EXPECT_EQ("auser", config.username());
- EXPECT_EQ("someauth", config.auth_token());
- EXPECT_EQ("ajid", config.host_jid());
+ EXPECT_EQ("auser", config.username);
+ EXPECT_EQ("someauth", config.auth_token);
+ EXPECT_EQ("ajid", config.host_jid);
}
} // namespace remoting
diff --git a/remoting/client/host_connection.h b/remoting/client/host_connection.h
index c53bc73..105cad3 100644
--- a/remoting/client/host_connection.h
+++ b/remoting/client/host_connection.h
@@ -39,7 +39,7 @@ class HostConnection {
virtual ~HostConnection() {}
// TODO(ajwong): We need to generalize this API.
- virtual void Connect(ClientConfig* config,
+ virtual void Connect(const ClientConfig& config,
HostEventCallback* event_callback) = 0;
virtual void Disconnect() = 0;
diff --git a/remoting/client/jingle_host_connection.cc b/remoting/client/jingle_host_connection.cc
index 2e1b0a1..27de426 100644
--- a/remoting/client/jingle_host_connection.cc
+++ b/remoting/client/jingle_host_connection.cc
@@ -18,7 +18,7 @@ JingleHostConnection::JingleHostConnection(ClientContext* context)
JingleHostConnection::~JingleHostConnection() {
}
-void JingleHostConnection::Connect(ClientConfig* config,
+void JingleHostConnection::Connect(const ClientConfig& config,
HostEventCallback* event_callback) {
message_loop()->PostTask(
FROM_HERE,
@@ -106,16 +106,16 @@ MessageLoop* JingleHostConnection::message_loop() {
return context_->jingle_thread()->message_loop();
}
-void JingleHostConnection::DoConnect(ClientConfig* config,
+void JingleHostConnection::DoConnect(const ClientConfig& config,
HostEventCallback* event_callback) {
DCHECK_EQ(message_loop(), MessageLoop::current());
event_callback_ = event_callback;
jingle_client_ = new JingleClient(context_->jingle_thread());
- jingle_client_->Init(config->username(), config->auth_token(),
+ jingle_client_->Init(config.username, config.auth_token,
kChromotingTokenServiceName, this);
- jingle_channel_ = jingle_client_->Connect(config->host_jid(), this);
+ jingle_channel_ = jingle_client_->Connect(config.host_jid, this);
}
void JingleHostConnection::DoDisconnect() {
diff --git a/remoting/client/jingle_host_connection.h b/remoting/client/jingle_host_connection.h
index 5fc75cb..c56c0df 100644
--- a/remoting/client/jingle_host_connection.h
+++ b/remoting/client/jingle_host_connection.h
@@ -41,7 +41,7 @@ class JingleHostConnection : public HostConnection,
explicit JingleHostConnection(ClientContext* context);
virtual ~JingleHostConnection();
- virtual void Connect(ClientConfig* config,
+ virtual void Connect(const ClientConfig& config,
HostEventCallback* event_callback);
virtual void Disconnect();
@@ -61,7 +61,7 @@ class JingleHostConnection : public HostConnection,
private:
MessageLoop* message_loop();
- void DoConnect(ClientConfig* config,
+ void DoConnect(const ClientConfig& config,
HostEventCallback* event_callback);
void DoDisconnect();
diff --git a/remoting/client/plugin/chromoting_plugin.cc b/remoting/client/plugin/chromoting_plugin.cc
index bb1aa80..af7321e 100644
--- a/remoting/client/plugin/chromoting_plugin.cc
+++ b/remoting/client/plugin/chromoting_plugin.cc
@@ -86,7 +86,7 @@ bool ChromotingPlugin::Init(uint32_t argc,
host_connection_.reset(new JingleHostConnection(context_.get()));
view_.reset(new PepperView(this));
input_handler_.reset(new PepperInputHandler());
- client_.reset(new ChromotingClient(&config,
+ client_.reset(new ChromotingClient(config,
context_.get(),
host_connection_.get(),
view_.get(),
diff --git a/remoting/client/x11_client.cc b/remoting/client/x11_client.cc
index 8d79f92..10d459c 100644
--- a/remoting/client/x11_client.cc
+++ b/remoting/client/x11_client.cc
@@ -32,7 +32,7 @@ int main(int argc, char** argv) {
remoting::JingleHostConnection connection(&context);
remoting::X11View view;
remoting::X11InputHandler input_handler(&context, &view);
- remoting::ChromotingClient client(&config, &context, &connection, &view,
+ remoting::ChromotingClient client(config, &context, &connection, &view,
&input_handler, NewRunnableFunction(&ClientQuit, &ui_loop));
// Run the client on a new MessageLoop until