transportlayer.cpp (1368B)
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 #include "transportlayer.h" 9 10 #include "logging.h" 11 12 // Logging context 13 namespace mozilla { 14 15 MOZ_MTLOG_MODULE("mtransport") 16 17 nsresult TransportLayer::Init() { 18 if (state_ != TS_NONE) return state_ == TS_ERROR ? NS_ERROR_FAILURE : NS_OK; 19 20 nsresult rv = InitInternal(); 21 22 if (!NS_SUCCEEDED(rv)) { 23 state_ = TS_ERROR; 24 return rv; 25 } 26 state_ = TS_INIT; 27 28 return NS_OK; 29 } 30 31 void TransportLayer::Chain(TransportLayer* downward) { 32 downward_ = downward; 33 MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Inserted: downward='" 34 << (downward ? downward->id() : "none") 35 << "'"); 36 37 WasInserted(); 38 } 39 40 void TransportLayer::SetState(State state, const char* file, unsigned line) { 41 if (state != state_) { 42 MOZ_MTLOG(state == TS_ERROR ? ML_ERROR : ML_DEBUG, 43 file << ":" << line << ": " << LAYER_INFO << "state " << state_ 44 << "->" << state); 45 state_ = state; 46 SignalStateChange(this, state); 47 } 48 } 49 50 } // namespace mozilla