media/mtransport/transportlayerlog.cpp

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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/. */
     7 // Original author: ekr@rtfm.com
     9 #include "logging.h"
    10 #include "transportflow.h"
    11 #include "transportlayerlog.h"
    13 namespace mozilla {
    15 MOZ_MTLOG_MODULE("mtransport")
    17 void TransportLayerLogging::WasInserted() {
    18   if (downward_) {
    19     downward_->SignalStateChange.connect(
    20         this, &TransportLayerLogging::StateChange);
    21     downward_->SignalPacketReceived.connect(
    22         this, &TransportLayerLogging::PacketReceived);
    23     TL_SET_STATE(downward_->state());
    24   }
    25 }
    27 TransportResult
    28 TransportLayerLogging::SendPacket(const unsigned char *data, size_t len) {
    29   MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "SendPacket(" << len << ")");
    31   if (downward_) {
    32     return downward_->SendPacket(data, len);
    33   }
    34   else {
    35     return static_cast<TransportResult>(len);
    36   }
    37 }
    39 void TransportLayerLogging::StateChange(TransportLayer *layer, State state) {
    40   MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Received StateChange to " << state);
    42   TL_SET_STATE(state);
    43 }
    45 void TransportLayerLogging::PacketReceived(TransportLayer* layer,
    46                                            const unsigned char *data,
    47                                            size_t len) {
    48   MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "PacketReceived(" << len << ")");
    50   SignalPacketReceived(this, data, len);
    51 }
    55 }  // close namespace

mercurial