Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 : * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : // Original author: ekr@rtfm.com
8 :
9 : #include "logging.h"
10 : #include "transportflow.h"
11 : #include "transportlayerlog.h"
12 :
13 : namespace mozilla {
14 :
15 0 : MOZ_MTLOG_MODULE("mtransport")
16 :
17 0 : void TransportLayerLogging::WasInserted() {
18 0 : if (downward_) {
19 0 : downward_->SignalStateChange.connect(
20 0 : this, &TransportLayerLogging::StateChange);
21 0 : downward_->SignalPacketReceived.connect(
22 0 : this, &TransportLayerLogging::PacketReceived);
23 0 : TL_SET_STATE(downward_->state());
24 : }
25 0 : }
26 :
27 : TransportResult
28 0 : TransportLayerLogging::SendPacket(const unsigned char *data, size_t len) {
29 0 : MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "SendPacket(" << len << ")");
30 :
31 0 : if (downward_) {
32 0 : return downward_->SendPacket(data, len);
33 : }
34 0 : return static_cast<TransportResult>(len);
35 : }
36 :
37 0 : void TransportLayerLogging::StateChange(TransportLayer *layer, State state) {
38 0 : MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Received StateChange to " << state);
39 :
40 0 : TL_SET_STATE(state);
41 0 : }
42 :
43 0 : void TransportLayerLogging::PacketReceived(TransportLayer* layer,
44 : const unsigned char *data,
45 : size_t len) {
46 0 : MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "PacketReceived(" << len << ")");
47 :
48 0 : SignalPacketReceived(this, data, len);
49 0 : }
50 :
51 :
52 :
53 : } // close namespace
|