summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-23 02:41:31 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-23 02:41:31 +0000
commitcb68c0239fd762b3984623a9d1064299334061b0 (patch)
tree7d7eb1feca6bd65ddaf33c0a3e605578845bfccf /remoting
parent51f1b9d4c685f0e4de67023c07476fb471cd4014 (diff)
downloadchromium_src-cb68c0239fd762b3984623a9d1064299334061b0.zip
chromium_src-cb68c0239fd762b3984623a9d1064299334061b0.tar.gz
chromium_src-cb68c0239fd762b3984623a9d1064299334061b0.tar.bz2
Rename ChromotingView to ClientUserInterface. Clean it up.
ChromotingView wasn't really doing what it was initially meant to do, now FrameProducer and FrameConsumer interfaces are used to process video stream. Renamed and simplified that interface. Also moved implementation from PepperView to ChromotingInstance. Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=147595 Review URL: https://chromiumcodereview.appspot.com/10703144 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147828 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/client/chromoting_client.cc16
-rw-r--r--remoting/client/chromoting_client.h6
-rw-r--r--remoting/client/client_user_interface.h (renamed from remoting/client/chromoting_view.h)28
-rw-r--r--remoting/client/plugin/chromoting_instance.cc190
-rw-r--r--remoting/client/plugin/chromoting_instance.h45
-rw-r--r--remoting/client/plugin/pepper_view.cc102
-rw-r--r--remoting/client/plugin/pepper_view.h17
-rw-r--r--remoting/protocol/connection_to_host.cc4
-rw-r--r--remoting/protocol/connection_to_host.h1
-rw-r--r--remoting/remoting.gyp2
10 files changed, 158 insertions, 253 deletions
diff --git a/remoting/client/chromoting_client.cc b/remoting/client/chromoting_client.cc
index 9d9df67..e77c53a 100644
--- a/remoting/client/chromoting_client.cc
+++ b/remoting/client/chromoting_client.cc
@@ -6,8 +6,8 @@
#include "base/bind.h"
#include "remoting/client/audio_player.h"
-#include "remoting/client/chromoting_view.h"
#include "remoting/client/client_context.h"
+#include "remoting/client/client_user_interface.h"
#include "remoting/client/rectangle_update_decoder.h"
#include "remoting/proto/audio.pb.h"
#include "remoting/proto/video.pb.h"
@@ -33,13 +33,13 @@ ChromotingClient::ChromotingClient(
const ClientConfig& config,
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
protocol::ConnectionToHost* connection,
- ChromotingView* view,
+ ClientUserInterface* user_interface,
RectangleUpdateDecoder* rectangle_decoder,
AudioPlayer* audio_player)
: config_(config),
task_runner_(task_runner),
connection_(connection),
- view_(view),
+ user_interface_(user_interface),
rectangle_decoder_(rectangle_decoder),
audio_player_(audio_player),
packet_being_processed_(false),
@@ -66,8 +66,6 @@ void ChromotingClient::Start(
connection_->Connect(xmpp_proxy, config_.local_jid, config_.host_jid,
config_.host_public_key, transport_factory.Pass(),
authenticator.Pass(), this, this, this, this, this);
-
- view_->Initialize();
}
void ChromotingClient::Stop(const base::Closure& shutdown_task) {
@@ -85,8 +83,6 @@ void ChromotingClient::Stop(const base::Closure& shutdown_task) {
}
void ChromotingClient::OnDisconnected(const base::Closure& shutdown_task) {
- view_->TearDown();
-
shutdown_task.Run();
}
@@ -98,12 +94,12 @@ ChromotingStats* ChromotingClient::GetStats() {
void ChromotingClient::InjectClipboardEvent(
const protocol::ClipboardEvent& event) {
DCHECK(task_runner_->BelongsToCurrentThread());
- view_->GetClipboardStub()->InjectClipboardEvent(event);
+ user_interface_->GetClipboardStub()->InjectClipboardEvent(event);
}
void ChromotingClient::SetCursorShape(
const protocol::CursorShapeInfo& cursor_shape) {
- view_->GetCursorShapeStub()->SetCursorShape(cursor_shape);
+ user_interface_->GetCursorShapeStub()->SetCursorShape(cursor_shape);
}
void ChromotingClient::ProcessVideoPacket(scoped_ptr<VideoPacket> packet,
@@ -185,7 +181,7 @@ void ChromotingClient::OnConnectionState(
VLOG(1) << "ChromotingClient::OnConnectionState(" << state << ")";
if (state == protocol::ConnectionToHost::CONNECTED)
Initialize();
- view_->SetConnectionState(state, error);
+ user_interface_->OnConnectionState(state, error);
}
void ChromotingClient::OnPacketDone(bool last_packet,
diff --git a/remoting/client/chromoting_client.h b/remoting/client/chromoting_client.h
index d15073f..d68ae3b 100644
--- a/remoting/client/chromoting_client.h
+++ b/remoting/client/chromoting_client.h
@@ -15,7 +15,6 @@
#include "base/time.h"
#include "remoting/client/client_config.h"
#include "remoting/client/chromoting_stats.h"
-#include "remoting/client/chromoting_view.h"
#include "remoting/protocol/audio_stub.h"
#include "remoting/protocol/client_stub.h"
#include "remoting/protocol/clipboard_stub.h"
@@ -35,6 +34,7 @@ class TransportFactory;
} // namespace protocol
class AudioPlayer;
+class ClientUserInterface;
class RectangleUpdateDecoder;
// TODO(sergeyu): Move VideoStub implementation to RectangleUpdateDecoder.
@@ -47,7 +47,7 @@ class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback,
ChromotingClient(const ClientConfig& config,
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
protocol::ConnectionToHost* connection,
- ChromotingView* view,
+ ClientUserInterface* user_interface,
RectangleUpdateDecoder* rectangle_decoder,
AudioPlayer* audio_player);
@@ -110,7 +110,7 @@ class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback,
ClientConfig config_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
protocol::ConnectionToHost* connection_;
- ChromotingView* view_;
+ ClientUserInterface* user_interface_;
RectangleUpdateDecoder* rectangle_decoder_;
AudioPlayer* audio_player_;
diff --git a/remoting/client/chromoting_view.h b/remoting/client/client_user_interface.h
index 1035d3c..e6498fb 100644
--- a/remoting/client/chromoting_view.h
+++ b/remoting/client/client_user_interface.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_CLIENT_CHROMOTING_VIEW_H_
-#define REMOTING_CLIENT_CHROMOTING_VIEW_H_
+#ifndef REMOTING_CLIENT_CLIENT_USER_INTERFACE_H_
+#define REMOTING_CLIENT_CLIENT_USER_INTERFACE_H_
#include "base/basictypes.h"
#include "remoting/protocol/connection_to_host.h"
@@ -15,22 +15,18 @@ class ClipboardStub;
class CursorShapeStub;
} // namespace protocol
-// ChromotingView defines the behavior of an object that draws a view of the
-// remote desktop. Its main function is to render the update stream onto the
-// screen.
-class ChromotingView {
+// ClientUserInterface is an interface that must be implemented by
+// applications embedding the Chromoting client, to provide client's user
+// interface.
+//
+// TODO(sergeyu): Cleanup this interface, see crbug.com/138108 .
+class ClientUserInterface {
public:
- virtual ~ChromotingView() {}
-
- // Initialize the common structures for the view.
- virtual bool Initialize() = 0;
-
- // Free up resources allocated by this view.
- virtual void TearDown() = 0;
+ virtual ~ClientUserInterface() {}
// Record the update the state of the connection, updating the UI as needed.
- virtual void SetConnectionState(protocol::ConnectionToHost::State state,
- protocol::ErrorCode error) = 0;
+ virtual void OnConnectionState(protocol::ConnectionToHost::State state,
+ protocol::ErrorCode error) = 0;
// Get the view's ClipboardStub implementation.
virtual protocol::ClipboardStub* GetClipboardStub() = 0;
@@ -41,4 +37,4 @@ class ChromotingView {
} // namespace remoting
-#endif // REMOTING_CLIENT_CHROMOTING_VIEW_H_
+#endif // REMOTING_CLIENT_CLIENT_USER_INTERFACE_H_
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc
index ea212b2..c1eeee3 100644
--- a/remoting/client/plugin/chromoting_instance.cc
+++ b/remoting/client/plugin/chromoting_instance.cc
@@ -57,40 +57,57 @@ const int kBytesPerPixel = 4;
const int kPerfStatsIntervalMs = 1000;
-std::string ConnectionStateToString(ChromotingInstance::ConnectionState state) {
+std::string ConnectionStateToString(protocol::ConnectionToHost::State state) {
+ // Values returned by this function must match the
+ // remoting.ClientSession.State enum in JS code.
switch (state) {
- case ChromotingInstance::STATE_CONNECTING:
- return "CONNECTING";
- case ChromotingInstance::STATE_INITIALIZING:
+ case protocol::ConnectionToHost::INITIALIZING:
return "INITIALIZING";
- case ChromotingInstance::STATE_CONNECTED:
+ case protocol::ConnectionToHost::CONNECTING:
+ return "CONNECTING";
+ case protocol::ConnectionToHost::CONNECTED:
return "CONNECTED";
- case ChromotingInstance::STATE_CLOSED:
+ case protocol::ConnectionToHost::CLOSED:
return "CLOSED";
- case ChromotingInstance::STATE_FAILED:
+ case protocol::ConnectionToHost::FAILED:
return "FAILED";
}
NOTREACHED();
return "";
}
-std::string ConnectionErrorToString(ChromotingInstance::ConnectionError error) {
+// TODO(sergeyu): Ideally we should just pass ErrorCode to the webapp
+// and let it handle it, but it would be hard to fix it now because
+// client plugin and webapp versions may not be in sync. It should be
+// easy to do after we are finished moving the client plugin to NaCl.
+std::string ConnectionErrorToString(protocol::ErrorCode error) {
+ // Values returned by this function must match the
+ // remoting.ClientSession.Error enum in JS code.
switch (error) {
- case ChromotingInstance::ERROR_NONE:
+ case protocol::OK:
return "NONE";
- case ChromotingInstance::ERROR_HOST_IS_OFFLINE:
+
+ case protocol::PEER_IS_OFFLINE:
return "HOST_IS_OFFLINE";
- case ChromotingInstance::ERROR_SESSION_REJECTED:
+
+ case protocol::SESSION_REJECTED:
+ case protocol::AUTHENTICATION_FAILED:
return "SESSION_REJECTED";
- case ChromotingInstance::ERROR_INCOMPATIBLE_PROTOCOL:
+
+ case protocol::INCOMPATIBLE_PROTOCOL:
return "INCOMPATIBLE_PROTOCOL";
- case ChromotingInstance::ERROR_NETWORK_FAILURE:
- return "NETWORK_FAILURE";
- case ChromotingInstance::ERROR_HOST_OVERLOAD:
+
+ case protocol::HOST_OVERLOAD:
return "HOST_OVERLOAD";
+
+ case protocol::CHANNEL_CONNECTION_ERROR:
+ case protocol::SIGNALING_ERROR:
+ case protocol::SIGNALING_TIMEOUT:
+ case protocol::UNKNOWN_ERROR:
+ return "NETWORK_FAILURE";
}
- NOTREACHED();
- return "";
+ DLOG(FATAL) << "Unknown error code" << error;
+ return "";
}
// This flag blocks LOGs to the UI if we're already in the middle of logging
@@ -160,6 +177,9 @@ ChromotingInstance::~ChromotingInstance() {
// to it. This will stop all logging in all Chromoting instances.
UnregisterLoggingInstance();
+ // PepperView must be destroyed before the client.
+ view_.reset();
+
if (client_.get()) {
base::WaitableEvent done_event(true, false);
client_->Stop(base::Bind(&base::WaitableEvent::Signal,
@@ -364,15 +384,81 @@ void ChromotingInstance::SetDesktopSize(const SkISize& size,
PostChromotingMessage("onDesktopSize", data.Pass());
}
-void ChromotingInstance::SetConnectionState(
- ConnectionState state,
- ConnectionError error) {
+void ChromotingInstance::OnConnectionState(
+ protocol::ConnectionToHost::State state,
+ protocol::ErrorCode error) {
scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
data->SetString("state", ConnectionStateToString(state));
data->SetString("error", ConnectionErrorToString(error));
PostChromotingMessage("onConnectionStatus", data.Pass());
}
+protocol::ClipboardStub* ChromotingInstance::GetClipboardStub() {
+ // TODO(sergeyu): Move clipboard handling to a separate class.
+ // crbug.com/138108
+ return this;
+}
+
+protocol::CursorShapeStub* ChromotingInstance::GetCursorShapeStub() {
+ // TODO(sergeyu): Move cursor shape code to a separate class.
+ // crbug.com/138108
+ return this;
+}
+
+void ChromotingInstance::InjectClipboardEvent(
+ const protocol::ClipboardEvent& event) {
+ scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
+ data->SetString("mimeType", event.mime_type());
+ data->SetString("item", event.data());
+ PostChromotingMessage("injectClipboardItem", data.Pass());
+}
+
+void ChromotingInstance::SetCursorShape(
+ const protocol::CursorShapeInfo& cursor_shape) {
+ if (!cursor_shape.has_data() ||
+ !cursor_shape.has_width() ||
+ !cursor_shape.has_height() ||
+ !cursor_shape.has_hotspot_x() ||
+ !cursor_shape.has_hotspot_y()) {
+ return;
+ }
+
+ if (pp::ImageData::GetNativeImageDataFormat() !=
+ PP_IMAGEDATAFORMAT_BGRA_PREMUL) {
+ VLOG(2) << "Unable to set cursor shape - non-native image format";
+ return;
+ }
+
+ int width = cursor_shape.width();
+ int height = cursor_shape.height();
+
+ if (width > 32 || height > 32) {
+ VLOG(2) << "Cursor too large for SetCursor: "
+ << width << "x" << height << " > 32x32";
+ return;
+ }
+
+ int hotspot_x = cursor_shape.hotspot_x();
+ int hotspot_y = cursor_shape.hotspot_y();
+
+ pp::ImageData cursor_image(this, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::Size(width, height), false);
+
+ int bytes_per_row = width * kBytesPerPixel;
+ const uint8* src_row_data = reinterpret_cast<const uint8*>(
+ cursor_shape.data().data());
+ uint8* dst_row_data = reinterpret_cast<uint8*>(cursor_image.data());
+ for (int row = 0; row < height; row++) {
+ memcpy(dst_row_data, src_row_data, bytes_per_row);
+ src_row_data += bytes_per_row;
+ dst_row_data += cursor_image.stride();
+ }
+
+ pp::MouseCursor::SetCursor(this, PP_MOUSECURSOR_TYPE_CUSTOM,
+ cursor_image,
+ pp::Point(hotspot_x, hotspot_y));
+}
+
void ChromotingInstance::OnFirstFrameReceived() {
scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
PostChromotingMessage("onFirstFrameReceived", data.Pass());
@@ -385,7 +471,7 @@ void ChromotingInstance::Connect(const ClientConfig& config) {
host_connection_.reset(new protocol::ConnectionToHost(true));
client_.reset(new ChromotingClient(config, context_.main_task_runner(),
- host_connection_.get(), view_.get(),
+ host_connection_.get(), this,
rectangle_decoder_.get(),
audio_player_.get()));
@@ -428,14 +514,14 @@ void ChromotingInstance::Connect(const ClientConfig& config) {
plugin_message_loop_->PostDelayedTask(
FROM_HERE, base::Bind(&ChromotingInstance::SendPerfStats, AsWeakPtr()),
base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs));
-
- VLOG(1) << "Connection status: Initializing";
- SetConnectionState(STATE_INITIALIZING, ERROR_NONE);
}
void ChromotingInstance::Disconnect() {
DCHECK(plugin_message_loop_->BelongsToCurrentThread());
+ // PepperView must be destroyed before the client.
+ view_.reset();
+
LOG(INFO) << "Disconnecting from host.";
if (client_.get()) {
// TODO(sergeyu): Should we disconnect asynchronously?
@@ -450,8 +536,6 @@ void ChromotingInstance::Disconnect() {
input_tracker_.reset();
mouse_input_filter_.reset();
host_connection_.reset();
-
- SetConnectionState(STATE_CLOSED, ERROR_NONE);
}
void ChromotingInstance::OnIncomingIq(const std::string& iq) {
@@ -560,60 +644,6 @@ void ChromotingInstance::SendPerfStats() {
PostChromotingMessage("onPerfStats", data.Pass());
}
-void ChromotingInstance::InjectClipboardEvent(
- const protocol::ClipboardEvent& event) {
- scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
- data->SetString("mimeType", event.mime_type());
- data->SetString("item", event.data());
- PostChromotingMessage("injectClipboardItem", data.Pass());
-}
-
-void ChromotingInstance::SetCursorShape(
- const protocol::CursorShapeInfo& cursor_shape) {
- if (!cursor_shape.has_data() ||
- !cursor_shape.has_width() ||
- !cursor_shape.has_height() ||
- !cursor_shape.has_hotspot_x() ||
- !cursor_shape.has_hotspot_y()) {
- return;
- }
-
- if (pp::ImageData::GetNativeImageDataFormat() !=
- PP_IMAGEDATAFORMAT_BGRA_PREMUL) {
- VLOG(2) << "Unable to set cursor shape - non-native image format";
- return;
- }
-
- int width = cursor_shape.width();
- int height = cursor_shape.height();
-
- if (width > 32 || height > 32) {
- VLOG(2) << "Cursor too large for SetCursor: "
- << width << "x" << height << " > 32x32";
- return;
- }
-
- int hotspot_x = cursor_shape.hotspot_x();
- int hotspot_y = cursor_shape.hotspot_y();
-
- pp::ImageData cursor_image(this, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
- pp::Size(width, height), false);
-
- int bytes_per_row = width * kBytesPerPixel;
- const uint8* src_row_data = reinterpret_cast<const uint8*>(
- cursor_shape.data().data());
- uint8* dst_row_data = reinterpret_cast<uint8*>(cursor_image.data());
- for (int row = 0; row < height; row++) {
- memcpy(dst_row_data, src_row_data, bytes_per_row);
- src_row_data += bytes_per_row;
- dst_row_data += cursor_image.stride();
- }
-
- pp::MouseCursor::SetCursor(this, PP_MOUSECURSOR_TYPE_CUSTOM,
- cursor_image,
- pp::Point(hotspot_x, hotspot_y));
-}
-
// static
void ChromotingInstance::RegisterLogMessageHandler() {
base::AutoLock lock(g_logging_lock.Get());
diff --git a/remoting/client/plugin/chromoting_instance.h b/remoting/client/plugin/chromoting_instance.h
index c00f57b..baa98bf 100644
--- a/remoting/client/plugin/chromoting_instance.h
+++ b/remoting/client/plugin/chromoting_instance.h
@@ -28,13 +28,14 @@
#include "ppapi/cpp/instance.h"
#include "remoting/client/client_context.h"
+#include "remoting/client/client_user_interface.h"
#include "remoting/client/key_event_mapper.h"
#include "remoting/client/plugin/mac_key_event_processor.h"
#include "remoting/client/plugin/pepper_plugin_thread_delegate.h"
#include "remoting/proto/event.pb.h"
#include "remoting/protocol/clipboard_stub.h"
-#include "remoting/protocol/cursor_shape_stub.h"
#include "remoting/protocol/connection_to_host.h"
+#include "remoting/protocol/cursor_shape_stub.h"
namespace base {
class DictionaryValue;
@@ -48,7 +49,6 @@ class Module;
namespace remoting {
namespace protocol {
-class ConnectionToHost;
class InputEventTracker;
class MouseInputFilter;
} // namespace protocol
@@ -66,32 +66,12 @@ class RectangleUpdateDecoder;
struct ClientConfig;
class ChromotingInstance :
+ public ClientUserInterface,
public protocol::ClipboardStub,
public protocol::CursorShapeStub,
public pp::Instance,
public base::SupportsWeakPtr<ChromotingInstance> {
public:
- // These state values are duplicated in the JS code. Remember to
- // update both copies when making changes.
- enum ConnectionState {
- STATE_CONNECTING = 1,
- STATE_INITIALIZING,
- STATE_CONNECTED,
- STATE_CLOSED,
- STATE_FAILED,
- };
-
- // These values are duplicated in the JS code. Remember to update
- // both copies when making changes.
- enum ConnectionError {
- ERROR_NONE = 0,
- ERROR_HOST_IS_OFFLINE,
- ERROR_SESSION_REJECTED,
- ERROR_INCOMPATIBLE_PROTOCOL,
- ERROR_NETWORK_FAILURE,
- ERROR_HOST_OVERLOAD,
- };
-
// Plugin API version. This should be incremented whenever the API
// interface changes.
static const int kApiVersion = 7;
@@ -125,17 +105,22 @@ class ChromotingInstance :
virtual void HandleMessage(const pp::Var& message) OVERRIDE;
virtual bool HandleInputEvent(const pp::InputEvent& event) OVERRIDE;
- // ClipboardStub implementation.
- virtual void InjectClipboardEvent(const protocol::ClipboardEvent& event)
- OVERRIDE;
+ // ClientUserInterface interface.
+ virtual void OnConnectionState(protocol::ConnectionToHost::State state,
+ protocol::ErrorCode error) OVERRIDE;
+ virtual protocol::ClipboardStub* GetClipboardStub() OVERRIDE;
+ virtual protocol::CursorShapeStub* GetCursorShapeStub() OVERRIDE;
+
+ // protocol::ClipboardStub interface.
+ virtual void InjectClipboardEvent(
+ const protocol::ClipboardEvent& event) OVERRIDE;
- // CursorShapeStub implementation.
- virtual void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape)
- OVERRIDE;
+ // protocol::CursorShapeStub interface.
+ virtual void SetCursorShape(
+ const protocol::CursorShapeInfo& cursor_shape) OVERRIDE;
// Called by PepperView.
void SetDesktopSize(const SkISize& size, const SkIPoint& dpi);
- void SetConnectionState(ConnectionState state, ConnectionError error);
void OnFirstFrameReceived();
// Message handlers for messages that come from JavaScript. Called
diff --git a/remoting/client/plugin/pepper_view.cc b/remoting/client/plugin/pepper_view.cc
index 0d19b88..b86af03 100644
--- a/remoting/client/plugin/pepper_view.cc
+++ b/remoting/client/plugin/pepper_view.cc
@@ -8,6 +8,7 @@
#include "base/message_loop.h"
#include "base/string_util.h"
+#include "base/time.h"
#include "base/synchronization/waitable_event.h"
#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/graphics_2d.h"
@@ -31,39 +32,6 @@ namespace {
// The maximum number of image buffers to be allocated at any point of time.
const size_t kMaxPendingBuffersCount = 2;
-// TODO(sergeyu): Ideally we should just pass ErrorCode to the webapp
-// and let it handle it, but it would be hard to fix it now because
-// client plugin and webapp versions may not be in sync. It should be
-// easy to do after we are finished moving the client plugin to NaCl.
-ChromotingInstance::ConnectionError ConvertConnectionError(
- protocol::ErrorCode error) {
- switch (error) {
- case protocol::OK:
- return ChromotingInstance::ERROR_NONE;
-
- case protocol::PEER_IS_OFFLINE:
- return ChromotingInstance::ERROR_HOST_IS_OFFLINE;
-
- case protocol::SESSION_REJECTED:
- case protocol::AUTHENTICATION_FAILED:
- return ChromotingInstance::ERROR_SESSION_REJECTED;
-
- case protocol::INCOMPATIBLE_PROTOCOL:
- return ChromotingInstance::ERROR_INCOMPATIBLE_PROTOCOL;
-
- case protocol::HOST_OVERLOAD:
- return ChromotingInstance::ERROR_HOST_OVERLOAD;
-
- case protocol::CHANNEL_CONNECTION_ERROR:
- case protocol::SIGNALING_ERROR:
- case protocol::SIGNALING_TIMEOUT:
- case protocol::UNKNOWN_ERROR:
- return ChromotingInstance::ERROR_NETWORK_FAILURE;
- }
- DLOG(FATAL) << "Unknown error code" << error;
- return ChromotingInstance::ERROR_NONE;
-}
-
} // namespace
PepperView::PepperView(ChromotingInstance* instance,
@@ -79,29 +47,11 @@ PepperView::PepperView(ChromotingInstance* instance,
source_size_(SkISize::Make(0, 0)),
source_dpi_(SkIPoint::Make(0, 0)),
flush_pending_(false),
- is_initialized_(false),
frame_received_(false) {
-}
-
-PepperView::~PepperView() {
- DCHECK(merge_buffer_ == NULL);
- DCHECK(buffers_.empty());
-}
-
-bool PepperView::Initialize() {
- DCHECK(!is_initialized_);
-
- is_initialized_ = true;
InitiateDrawing();
- return true;
}
-void PepperView::TearDown() {
- DCHECK(context_->main_task_runner()->BelongsToCurrentThread());
- DCHECK(is_initialized_);
-
- is_initialized_ = false;
-
+PepperView::~PepperView() {
// The producer should now return any pending buffers. At this point, however,
// ReturnBuffer() tasks scheduled by the producer will not be delivered,
// so we free all the buffers once the producer's queue is empty.
@@ -116,45 +66,6 @@ void PepperView::TearDown() {
}
}
-void PepperView::SetConnectionState(protocol::ConnectionToHost::State state,
- protocol::ErrorCode error) {
- DCHECK(context_->main_task_runner()->BelongsToCurrentThread());
-
- switch (state) {
- case protocol::ConnectionToHost::CONNECTING:
- instance_->SetConnectionState(
- ChromotingInstance::STATE_CONNECTING,
- ConvertConnectionError(error));
- break;
-
- case protocol::ConnectionToHost::CONNECTED:
- instance_->SetConnectionState(
- ChromotingInstance::STATE_CONNECTED,
- ConvertConnectionError(error));
- break;
-
- case protocol::ConnectionToHost::CLOSED:
- instance_->SetConnectionState(
- ChromotingInstance::STATE_CLOSED,
- ConvertConnectionError(error));
- break;
-
- case protocol::ConnectionToHost::FAILED:
- instance_->SetConnectionState(
- ChromotingInstance::STATE_FAILED,
- ConvertConnectionError(error));
- break;
- }
-}
-
-protocol::ClipboardStub* PepperView::GetClipboardStub() {
- return instance_;
-}
-
-protocol::CursorShapeStub* PepperView::GetCursorShapeStub() {
- return instance_;
-}
-
void PepperView::SetView(const SkISize& view_size, const SkIRect& clip_area) {
bool view_changed = false;
@@ -211,12 +122,6 @@ void PepperView::ApplyBuffer(const SkISize& view_size,
void PepperView::ReturnBuffer(pp::ImageData* buffer) {
DCHECK(context_->main_task_runner()->BelongsToCurrentThread());
- // Free the buffer if there is nothing to paint.
- if (!is_initialized_) {
- FreeBuffer(buffer);
- return;
- }
-
// Reuse the buffer if it is large enough, otherwise drop it on the floor
// and allocate a new one.
if (buffer->size().width() >= clip_area_.width() &&
@@ -271,9 +176,6 @@ void PepperView::FreeBuffer(pp::ImageData* buffer) {
}
void PepperView::InitiateDrawing() {
- if (!is_initialized_)
- return;
-
pp::ImageData* buffer = AllocateBuffer();
while (buffer) {
producer_->DrawBuffer(buffer);
diff --git a/remoting/client/plugin/pepper_view.h b/remoting/client/plugin/pepper_view.h
index 9cfa8b8..68446e4 100644
--- a/remoting/client/plugin/pepper_view.h
+++ b/remoting/client/plugin/pepper_view.h
@@ -13,17 +13,19 @@
#include "base/memory/weak_ptr.h"
#include "ppapi/cpp/graphics_2d.h"
#include "ppapi/cpp/point.h"
-#include "remoting/client/chromoting_view.h"
#include "remoting/client/frame_consumer.h"
+namespace base {
+class Time;
+} // namespace base
+
namespace remoting {
class ChromotingInstance;
class ClientContext;
class FrameProducer;
-class PepperView : public ChromotingView,
- public FrameConsumer,
+class PepperView : public FrameConsumer,
public base::SupportsWeakPtr<PepperView> {
public:
// Constructs a PepperView for the |instance|. The |instance|, |context|
@@ -33,15 +35,6 @@ class PepperView : public ChromotingView,
FrameProducer* producer);
virtual ~PepperView();
- // ChromotingView implementation.
- virtual bool Initialize() OVERRIDE;
- virtual void TearDown() OVERRIDE;
- virtual void SetConnectionState(
- protocol::ConnectionToHost::State state,
- protocol::ErrorCode error) OVERRIDE;
- virtual protocol::ClipboardStub* GetClipboardStub() OVERRIDE;
- virtual protocol::CursorShapeStub* GetCursorShapeStub() OVERRIDE;
-
// FrameConsumer implementation.
virtual void ApplyBuffer(const SkISize& view_size,
const SkIRect& clip_area,
diff --git a/remoting/protocol/connection_to_host.cc b/remoting/protocol/connection_to_host.cc
index b869b3c..5794c50 100644
--- a/remoting/protocol/connection_to_host.cc
+++ b/remoting/protocol/connection_to_host.cc
@@ -36,7 +36,7 @@ ConnectionToHost::ConnectionToHost(
clipboard_stub_(NULL),
video_stub_(NULL),
audio_stub_(NULL),
- state_(CONNECTING),
+ state_(INITIALIZING),
error_(OK) {
}
@@ -88,6 +88,8 @@ void ConnectionToHost::Connect(scoped_refptr<XmppProxy> xmpp_proxy,
session_manager_.reset(new JingleSessionManager(
transport_factory.Pass(), allow_nat_traversal_));
session_manager_->Init(signal_strategy_.get(), this);
+
+ SetState(CONNECTING, OK);
}
void ConnectionToHost::Disconnect(const base::Closure& shutdown_task) {
diff --git a/remoting/protocol/connection_to_host.h b/remoting/protocol/connection_to_host.h
index 165dcad..4eb7d15 100644
--- a/remoting/protocol/connection_to_host.h
+++ b/remoting/protocol/connection_to_host.h
@@ -51,6 +51,7 @@ class ConnectionToHost : public SignalStrategy::Listener,
public base::NonThreadSafe {
public:
enum State {
+ INITIALIZING,
CONNECTING,
CONNECTED,
FAILED,
diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp
index 2ea6506..f3ca639 100644
--- a/remoting/remoting.gyp
+++ b/remoting/remoting.gyp
@@ -1297,11 +1297,11 @@
'client/chromoting_client.h',
'client/chromoting_stats.cc',
'client/chromoting_stats.h',
- 'client/chromoting_view.h',
'client/client_config.cc',
'client/client_config.h',
'client/client_context.cc',
'client/client_context.h',
+ 'client/client_user_interface.h',
'client/frame_consumer.h',
'client/frame_consumer_proxy.cc',
'client/frame_consumer_proxy.h',