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