From 6387b4de56f0ac62bae8ab2c356e617db9cb9c55 Mon Sep 17 00:00:00 2001 From: "wez@chromium.org" Date: Wed, 11 Apr 2012 02:27:09 +0000 Subject: This CL removes the unused trace.proto definition and build target, and makes all protobuf fields "optional". Fields marked required cause protobuf messages to be silently ignored if those fields are not present. By moving the fields to be optional we have more flexibility to remove fields in future. All of the previously-required fields were in client-to-host messages; clients will need to continue to provide those fields at least until all hosts are updated not to require them - this is primarily relevant for the KeyEvent "keycode" field. Review URL: http://codereview.chromium.org/10024003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131698 0039d316-1c4b-4281-b951-d872f2087c98 --- remoting/proto/event.proto | 4 +-- remoting/proto/internal.proto | 2 +- remoting/proto/trace.gyp | 22 ----------------- remoting/proto/trace.proto | 37 ---------------------------- remoting/proto/video.proto | 3 +-- remoting/protocol/client_event_dispatcher.cc | 4 ++- remoting/protocol/host_event_dispatcher.cc | 6 +++-- remoting/remoting.gyp | 1 - 8 files changed, 11 insertions(+), 68 deletions(-) delete mode 100644 remoting/proto/trace.gyp delete mode 100644 remoting/proto/trace.proto (limited to 'remoting') diff --git a/remoting/proto/event.proto b/remoting/proto/event.proto index e42f5d3..e0a469d 100644 --- a/remoting/proto/event.proto +++ b/remoting/proto/event.proto @@ -13,8 +13,8 @@ package remoting.protocol; // Defines a keyboard event. message KeyEvent { // The Windows Virtual Key code. - required int32 keycode = 1; - required bool pressed = 2; + optional int32 keycode = 1; + optional bool pressed = 2; // The USB key code. // The upper 16-bits are the USB Page (0x07 for key events). diff --git a/remoting/proto/internal.proto b/remoting/proto/internal.proto index a65b677..56ecc8f 100644 --- a/remoting/proto/internal.proto +++ b/remoting/proto/internal.proto @@ -21,7 +21,7 @@ message ControlMessage { // Defines an event message on the event channel. message EventMessage { - required int64 sequence_number = 1; // Client timestamp for event. + optional int64 sequence_number = 1; // Client timestamp for event. optional bool dummy = 2; // Whether this is a dummy event. optional KeyEvent key_event = 3; diff --git a/remoting/proto/trace.gyp b/remoting/proto/trace.gyp deleted file mode 100644 index 084c810..0000000 --- a/remoting/proto/trace.gyp +++ /dev/null @@ -1,22 +0,0 @@ -# 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. - -{ - 'variables': { - 'chromium_code': 1, - }, - 'targets': [ - { - 'target_name': 'trace_proto_lib', - 'type': 'static_library', - 'sources': [ - 'trace.proto', - ], - 'variables': { - 'proto_out_dir': 'remoting/proto', - }, - 'includes': ['../../build/protoc.gypi'], - }, - ], -} diff --git a/remoting/proto/trace.proto b/remoting/proto/trace.proto deleted file mode 100644 index dbbabcf..0000000 --- a/remoting/proto/trace.proto +++ /dev/null @@ -1,37 +0,0 @@ -// 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. -// -// Protocol buffers for creating performance traces on requests. - -syntax = "proto2"; - -option optimize_for = LITE_RUNTIME; - -package remoting; - -// Represents one entry in the TraceBuffer below. Collates information that -// would be useful for analyzing the performance in a program trace. -message TraceRecord { - required string annotation = 1; - required int64 timestamp = 2; // In micros from epoch. - - // -- Information for constructing a distributed trace. -- - // TODO(ajwong): Decide which of these are useful, and remove rest. - - // Identifies the machine. - optional int64 source_id = 3 [ default = -1 ]; - - // Identifies the thread on the machine. - optional fixed64 thread_id = 4; - - // Estimated skew from master clock. - optional int64 clock_skew = 5 [ default = 0 ]; -} - -// Protocol buffer used for collecting stats, and performance data. -message TraceBuffer { - required string name = 1; // Name of this trace. - repeated TraceRecord record = 2; -} - diff --git a/remoting/proto/video.proto b/remoting/proto/video.proto index 049351e..14415af 100644 --- a/remoting/proto/video.proto +++ b/remoting/proto/video.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -10,7 +10,6 @@ option optimize_for = LITE_RUNTIME; package remoting; -// TODO(ajwong): Determine if these fields should be optional or required. message VideoPacketFormat { // Identifies how the image was encoded. enum Encoding { diff --git a/remoting/protocol/client_event_dispatcher.cc b/remoting/protocol/client_event_dispatcher.cc index c0da837..ab6c292 100644 --- a/remoting/protocol/client_event_dispatcher.cc +++ b/remoting/protocol/client_event_dispatcher.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -32,6 +32,8 @@ void ClientEventDispatcher::OnInitialized() { } void ClientEventDispatcher::InjectKeyEvent(const KeyEvent& event) { + DCHECK(event.has_keycode() || event.has_usb_keycode()); + DCHECK(event.has_pressed()); EventMessage message; message.set_sequence_number(base::Time::Now().ToInternalValue()); message.mutable_key_event()->CopyFrom(event); diff --git a/remoting/protocol/host_event_dispatcher.cc b/remoting/protocol/host_event_dispatcher.cc index 6ec1f17..6ba6dd0 100644 --- a/remoting/protocol/host_event_dispatcher.cc +++ b/remoting/protocol/host_event_dispatcher.cc @@ -33,11 +33,13 @@ void HostEventDispatcher::OnMessageReceived( base::ScopedClosureRunner done_runner(done_task); - sequence_number_callback_.Run(message->sequence_number()); + if (message->has_sequence_number() && !sequence_number_callback_.is_null()) + sequence_number_callback_.Run(message->sequence_number()); if (message->has_key_event()) { const KeyEvent& event = message->key_event(); - if (event.has_keycode() && event.has_pressed()) { + if ((event.has_keycode() || event.has_usb_keycode()) && + event.has_pressed()) { input_stub_->InjectKeyEvent(event); } else { LOG(WARNING) << "Received invalid key event."; diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index 2fe3b4e..1a4405e 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -715,7 +715,6 @@ '../media/media.gyp:yuv_convert', 'remoting_jingle_glue', 'proto/chromotocol.gyp:chromotocol_proto_lib', - 'proto/trace.gyp:trace_proto_lib', ], 'export_dependent_settings': [ '../base/base.gyp:base', -- cgit v1.1