michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: // Original author: ekr@rtfm.com michael@0: michael@0: #include "logging.h" michael@0: #include "transportflow.h" michael@0: #include "transportlayerlog.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: MOZ_MTLOG_MODULE("mtransport") michael@0: michael@0: void TransportLayerLogging::WasInserted() { michael@0: if (downward_) { michael@0: downward_->SignalStateChange.connect( michael@0: this, &TransportLayerLogging::StateChange); michael@0: downward_->SignalPacketReceived.connect( michael@0: this, &TransportLayerLogging::PacketReceived); michael@0: TL_SET_STATE(downward_->state()); michael@0: } michael@0: } michael@0: michael@0: TransportResult michael@0: TransportLayerLogging::SendPacket(const unsigned char *data, size_t len) { michael@0: MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "SendPacket(" << len << ")"); michael@0: michael@0: if (downward_) { michael@0: return downward_->SendPacket(data, len); michael@0: } michael@0: else { michael@0: return static_cast(len); michael@0: } michael@0: } michael@0: michael@0: void TransportLayerLogging::StateChange(TransportLayer *layer, State state) { michael@0: MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Received StateChange to " << state); michael@0: michael@0: TL_SET_STATE(state); michael@0: } michael@0: michael@0: void TransportLayerLogging::PacketReceived(TransportLayer* layer, michael@0: const unsigned char *data, michael@0: size_t len) { michael@0: MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "PacketReceived(" << len << ")"); michael@0: michael@0: SignalPacketReceived(this, data, len); michael@0: } michael@0: michael@0: michael@0: michael@0: } // close namespace