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

Unified Diff: remoting/client/plugin/chromoting_plugin.cc

Issue 2861047: Refactor the client code. Move all x11-related code into X11View and create... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: remoting/client/plugin/chromoting_plugin.cc
===================================================================
--- remoting/client/plugin/chromoting_plugin.cc (revision 52921)
+++ remoting/client/plugin/chromoting_plugin.cc (working copy)
@@ -10,18 +10,18 @@
#include "base/message_loop.h"
#include "base/string_util.h"
#include "base/thread.h"
+#include "remoting/client/client_config.h"
+#include "remoting/client/client_util.h"
#include "remoting/client/chromoting_client.h"
#include "remoting/client/host_connection.h"
#include "remoting/client/jingle_host_connection.h"
+#include "remoting/client/plugin/pepper_input_handler.h"
#include "remoting/client/plugin/pepper_view.h"
#include "remoting/jingle_glue/jingle_thread.h"
#include "third_party/ppapi/c/pp_event.h"
#include "third_party/ppapi/c/pp_rect.h"
#include "third_party/ppapi/cpp/completion_callback.h"
-using std::string;
-using std::vector;
-
namespace remoting {
const char* ChromotingPlugin::kMimeType = "pepper-application/x-chromoting";
@@ -32,18 +32,17 @@
}
ChromotingPlugin::~ChromotingPlugin() {
- if (host_connection_.get())
- host_connection_->Disconnect();
+ if (client_.get()) {
+ client_->Stop();
+ }
// TODO(ajwong): We need to ensure all objects have actually stopped posting
// to the message loop before this point. Right now, we don't have a well
// defined stop for the plugin process, and the thread shutdown is likely a
// race condition.
- if (network_thread_.get())
- network_thread_->Stop();
-
- if (main_thread_.get())
- main_thread_->Stop();
+ if (context_.get()) {
+ context_->Stop();
+ }
}
bool ChromotingPlugin::Init(uint32_t argc,
@@ -77,34 +76,29 @@
return false;
}
- string user_id;
- string auth_token;
- string host_jid;
- if (!ParseUrl(url, &user_id, &auth_token, &host_jid)) {
+ ClientConfig config;
+ if (!GetLoginInfoFromUrlParams(url, &config)) {
LOG(WARNING) << "Could not parse URL: " << url;
return false;
}
- // Start the threads.
- main_thread_.reset(new base::Thread("ChromoClientMain"));
- if (!main_thread_->Start()) {
- LOG(ERROR) << "Main thread failed to start.";
- return false;
- }
- network_thread_.reset(new JingleThread());
- network_thread_->Start();
-
- // Create the chromting objects.
- host_connection_.reset(new JingleHostConnection(network_thread_.get()));
+ // Create the chromoting objects.
+ host_connection_.reset(new JingleHostConnection(context_.get()));
view_.reset(new PepperView(this));
- client_.reset(new ChromotingClient(main_thread_->message_loop(),
- host_connection_.get(), view_.get()));
+ input_handler_.reset(new PepperInputHandler());
+ client_.reset(new ChromotingClient(&config,
+ context_.get(),
+ host_connection_.get(),
+ view_.get(),
+ input_handler_.get(),
+ NULL));
// Default to a medium grey.
view_->SetSolidFill(0xFFCDCDCD);
// Kick off the connection.
- host_connection_->Connect(user_id, auth_token, host_jid, client_.get());
+ context_->Start();
+ client_->Start();
return true;
}
@@ -153,41 +147,4 @@
return false;
}
-bool ChromotingPlugin::ParseUrl(const std::string& url,
- string* user_id,
- string* auth_token,
- string* host_jid) {
- // TODO(ajwong): We should use GURL or something. Don't parse this by hand!
-
- // The Url should be of the form:
- //
- // chromotocol://<hostid>?user=<userid>&auth=<authtoken>&jid=<hostjid>
- //
- vector<string> parts;
- SplitString(url, '&', &parts);
- if (parts.size() != 3) {
- return false;
- }
-
- size_t pos = parts[0].rfind('=');
- if (pos == string::npos && (pos + 1) != string::npos) {
- return false;
- }
- user_id->assign(parts[0].substr(pos + 1));
-
- pos = parts[1].rfind('=');
- if (pos == string::npos && (pos + 1) != string::npos) {
- return false;
- }
- auth_token->assign(parts[1].substr(pos + 1));
-
- pos = parts[2].rfind('=');
- if (pos == string::npos && (pos + 1) != string::npos) {
- return false;
- }
- host_jid->assign(parts[2].substr(pos + 1));
-
- return true;
-}
-
} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698