diff options
author | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-13 04:31:01 +0000 |
---|---|---|
committer | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-13 04:31:01 +0000 |
commit | 48a8ca3ed1782d239d38fef2ac03765f2d38eb5f (patch) | |
tree | 13a7c9f5106fd50b6e1c04c0bd2fb4bd18cff9c6 | |
parent | b7ca2edf7bfebc4b3c831665b3579f07bfcab7ed (diff) | |
download | chromium_src-48a8ca3ed1782d239d38fef2ac03765f2d38eb5f.zip chromium_src-48a8ca3ed1782d239d38fef2ac03765f2d38eb5f.tar.gz chromium_src-48a8ca3ed1782d239d38fef2ac03765f2d38eb5f.tar.bz2 |
Rename ClientDimensions to ClientResolution and add pixel-size and DPI fields.
This CL also updates the client and host protocol handlers to the new name.
BUG=172404
Review URL: https://chromiumcodereview.appspot.com/12220092
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182115 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | remoting/client/plugin/chromoting_instance.cc | 20 | ||||
-rw-r--r-- | remoting/host/chromoting_host.cc | 8 | ||||
-rw-r--r-- | remoting/host/chromoting_host.h | 5 | ||||
-rw-r--r-- | remoting/host/client_session.cc | 22 | ||||
-rw-r--r-- | remoting/host/client_session.h | 13 | ||||
-rw-r--r-- | remoting/host/host_mock_objects.h | 5 | ||||
-rw-r--r-- | remoting/host/host_status_observer.h | 7 | ||||
-rw-r--r-- | remoting/host/resizing_host_observer.cc | 6 | ||||
-rw-r--r-- | remoting/host/resizing_host_observer.h | 5 | ||||
-rw-r--r-- | remoting/host/resizing_host_observer_unittest.cc | 3 | ||||
-rw-r--r-- | remoting/proto/control.proto | 17 | ||||
-rw-r--r-- | remoting/proto/internal.proto | 2 | ||||
-rw-r--r-- | remoting/protocol/client_control_dispatcher.cc | 6 | ||||
-rw-r--r-- | remoting/protocol/client_control_dispatcher.h | 4 | ||||
-rw-r--r-- | remoting/protocol/host_control_dispatcher.cc | 4 | ||||
-rw-r--r-- | remoting/protocol/host_stub.h | 6 | ||||
-rw-r--r-- | remoting/protocol/protocol_mock_objects.h | 4 |
17 files changed, 88 insertions, 49 deletions
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc index daf591f..3ee563d 100644 --- a/remoting/client/plugin/chromoting_instance.cc +++ b/remoting/client/plugin/chromoting_instance.cc @@ -54,6 +54,10 @@ namespace { // 32-bit BGRA is 4 bytes per pixel. const int kBytesPerPixel = 4; +// Default DPI to assume for old clients that use notifyClientDimensions. +const int kDefaultDPI = 96; + +// Interval at which to sample performance statistics. const int kPerfStatsIntervalMs = 1000; // URL scheme used by Chrome apps and extensions. @@ -593,10 +597,18 @@ void ChromotingInstance::NotifyClientDimensions(int width, int height) { if (!IsConnected()) { return; } - protocol::ClientDimensions client_dimensions; - client_dimensions.set_width(width); - client_dimensions.set_height(height); - host_connection_->host_stub()->NotifyClientDimensions(client_dimensions); + + protocol::ClientResolution client_resolution; + client_resolution.set_width(width); + client_resolution.set_height(height); + client_resolution.set_x_dpi(kDefaultDPI); + client_resolution.set_y_dpi(kDefaultDPI); + + // Include the legacy width & height for use by older hosts. + client_resolution.set_dips_width(width); + client_resolution.set_dips_height(height); + + host_connection_->host_stub()->NotifyClientResolution(client_resolution); } void ChromotingInstance::PauseVideo(bool pause) { diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc index 51d50aa..848b926 100644 --- a/remoting/host/chromoting_host.cc +++ b/remoting/host/chromoting_host.cc @@ -266,11 +266,13 @@ void ChromotingHost::OnSessionRouteChange( route)); } -void ChromotingHost::OnClientDimensionsChanged(ClientSession* session, - const SkISize& size) { +void ChromotingHost::OnClientResolutionChanged(ClientSession* session, + const SkISize& size, + const SkIPoint& dpi) { DCHECK(network_task_runner_->BelongsToCurrentThread()); FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, - OnClientDimensionsChanged(session->client_jid(), size)); + OnClientResolutionChanged(session->client_jid(), + size, dpi)); } void ChromotingHost::OnSessionManagerReady() { diff --git a/remoting/host/chromoting_host.h b/remoting/host/chromoting_host.h index 7e1a935..bfd4dca 100644 --- a/remoting/host/chromoting_host.h +++ b/remoting/host/chromoting_host.h @@ -125,8 +125,9 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, ClientSession* session, const std::string& channel_name, const protocol::TransportRoute& route) OVERRIDE; - virtual void OnClientDimensionsChanged(ClientSession* session, - const SkISize& size) OVERRIDE; + virtual void OnClientResolutionChanged(ClientSession* session, + const SkISize& size, + const SkIPoint& dpi) OVERRIDE; // SessionManager::Listener implementation. virtual void OnSessionManagerReady() OVERRIDE; diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc index b62b2e4..51d3bd8 100644 --- a/remoting/host/client_session.cc +++ b/remoting/host/client_session.cc @@ -27,6 +27,11 @@ namespace remoting { +namespace { +// Default DPI to assume for old clients that use notifyClientDimensions. +const int kDefaultDPI = 96; +} // namespace + ClientSession::ClientSession( EventHandler* event_handler, scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, @@ -75,13 +80,16 @@ ClientSession::ClientSession( auth_clipboard_filter_.set_enabled(false); } -void ClientSession::NotifyClientDimensions( - const protocol::ClientDimensions& dimensions) { - if (dimensions.has_width() && dimensions.has_height()) { - VLOG(1) << "Received ClientDimensions (width=" - << dimensions.width() << ", height=" << dimensions.height() << ")"; - event_handler_->OnClientDimensionsChanged( - this, SkISize::Make(dimensions.width(), dimensions.height())); +void ClientSession::NotifyClientResolution( + const protocol::ClientResolution& resolution) { + if (resolution.has_dips_width() && resolution.has_dips_height()) { + VLOG(1) << "Received ClientResolution (dips_width=" + << resolution.width() << ", dips_height=" + << resolution.height() << ")"; + event_handler_->OnClientResolutionChanged( + this, + SkISize::Make(resolution.dips_width(), resolution.dips_height()), + SkIPoint::Make(kDefaultDPI, kDefaultDPI)); } } diff --git a/remoting/host/client_session.h b/remoting/host/client_session.h index 6d32adf..5ed34f3 100644 --- a/remoting/host/client_session.h +++ b/remoting/host/client_session.h @@ -78,10 +78,11 @@ class ClientSession const std::string& channel_name, const protocol::TransportRoute& route) = 0; - // Called when the initial client dimensions are received, and when they - // change. - virtual void OnClientDimensionsChanged(ClientSession* client, - const SkISize& size) = 0; + // Called when the initial client resolution is received, and when it + // changes. + virtual void OnClientResolutionChanged(ClientSession* client, + const SkISize& size, + const SkIPoint& dpi) = 0; protected: virtual ~EventHandler() {} @@ -102,8 +103,8 @@ class ClientSession const base::TimeDelta& max_duration); // protocol::HostStub interface. - virtual void NotifyClientDimensions( - const protocol::ClientDimensions& dimensions) OVERRIDE; + virtual void NotifyClientResolution( + const protocol::ClientResolution& resolution) OVERRIDE; virtual void ControlVideo( const protocol::VideoControl& video_control) OVERRIDE; virtual void ControlAudio( diff --git a/remoting/host/host_mock_objects.h b/remoting/host/host_mock_objects.h index 1c32dab..1c4e88e 100644 --- a/remoting/host/host_mock_objects.h +++ b/remoting/host/host_mock_objects.h @@ -94,8 +94,9 @@ class MockClientSessionEventHandler : public ClientSession::EventHandler { ClientSession* client, const std::string& channel_name, const protocol::TransportRoute& route)); - MOCK_METHOD2(OnClientDimensionsChanged, void(ClientSession* client, - const SkISize& size)); + MOCK_METHOD3(OnClientResolutionChanged, void(ClientSession* client, + const SkISize& size, + const SkIPoint& dpi)); private: DISALLOW_COPY_AND_ASSIGN(MockClientSessionEventHandler); diff --git a/remoting/host/host_status_observer.h b/remoting/host/host_status_observer.h index a37e9e4..f2e2198 100644 --- a/remoting/host/host_status_observer.h +++ b/remoting/host/host_status_observer.h @@ -46,9 +46,10 @@ class HostStatusObserver { const std::string& channel_name, const protocol::TransportRoute& route) {} - // Called when the client view dimensions change. - virtual void OnClientDimensionsChanged(const std::string& jid, - const SkISize& size) {} + // Called when the client view size or pixel density change. + virtual void OnClientResolutionChanged(const std::string& jid, + const SkISize& size, + const SkIPoint& dpi) {} // Called when hosting is started for an account. virtual void OnStart(const std::string& xmpp_login) {} diff --git a/remoting/host/resizing_host_observer.cc b/remoting/host/resizing_host_observer.cc index 039c94d..06d1187 100644 --- a/remoting/host/resizing_host_observer.cc +++ b/remoting/host/resizing_host_observer.cc @@ -126,8 +126,10 @@ class CandidateSize { SkISize size_; }; -void ResizingHostObserver::OnClientDimensionsChanged( - const std::string& jid, const SkISize& preferred_size) { +void ResizingHostObserver::OnClientResolutionChanged( + const std::string& jid, + const SkISize& preferred_size, + const SkIPoint& dpi) { if (previous_size_.isZero() || preferred_size.isEmpty()) { return; } diff --git a/remoting/host/resizing_host_observer.h b/remoting/host/resizing_host_observer.h index 41b18fe..f6badb6 100644 --- a/remoting/host/resizing_host_observer.h +++ b/remoting/host/resizing_host_observer.h @@ -29,8 +29,9 @@ class ResizingHostObserver : public HostStatusObserver { // HostStatusObserver interface virtual void OnClientAuthenticated(const std::string& jid) OVERRIDE; virtual void OnClientDisconnected(const std::string& jid) OVERRIDE; - virtual void OnClientDimensionsChanged(const std::string& jid, - const SkISize& size) OVERRIDE; + virtual void OnClientResolutionChanged(const std::string& jid, + const SkISize& size, + const SkIPoint& dpi) OVERRIDE; private: DesktopResizer* const desktop_resizer_; diff --git a/remoting/host/resizing_host_observer_unittest.cc b/remoting/host/resizing_host_observer_unittest.cc index 5e1d519..7944a14 100644 --- a/remoting/host/resizing_host_observer_unittest.cc +++ b/remoting/host/resizing_host_observer_unittest.cc @@ -74,7 +74,8 @@ class ResizingHostObserverTest : public testing::Test { } SkISize GetBestSize(const SkISize& client_size) { - resizing_host_observer_->OnClientDimensionsChanged("", client_size); + resizing_host_observer_->OnClientResolutionChanged( + "", client_size, SkIPoint()); return desktop_resizer_->GetCurrentSize(); } diff --git a/remoting/proto/control.proto b/remoting/proto/control.proto index 20f0b9d..e1c29ce 100644 --- a/remoting/proto/control.proto +++ b/remoting/proto/control.proto @@ -10,10 +10,19 @@ option optimize_for = LITE_RUNTIME; package remoting.protocol; -message ClientDimensions { - // Width and height of the client. - optional int32 width = 1; - optional int32 height = 2; +message ClientResolution { + // Legacy width and height of the client in Density-Independent Pixels + optional int32 dips_width = 1; + optional int32 dips_height = 2; + + // Width and height of the client in device pixels. + optional int32 width = 3; + optional int32 height = 4; + + // Horizontal and vertical DPI of the screen. If either of these is zero or + // unset, the corresponding DPI should be assumed to be 96 (Windows' default) + optional int32 x_dpi = 5; + optional int32 y_dpi = 6; } message VideoControl { diff --git a/remoting/proto/internal.proto b/remoting/proto/internal.proto index 7f06f9d..21f32da 100644 --- a/remoting/proto/internal.proto +++ b/remoting/proto/internal.proto @@ -17,7 +17,7 @@ package remoting.protocol; // Represents a message being sent on the control channel. message ControlMessage { optional ClipboardEvent clipboard_event = 1; - optional ClientDimensions client_dimensions = 2; + optional ClientResolution client_resolution = 2; optional CursorShapeInfo cursor_shape = 4; optional VideoControl video_control = 3; optional AudioControl audio_control = 5; diff --git a/remoting/protocol/client_control_dispatcher.cc b/remoting/protocol/client_control_dispatcher.cc index 155f128..6830981 100644 --- a/remoting/protocol/client_control_dispatcher.cc +++ b/remoting/protocol/client_control_dispatcher.cc @@ -41,10 +41,10 @@ void ClientControlDispatcher::InjectClipboardEvent( writer_.Write(SerializeAndFrameMessage(message), base::Closure()); } -void ClientControlDispatcher::NotifyClientDimensions( - const ClientDimensions& dimensions) { +void ClientControlDispatcher::NotifyClientResolution( + const ClientResolution& resolution) { ControlMessage message; - message.mutable_client_dimensions()->CopyFrom(dimensions); + message.mutable_client_resolution()->CopyFrom(resolution); writer_.Write(SerializeAndFrameMessage(message), base::Closure()); } diff --git a/remoting/protocol/client_control_dispatcher.h b/remoting/protocol/client_control_dispatcher.h index a28bbd0..a1bc79b 100644 --- a/remoting/protocol/client_control_dispatcher.h +++ b/remoting/protocol/client_control_dispatcher.h @@ -34,8 +34,8 @@ class ClientControlDispatcher : public ChannelDispatcherBase, virtual void InjectClipboardEvent(const ClipboardEvent& event) OVERRIDE; // HostStub implementation. - virtual void NotifyClientDimensions( - const ClientDimensions& dimensions) OVERRIDE; + virtual void NotifyClientResolution( + const ClientResolution& resolution) OVERRIDE; virtual void ControlVideo(const VideoControl& video_control) OVERRIDE; virtual void ControlAudio(const AudioControl& audio_control) OVERRIDE; diff --git a/remoting/protocol/host_control_dispatcher.cc b/remoting/protocol/host_control_dispatcher.cc index 2dc83af..db041b4 100644 --- a/remoting/protocol/host_control_dispatcher.cc +++ b/remoting/protocol/host_control_dispatcher.cc @@ -54,8 +54,8 @@ void HostControlDispatcher::OnMessageReceived( if (message->has_clipboard_event()) { clipboard_stub_->InjectClipboardEvent(message->clipboard_event()); - } else if (message->has_client_dimensions()) { - host_stub_->NotifyClientDimensions(message->client_dimensions()); + } else if (message->has_client_resolution()) { + host_stub_->NotifyClientResolution(message->client_resolution()); } else if (message->has_video_control()) { host_stub_->ControlVideo(message->video_control()); } else if (message->has_audio_control()) { diff --git a/remoting/protocol/host_stub.h b/remoting/protocol/host_stub.h index a1d2152..b66558f 100644 --- a/remoting/protocol/host_stub.h +++ b/remoting/protocol/host_stub.h @@ -14,7 +14,7 @@ namespace remoting { namespace protocol { -class ClientDimensions; +class ClientResolution; class VideoControl; class AudioControl; @@ -22,9 +22,9 @@ class HostStub { public: HostStub() {} - // Notification of the available client display dimensions. + // Notification of the client dimensions and pixel density. // This may be used to resize the host display to match the client area. - virtual void NotifyClientDimensions(const ClientDimensions& dimensions) = 0; + virtual void NotifyClientResolution(const ClientResolution& resolution) = 0; // Configures video update properties. Currently only pausing & resuming the // video channel is supported. diff --git a/remoting/protocol/protocol_mock_objects.h b/remoting/protocol/protocol_mock_objects.h index 6472869..9d1e4a2 100644 --- a/remoting/protocol/protocol_mock_objects.h +++ b/remoting/protocol/protocol_mock_objects.h @@ -102,8 +102,8 @@ class MockHostStub : public HostStub { MockHostStub(); virtual ~MockHostStub(); - MOCK_METHOD1(NotifyClientDimensions, - void(const ClientDimensions& dimensions)); + MOCK_METHOD1(NotifyClientResolution, + void(const ClientResolution& resolution)); MOCK_METHOD1(ControlVideo, void(const VideoControl& video_control)); MOCK_METHOD1(ControlAudio, |