diff options
author | kmarshall <kmarshall@chromium.org> | 2016-03-01 14:13:02 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-01 22:15:07 +0000 |
commit | 8f2fedd4e99e00f6f601346036faf4a738be80b3 (patch) | |
tree | e7046d7f1da76a75a819d7cada3eeac0f2cd907f | |
parent | 55f2d0ef786093c3ea01cfd019903ab20e68661a (diff) | |
download | chromium_src-8f2fedd4e99e00f6f601346036faf4a738be80b3.zip chromium_src-8f2fedd4e99e00f6f601346036faf4a738be80b3.tar.gz chromium_src-8f2fedd4e99e00f6f601346036faf4a738be80b3.tar.bz2 |
Add detailed logging support for BlimpMessage and subtypes.
Add detailed logging support for BlimpMessage and subtypes.
* Create FieldExtractor interface for classes which can extract
loggable content from BlimpMessages.
* Implement FieldExtractors for most BlimpMessage types.
* Add BlimpMessageLogger class to manage FieldExtractors
and serialize log messages.
* Add unit tests to verify log output of most BlimpMessage types.
R=dtrainor@chromium.org,haibinlu@chromium.org
BUG=
Review URL: https://codereview.chromium.org/1741943002
Cr-Commit-Position: refs/heads/master@{#378573}
-rw-r--r-- | blimp/common/BUILD.gn | 4 | ||||
-rw-r--r-- | blimp/common/logging.cc | 253 | ||||
-rw-r--r-- | blimp/common/logging.h | 68 | ||||
-rw-r--r-- | blimp/common/logging_unittest.cc | 188 | ||||
-rw-r--r-- | blimp/common/proto/input.proto | 2 | ||||
-rw-r--r-- | blimp/net/BUILD.gn | 1 | ||||
-rw-r--r-- | blimp/net/blimp_connection.cc | 1 | ||||
-rw-r--r-- | blimp/net/blimp_message_demultiplexer.cc | 1 | ||||
-rw-r--r-- | blimp/net/blimp_message_output_buffer.cc | 3 | ||||
-rw-r--r-- | blimp/net/blimp_message_pump.cc | 1 | ||||
-rw-r--r-- | blimp/net/common.cc | 12 | ||||
-rw-r--r-- | blimp/net/common.h | 9 | ||||
-rw-r--r-- | blimp/net/engine_authentication_handler.cc | 3 | ||||
-rw-r--r-- | blimp/net/null_blimp_message_processor.cc | 1 |
14 files changed, 525 insertions, 22 deletions
diff --git a/blimp/common/BUILD.gn b/blimp/common/BUILD.gn index e1ec05a..2bfed0f 100644 --- a/blimp/common/BUILD.gn +++ b/blimp/common/BUILD.gn @@ -15,6 +15,8 @@ component("blimp_common") { "compositor/webp_decoder.h", "create_blimp_message.cc", "create_blimp_message.h", + "logging.cc", + "logging.h", "protocol_version.h", ] @@ -36,11 +38,13 @@ source_set("unit_tests") { sources = [ "create_blimp_message_unittest.cc", + "logging_unittest.cc", ] deps = [ ":blimp_common", "//blimp/common/proto", + "//testing/gmock", "//testing/gtest", ] } diff --git a/blimp/common/logging.cc b/blimp/common/logging.cc new file mode 100644 index 0000000..37aa513 --- /dev/null +++ b/blimp/common/logging.cc @@ -0,0 +1,253 @@ +// Copyright 2016 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 "blimp/common/logging.h" + +#include <iostream> +#include <string> +#include <vector> + +#include "base/format_macros.h" +#include "base/json/string_escape.h" +#include "base/lazy_instance.h" +#include "base/strings/string_util.h" +#include "base/strings/stringprintf.h" +#include "blimp/common/proto/blimp_message.pb.h" + +namespace blimp { +namespace { + +static base::LazyInstance<BlimpMessageLogger> g_logger = + LAZY_INSTANCE_INITIALIZER; + +// The AddField() suite of functions are used to convert KV pairs with +// arbitrarily typed values into string/string KV pairs for logging. + +// Specialization for string values, surrounding them with quotes and escaping +// characters as necessary. +void AddField(const std::string& key, + const std::string& value, + LogFields* output) { + std::string escaped_value; + base::EscapeJSONString(value, true, &escaped_value); + output->push_back(std::make_pair(key, escaped_value)); +} + +// Specialization for string literal values. +void AddField(const std::string& key, const char* value, LogFields* output) { + output->push_back(std::make_pair(key, std::string(value))); +} + +// Specialization for boolean values (serialized as "true" or "false"). +void AddField(const std::string& key, bool value, LogFields* output) { + output->push_back(std::make_pair(key, (value ? "true" : "false"))); +} + +// Specialization for SizeMessage values, serializing them as +// WIDTHxHEIGHT:RATIO. RATIO is rounded to two digits of precision +// (e.g. 2.123 => 2.12). +void AddField(const std::string& key, + const SizeMessage& value, + LogFields* output) { + output->push_back(std::make_pair( + key, base::StringPrintf("%" PRIu64 "x%" PRIu64 ":%.2lf", value.width(), + value.height(), value.device_pixel_ratio()))); +} + +// Conversion function for all other types. +// Uses std::to_string() to serialize |value|. +template <typename T> +void AddField(const std::string& key, const T& value, LogFields* output) { + output->push_back(std::make_pair(key, std::to_string(value))); +} + +// The following LogExtractor subclasses contain logic for extracting loggable +// fields from BlimpMessages. + +// Logs fields from TAB_CONTROL messages. +class TabControlLogExtractor : public LogExtractor { + void ExtractFields(const BlimpMessage& message, + LogFields* output) const override { + switch (message.tab_control().type()) { + case TabControlMessage::CREATE_TAB: + AddField("subtype", "CREATE_TAB", output); + break; + case TabControlMessage::CLOSE_TAB: + AddField("subtype", "CLOSE_TAB", output); + break; + case TabControlMessage::SIZE: + AddField("subtype", "SIZE", output); + AddField("size", message.tab_control().size(), output); + break; + default: // unknown + break; + } + } +}; + +// Logs fields from NAVIGATION messages. +class NavigationLogExtractor : public LogExtractor { + void ExtractFields(const BlimpMessage& message, + LogFields* output) const override { + switch (message.navigation().type()) { + case NavigationMessage::NAVIGATION_STATE_CHANGED: + AddField("subtype", "NAVIGATION_STATE_CHANGED", output); + if (message.navigation().navigation_state_changed().has_url()) { + AddField("url", message.navigation().navigation_state_changed().url(), + output); + } + if (message.navigation().navigation_state_changed().has_favicon()) { + AddField( + "favicon_size", + message.navigation().navigation_state_changed().favicon().size(), + output); + } + if (message.navigation().navigation_state_changed().has_title()) { + AddField("title", + message.navigation().navigation_state_changed().title(), + output); + } + if (message.navigation().navigation_state_changed().has_loading()) { + AddField("loading", + message.navigation().navigation_state_changed().loading(), + output); + } + break; + case NavigationMessage::LOAD_URL: + AddField("subtype", "LOAD_URL", output); + AddField("url", message.navigation().load_url().url(), output); + break; + case NavigationMessage::GO_BACK: + AddField("subtype", "GO_BACK", output); + break; + case NavigationMessage::GO_FORWARD: + AddField("subtype", "GO_FORWARD", output); + break; + case NavigationMessage::RELOAD: + AddField("subtype", "RELOAD", output); + break; + default: + break; + } + } +}; + +// Logs fields from RENDER_WIDGET messages. +class RenderWidgetLogExtractor : public LogExtractor { + void ExtractFields(const BlimpMessage& message, + LogFields* output) const override { + switch (message.render_widget().type()) { + case RenderWidgetMessage::INITIALIZE: + AddField("subtype", "INITIALIZE", output); + break; + case RenderWidgetMessage::CREATED: + AddField("subtype", "CREATED", output); + break; + case RenderWidgetMessage::DELETED: + AddField("subtype", "DELETED", output); + break; + } + AddField("render_widget_id", message.render_widget().render_widget_id(), + output); + } +}; + +// Logs fields from PROTOCOL_CONTROL messages. +class ProtocolControlLogExtractor : public LogExtractor { + void ExtractFields(const BlimpMessage& message, + LogFields* output) const override { + switch (message.protocol_control().type()) { + case ProtocolControlMessage::START_CONNECTION: + AddField("subtype", "START_CONNECTION", output); + AddField("client_token", + message.protocol_control().start_connection().client_token(), + output); + AddField( + "protocol_version", + message.protocol_control().start_connection().protocol_version(), + output); + break; + case ProtocolControlMessage::CHECKPOINT_ACK: + AddField("subtype", "CHECKPOINT_ACK", output); + AddField("checkpoint_id", + message.protocol_control().checkpoint_ack().checkpoint_id(), + output); + break; + default: + break; + } + } +}; + +// No fields are extracted from |message|. +class NullLogExtractor : public LogExtractor { + void ExtractFields(const BlimpMessage& message, + LogFields* output) const override {} +}; + +} // namespace + +BlimpMessageLogger::BlimpMessageLogger() { + AddHandler("COMPOSITOR", BlimpMessage::COMPOSITOR, + make_scoped_ptr(new NullLogExtractor)); + AddHandler("INPUT", BlimpMessage::INPUT, + make_scoped_ptr(new NullLogExtractor)); + AddHandler("NAVIGATION", BlimpMessage::NAVIGATION, + make_scoped_ptr(new NavigationLogExtractor)); + AddHandler("PROTOCOL_CONTROL", BlimpMessage::PROTOCOL_CONTROL, + make_scoped_ptr(new ProtocolControlLogExtractor)); + AddHandler("RENDER_WIDGET", BlimpMessage::RENDER_WIDGET, + make_scoped_ptr(new RenderWidgetLogExtractor)); + AddHandler("TAB_CONTROL", BlimpMessage::TAB_CONTROL, + make_scoped_ptr(new TabControlLogExtractor)); +} + +BlimpMessageLogger::~BlimpMessageLogger() {} + +void BlimpMessageLogger::AddHandler(const std::string& type_name, + BlimpMessage::Type type, + scoped_ptr<LogExtractor> extractor) { + DCHECK(extractors_.find(type) == extractors_.end()); + DCHECK(!type_name.empty()); + extractors_[type] = make_pair(type_name, std::move(extractor)); +} + +void BlimpMessageLogger::LogMessageToStream(const BlimpMessage& message, + std::ostream* out) const { + LogFields fields; + + auto extractor = extractors_.find(message.type()); + if (extractor != extractors_.end()) { + // An extractor is registered for |message|. + // Add the human-readable name of |message.type|. + fields.push_back(make_pair("type", extractor->second.first)); + extractor->second.second->ExtractFields(message, &fields); + } else { + // Don't know the human-readable name of |message.type|. + // Just represent it using its numeric form instead. + AddField("type", message.type(), &fields); + } + + // Append "target_tab_id" (if present) and "byte_size" to the field set. + if (message.has_target_tab_id()) { + AddField("target_tab_id", message.target_tab_id(), &fields); + } + AddField("byte_size", message.ByteSize(), &fields); + + // Format message using the syntax: + // <BlimpMessage field1=value1 field2="value 2"> + *out << "<BlimpMessage "; + for (size_t i = 0; i < fields.size(); ++i) { + *out << fields[i].first << "=" << fields[i].second + << (i != fields.size() - 1 ? " " : ""); + } + *out << ">"; +} + +std::ostream& operator<<(std::ostream& out, const BlimpMessage& message) { + g_logger.Get().LogMessageToStream(message, &out); + return out; +} + +} // namespace blimp diff --git a/blimp/common/logging.h b/blimp/common/logging.h new file mode 100644 index 0000000..b8e5443 --- /dev/null +++ b/blimp/common/logging.h @@ -0,0 +1,68 @@ +// Copyright 2016 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 BLIMP_COMMON_LOGGING_H_ +#define BLIMP_COMMON_LOGGING_H_ + +#include <map> +#include <string> +#include <utility> +#include <vector> + +#include "base/memory/scoped_ptr.h" +#include "blimp/common/blimp_common_export.h" +#include "blimp/common/proto/blimp_message.pb.h" + +namespace blimp { + +class BlimpMessage; +class LogExtractor; + +typedef std::vector<std::pair<std::string, std::string>> LogFields; + +// Defines an interface for classes that extract a set of loggable field +// values from a message. +class BLIMP_COMMON_EXPORT LogExtractor { + public: + virtual ~LogExtractor() {} + + // |message|: The message which is used for field extraction. + // |output|: A vector of KV pairs which will receive the extracted fields. + virtual void ExtractFields(const BlimpMessage& message, + LogFields* output) const = 0; +}; + +// Registry of log extractors. +class BLIMP_COMMON_EXPORT BlimpMessageLogger { + public: + BlimpMessageLogger(); + ~BlimpMessageLogger(); + + // Formats the loggable representation of |message| and sends it to |out|. + void LogMessageToStream(const BlimpMessage& message, std::ostream* out) const; + + private: + // Adds |extractor| to the registry for parsing messages of type |type|. + // |type_name|: The human readable name of |type|. + void AddHandler(const std::string& type_name, + BlimpMessage::Type type, + scoped_ptr<LogExtractor> extractor); + + // Registry of log extractors. Map structure is: + // {message type => (human readable message type, LogExtractor*)} + std::map<BlimpMessage::Type, std::pair<std::string, scoped_ptr<LogExtractor>>> + extractors_; + + DISALLOW_COPY_AND_ASSIGN(BlimpMessageLogger); +}; + +// Serializes a BlimpMessage in a human-readable format for logging. +// An example message would look like: +// "<type=TAB_CONTROL subtype=SIZE size=640x480:1.000000 size=19>" +BLIMP_COMMON_EXPORT std::ostream& operator<<(std::ostream& out, + const BlimpMessage& message); + +} // namespace blimp + +#endif // BLIMP_COMMON_LOGGING_H_ diff --git a/blimp/common/logging_unittest.cc b/blimp/common/logging_unittest.cc new file mode 100644 index 0000000..6dafa3b --- /dev/null +++ b/blimp/common/logging_unittest.cc @@ -0,0 +1,188 @@ +// Copyright 2016 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 <sstream> +#include <string> + +#include "base/at_exit.h" +#include "base/strings/stringprintf.h" +#include "blimp/common/logging.h" +#include "blimp/common/proto/blimp_message.pb.h" +#include "blimp/net/test_common.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" + +using testing::Return; + +namespace blimp { +namespace { + +const int kTargetTab = 123; + +class LoggingTest : public testing::Test { + public: + LoggingTest() {} + ~LoggingTest() override {} + + protected: + // Verifies that the logged form of |msg| matches |expected|, modulo prefix + // and suffix. + void VerifyLogOutput(const std::string& expected_fragment, + const BlimpMessage& msg) { + std::string expected = "<BlimpMessage " + expected_fragment + + " byte_size=" + std::to_string(msg.ByteSize()) + ">"; + std::stringstream outstream; + outstream << msg; + EXPECT_EQ(expected, outstream.str()); + } + + private: + // Deletes the singleton on test termination. + base::ShadowingAtExitManager at_exit_; +}; + +TEST_F(LoggingTest, Compositor) { + BlimpMessage base_msg; + base_msg.set_type(BlimpMessage::COMPOSITOR); + base_msg.set_target_tab_id(kTargetTab); + VerifyLogOutput("type=COMPOSITOR target_tab_id=123", base_msg); +} + +TEST_F(LoggingTest, Input) { + BlimpMessage base_msg; + base_msg.set_type(BlimpMessage::INPUT); + base_msg.set_target_tab_id(kTargetTab); + VerifyLogOutput("type=INPUT target_tab_id=123", base_msg); +} + +TEST_F(LoggingTest, Navigation) { + BlimpMessage base_msg; + base_msg.set_type(BlimpMessage::NAVIGATION); + base_msg.set_target_tab_id(kTargetTab); + + BlimpMessage navigation_state_msg = base_msg; + navigation_state_msg.mutable_navigation()->set_type( + NavigationMessage::NAVIGATION_STATE_CHANGED); + navigation_state_msg.mutable_navigation() + ->mutable_navigation_state_changed() + ->set_url("http://foo.com"); + navigation_state_msg.mutable_navigation() + ->mutable_navigation_state_changed() + ->set_favicon("bytes!"); + navigation_state_msg.mutable_navigation() + ->mutable_navigation_state_changed() + ->set_title("FooCo"); + navigation_state_msg.mutable_navigation() + ->mutable_navigation_state_changed() + ->set_loading(true); + VerifyLogOutput( + "type=NAVIGATION subtype=NAVIGATION_STATE_CHANGED url=\"http://foo.com\" " + "favicon_size=6 title=\"FooCo\" loading=true target_tab_id=123", + navigation_state_msg); + + BlimpMessage load_url_msg = base_msg; + load_url_msg.mutable_navigation()->set_type(NavigationMessage::LOAD_URL); + load_url_msg.mutable_navigation()->mutable_load_url()->set_url( + "http://foo.com"); + VerifyLogOutput( + "type=NAVIGATION subtype=LOAD_URL url=\"http://foo.com\" " + "target_tab_id=123", + load_url_msg); + + BlimpMessage go_back_msg = base_msg; + go_back_msg.mutable_navigation()->set_type(NavigationMessage::GO_BACK); + VerifyLogOutput("type=NAVIGATION subtype=GO_BACK target_tab_id=123", + go_back_msg); + + BlimpMessage go_forward_msg = base_msg; + go_forward_msg.mutable_navigation()->set_type(NavigationMessage::GO_FORWARD); + VerifyLogOutput("type=NAVIGATION subtype=GO_FORWARD target_tab_id=123", + go_forward_msg); + + BlimpMessage reload_msg = base_msg; + reload_msg.mutable_navigation()->set_type(NavigationMessage::RELOAD); + VerifyLogOutput("type=NAVIGATION subtype=RELOAD target_tab_id=123", + reload_msg); +} + +TEST_F(LoggingTest, TabControl) { + BlimpMessage base_msg; + base_msg.set_type(BlimpMessage::TAB_CONTROL); + base_msg.set_target_tab_id(kTargetTab); + + BlimpMessage create_tab_msg = base_msg; + create_tab_msg.mutable_tab_control()->set_type(TabControlMessage::CREATE_TAB); + VerifyLogOutput("type=TAB_CONTROL subtype=CREATE_TAB target_tab_id=123", + create_tab_msg); + + BlimpMessage close_tab_msg = base_msg; + close_tab_msg.mutable_tab_control()->set_type(TabControlMessage::CLOSE_TAB); + VerifyLogOutput("type=TAB_CONTROL subtype=CLOSE_TAB target_tab_id=123", + close_tab_msg); + + BlimpMessage size_msg = base_msg; + size_msg.mutable_tab_control()->set_type(TabControlMessage::SIZE); + size_msg.mutable_tab_control()->mutable_size()->set_width(640); + size_msg.mutable_tab_control()->mutable_size()->set_height(480); + size_msg.mutable_tab_control()->mutable_size()->set_device_pixel_ratio(2); + VerifyLogOutput( + "type=TAB_CONTROL subtype=SIZE size=640x480:2.00 target_tab_id=123", + size_msg); +} + +TEST_F(LoggingTest, ProtocolControl) { + BlimpMessage base_msg; + base_msg.set_type(BlimpMessage::PROTOCOL_CONTROL); + + BlimpMessage start_connection_msg = base_msg; + start_connection_msg.mutable_protocol_control()->set_type( + ProtocolControlMessage::START_CONNECTION); + start_connection_msg.mutable_protocol_control() + ->mutable_start_connection() + ->set_client_token("token"); + start_connection_msg.mutable_protocol_control() + ->mutable_start_connection() + ->set_protocol_version(2); + VerifyLogOutput( + "type=PROTOCOL_CONTROL subtype=START_CONNECTION " + "client_token=\"token\" protocol_version=2", + start_connection_msg); + + BlimpMessage checkpoint_msg = base_msg; + start_connection_msg.mutable_protocol_control()->set_type( + ProtocolControlMessage::CHECKPOINT_ACK); + start_connection_msg.mutable_protocol_control() + ->mutable_checkpoint_ack() + ->set_checkpoint_id(123); + VerifyLogOutput( + "type=PROTOCOL_CONTROL subtype=CHECKPOINT_ACK " + "checkpoint_id=123", + start_connection_msg); +} + +TEST_F(LoggingTest, RenderWidget) { + BlimpMessage base_msg; + base_msg.set_type(BlimpMessage::RENDER_WIDGET); + base_msg.mutable_render_widget()->set_render_widget_id(123); + + BlimpMessage initialize_msg = base_msg; + initialize_msg.mutable_render_widget()->set_type( + RenderWidgetMessage::INITIALIZE); + VerifyLogOutput("type=RENDER_WIDGET subtype=INITIALIZE render_widget_id=123", + initialize_msg); + + BlimpMessage created_msg = base_msg; + created_msg.mutable_render_widget()->set_type( + RenderWidgetMessage::CREATED); + VerifyLogOutput("type=RENDER_WIDGET subtype=CREATED render_widget_id=123", + created_msg); + + BlimpMessage deleted_msg = base_msg; + deleted_msg.mutable_render_widget()->set_type(RenderWidgetMessage::DELETED); + VerifyLogOutput("type=RENDER_WIDGET subtype=DELETED render_widget_id=123", + deleted_msg); +} + +} // namespace +} // namespace blimp diff --git a/blimp/common/proto/input.proto b/blimp/common/proto/input.proto index 2a59205..0905884 100644 --- a/blimp/common/proto/input.proto +++ b/blimp/common/proto/input.proto @@ -63,6 +63,8 @@ message InputMessage { // This is a subset of WebGestureType events. We only support a small set // of these with the existing protocol. + // TODO(dtrainor): Modify these enum values to be consistent with the rest + // of BlimpMessage subtype enums. Type_GestureScrollBegin = 1; Type_GestureScrollEnd = 2; Type_GestureScrollUpdate = 3; diff --git a/blimp/net/BUILD.gn b/blimp/net/BUILD.gn index 627b09b..aeafbae 100644 --- a/blimp/net/BUILD.gn +++ b/blimp/net/BUILD.gn @@ -105,6 +105,7 @@ source_set("unit_tests") { "//base", "//base/test:run_all_unittests", "//base/test:test_support", + "//blimp/common:blimp_common", "//blimp/common/proto", "//net:test_support", "//testing/gmock", diff --git a/blimp/net/blimp_connection.cc b/blimp/net/blimp_connection.cc index d2e2f78..ca6e178 100644 --- a/blimp/net/blimp_connection.cc +++ b/blimp/net/blimp_connection.cc @@ -9,6 +9,7 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/message_loop/message_loop.h" +#include "blimp/common/logging.h" #include "blimp/common/proto/blimp_message.pb.h" #include "blimp/net/blimp_message_processor.h" #include "blimp/net/blimp_message_pump.h" diff --git a/blimp/net/blimp_message_demultiplexer.cc b/blimp/net/blimp_message_demultiplexer.cc index eb9edff..22189b4 100644 --- a/blimp/net/blimp_message_demultiplexer.cc +++ b/blimp/net/blimp_message_demultiplexer.cc @@ -7,6 +7,7 @@ #include <string> #include "base/strings/stringprintf.h" +#include "blimp/common/logging.h" #include "blimp/net/common.h" #include "net/base/net_errors.h" diff --git a/blimp/net/blimp_message_output_buffer.cc b/blimp/net/blimp_message_output_buffer.cc index 678acc3..cf194aa 100644 --- a/blimp/net/blimp_message_output_buffer.cc +++ b/blimp/net/blimp_message_output_buffer.cc @@ -8,6 +8,7 @@ #include "base/macros.h" #include "base/message_loop/message_loop.h" +#include "blimp/common/logging.h" #include "blimp/common/proto/blimp_message.pb.h" #include "net/base/net_errors.h" @@ -59,7 +60,7 @@ int BlimpMessageOutputBuffer::GetUnacknowledgedMessageCountForTest() const { void BlimpMessageOutputBuffer::ProcessMessage( scoped_ptr<BlimpMessage> message, const net::CompletionCallback& callback) { - DVLOG(2) << "OutputBuffer::ProcessMessage " << message.get(); + DVLOG(2) << "OutputBuffer::ProcessMessage " << *message; message->set_message_id(++prev_message_id_); diff --git a/blimp/net/blimp_message_pump.cc b/blimp/net/blimp_message_pump.cc index 046df8e..37b084ee 100644 --- a/blimp/net/blimp_message_pump.cc +++ b/blimp/net/blimp_message_pump.cc @@ -5,6 +5,7 @@ #include "blimp/net/blimp_message_pump.h" #include "base/macros.h" +#include "blimp/common/logging.h" #include "blimp/common/proto/blimp_message.pb.h" #include "blimp/net/blimp_message_processor.h" #include "blimp/net/common.h" diff --git a/blimp/net/common.cc b/blimp/net/common.cc index 25eb09c..5a74de2 100644 --- a/blimp/net/common.cc +++ b/blimp/net/common.cc @@ -4,21 +4,9 @@ #include "blimp/net/common.h" -#include <iostream> - -#include "blimp/common/proto/blimp_message.pb.h" -#include "net/base/ip_address_number.h" - namespace blimp { const size_t kMaxPacketPayloadSizeBytes = 1024 * 1024; // 1MB const size_t kPacketHeaderSizeBytes = 4; -std::ostream& operator<<(std::ostream& out, const BlimpMessage& message) { - // TODO(kmarshall): Look into including type-specific fields in the output. - out << "<BlimpMessage type=" << message.type() - << ", size=" << message.ByteSize() << ">"; - return out; -} - } // namespace blimp diff --git a/blimp/net/common.h b/blimp/net/common.h index 2923104..4a7dda5 100644 --- a/blimp/net/common.h +++ b/blimp/net/common.h @@ -7,24 +7,15 @@ #include <stddef.h> -#include <string> - #include "blimp/net/blimp_net_export.h" -#include "net/base/ip_address_number.h" namespace blimp { -class BlimpMessage; - // TODO(kmarshall): Apply SCIENCE to determine a better constant here. // See crbug.com/542464 extern const size_t BLIMP_NET_EXPORT kMaxPacketPayloadSizeBytes; extern const size_t BLIMP_NET_EXPORT kPacketHeaderSizeBytes; -// Serializes human-readable BlimpMessage header info, for logging purposes. -BLIMP_NET_EXPORT std::ostream& operator<<(std::ostream& out, - const BlimpMessage& message); - } // namespace blimp #endif // BLIMP_NET_COMMON_H_ diff --git a/blimp/net/engine_authentication_handler.cc b/blimp/net/engine_authentication_handler.cc index 41813fc..753438e 100644 --- a/blimp/net/engine_authentication_handler.cc +++ b/blimp/net/engine_authentication_handler.cc @@ -4,9 +4,12 @@ #include "blimp/net/engine_authentication_handler.h" +#include <string> + #include "base/callback_helpers.h" #include "base/logging.h" #include "base/timer/timer.h" +#include "blimp/common/logging.h" #include "blimp/common/proto/blimp_message.pb.h" #include "blimp/net/blimp_connection.h" #include "blimp/net/blimp_message_processor.h" diff --git a/blimp/net/null_blimp_message_processor.cc b/blimp/net/null_blimp_message_processor.cc index 3b335ac..40e9388 100644 --- a/blimp/net/null_blimp_message_processor.cc +++ b/blimp/net/null_blimp_message_processor.cc @@ -4,6 +4,7 @@ #include "blimp/net/null_blimp_message_processor.h" +#include "blimp/common/logging.h" #include "blimp/net/common.h" namespace blimp { |