diff options
Diffstat (limited to 'remoting/client/plugin')
-rw-r--r-- | remoting/client/plugin/chromoting_plugin.cc | 87 | ||||
-rw-r--r-- | remoting/client/plugin/chromoting_plugin.h | 14 | ||||
-rw-r--r-- | remoting/client/plugin/chromoting_plugin_unittest.cc | 13 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_input_handler.cc | 19 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_input_handler.h | 27 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_view.cc | 11 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_view.h | 4 |
7 files changed, 87 insertions, 88 deletions
diff --git a/remoting/client/plugin/chromoting_plugin.cc b/remoting/client/plugin/chromoting_plugin.cc index 160bf3a..bb1aa80 100644 --- a/remoting/client/plugin/chromoting_plugin.cc +++ b/remoting/client/plugin/chromoting_plugin.cc @@ -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(PP_Instance pp_instance) } 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 @@ bool ChromotingPlugin::Init(uint32_t argc, 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 @@ bool ChromotingPlugin::HandleEvent(const PP_Event& event) { 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 diff --git a/remoting/client/plugin/chromoting_plugin.h b/remoting/client/plugin/chromoting_plugin.h index 0aac051..3bd0470 100644 --- a/remoting/client/plugin/chromoting_plugin.h +++ b/remoting/client/plugin/chromoting_plugin.h @@ -34,7 +34,9 @@ class Module; namespace remoting { class ChromotingClient; +class ClientContext; class HostConnection; +class InputHandler; class JingleThread; class PepperView; @@ -56,11 +58,6 @@ class ChromotingPlugin : public pp::Instance { FRIEND_TEST(ChromotingPluginTest, ParseUrl); FRIEND_TEST(ChromotingPluginTest, TestCaseSetup); - static bool ParseUrl(const std::string& url, - std::string* user_id, - std::string* auth_token, - std::string* host_jid); - // Since we're an internal plugin, we can just grab the message loop during // init to figure out which thread we're on. This should only be used to // sanity check which thread we're executing on. Do not post task here! @@ -69,11 +66,14 @@ class ChromotingPlugin : public pp::Instance { // TODO(ajwong): Think if there is a better way to safeguard this. MessageLoop* pepper_main_loop_dont_post_to_me_; - scoped_ptr<base::Thread> main_thread_; - scoped_ptr<JingleThread> network_thread_; + scoped_ptr<ClientContext> context_; scoped_ptr<HostConnection> host_connection_; + scoped_ptr<PepperView> view_; + + scoped_ptr<InputHandler> input_handler_; + scoped_ptr<ChromotingClient> client_; DISALLOW_COPY_AND_ASSIGN(ChromotingPlugin); diff --git a/remoting/client/plugin/chromoting_plugin_unittest.cc b/remoting/client/plugin/chromoting_plugin_unittest.cc index edda0e3..2dc0358 100644 --- a/remoting/client/plugin/chromoting_plugin_unittest.cc +++ b/remoting/client/plugin/chromoting_plugin_unittest.cc @@ -17,17 +17,4 @@ class ChromotingPluginTest : public testing::Test { } }; -TEST_F(ChromotingPluginTest, ParseUrl) { - const char url[] = "chromotocol://hostid?user=auser&auth=someauth&jid=ajid"; - std::string user_id; - std::string auth_token; - std::string host_jid; - ASSERT_TRUE( - ChromotingPlugin::ParseUrl(url, &user_id, &auth_token, &host_jid)); - - EXPECT_EQ("auser", user_id); - EXPECT_EQ("someauth", auth_token); - EXPECT_EQ("ajid", host_jid); -} - } // namespace remoting diff --git a/remoting/client/plugin/pepper_input_handler.cc b/remoting/client/plugin/pepper_input_handler.cc new file mode 100644 index 0000000..53cced3 --- /dev/null +++ b/remoting/client/plugin/pepper_input_handler.cc @@ -0,0 +1,19 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "remoting/client/plugin/pepper_input_handler.h" + +namespace remoting { + +PepperInputHandler::PepperInputHandler() { +} + +PepperInputHandler::~PepperInputHandler() { +} + +void PepperInputHandler::Initialize() { + // TODO(garykac): Implement this. +} + +} // namespace remoting diff --git a/remoting/client/plugin/pepper_input_handler.h b/remoting/client/plugin/pepper_input_handler.h new file mode 100644 index 0000000..59399e9 --- /dev/null +++ b/remoting/client/plugin/pepper_input_handler.h @@ -0,0 +1,27 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef REMOTING_CLIENT_PLUGIN_PEPPER_INPUT_HANDLER_H_ +#define REMOTING_CLIENT_PLUGIN_PEPPER_INPUT_HANDLER_H_ + +#include "remoting/client/input_handler.h" + +namespace remoting { + +class PepperInputHandler : public InputHandler { + public: + PepperInputHandler(); + virtual ~PepperInputHandler(); + + void Initialize(); + + private: + DISALLOW_COPY_AND_ASSIGN(PepperInputHandler); +}; + +} // namespace remoting + +DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::PepperInputHandler); + +#endif // REMOTING_CLIENT_PLUGIN_PEPPER_INPUT_HANDLER_H_ diff --git a/remoting/client/plugin/pepper_view.cc b/remoting/client/plugin/pepper_view.cc index a6ebc13..ce38289 100644 --- a/remoting/client/plugin/pepper_view.cc +++ b/remoting/client/plugin/pepper_view.cc @@ -30,6 +30,13 @@ PepperView::PepperView(ChromotingPlugin* plugin) PepperView::~PepperView() { } +bool PepperView::Initialize() { + return true; +} + +void PepperView::TearDown() { +} + void PepperView::Paint() { if (!plugin_->CurrentlyOnPluginThread()) { RunTaskOnPluginThread(NewRunnableMethod(this, &PepperView::Paint)); @@ -118,10 +125,10 @@ void PepperView::SetViewport(int x, int y, int width, int height) { } } -void PepperView::SetBackingStoreSize(int width, int height) { +void PepperView::SetHostScreenSize(int width, int height) { if (!plugin_->CurrentlyOnPluginThread()) { RunTaskOnPluginThread(NewRunnableMethod(this, - &PepperView::SetBackingStoreSize, + &PepperView::SetHostScreenSize, width, height)); return; } diff --git a/remoting/client/plugin/pepper_view.h b/remoting/client/plugin/pepper_view.h index 655b9ae..3622ab3 100644 --- a/remoting/client/plugin/pepper_view.h +++ b/remoting/client/plugin/pepper_view.h @@ -37,11 +37,13 @@ class PepperView : public ChromotingView { virtual ~PepperView(); // ChromotingView implementation. + virtual bool Initialize(); + virtual void TearDown(); virtual void Paint(); virtual void SetSolidFill(uint32 color); virtual void UnsetSolidFill(); virtual void SetViewport(int x, int y, int width, int height); - virtual void SetBackingStoreSize(int width, int height); + virtual void SetHostScreenSize(int width, int height); virtual void HandleBeginUpdateStream(HostMessage* msg); virtual void HandleUpdateStreamPacket(HostMessage* msg); virtual void HandleEndUpdateStream(HostMessage* msg); |