Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #include "nsHtml5TreeOpStage.h" |
michael@0 | 6 | |
michael@0 | 7 | nsHtml5TreeOpStage::nsHtml5TreeOpStage() |
michael@0 | 8 | : mMutex("nsHtml5TreeOpStage mutex") |
michael@0 | 9 | { |
michael@0 | 10 | } |
michael@0 | 11 | |
michael@0 | 12 | nsHtml5TreeOpStage::~nsHtml5TreeOpStage() |
michael@0 | 13 | { |
michael@0 | 14 | } |
michael@0 | 15 | |
michael@0 | 16 | void |
michael@0 | 17 | nsHtml5TreeOpStage::MoveOpsFrom(nsTArray<nsHtml5TreeOperation>& aOpQueue) |
michael@0 | 18 | { |
michael@0 | 19 | mozilla::MutexAutoLock autoLock(mMutex); |
michael@0 | 20 | if (mOpQueue.IsEmpty()) { |
michael@0 | 21 | mOpQueue.SwapElements(aOpQueue); |
michael@0 | 22 | } else { |
michael@0 | 23 | mOpQueue.MoveElementsFrom(aOpQueue); |
michael@0 | 24 | } |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | void |
michael@0 | 28 | nsHtml5TreeOpStage::MoveOpsAndSpeculativeLoadsTo(nsTArray<nsHtml5TreeOperation>& aOpQueue, |
michael@0 | 29 | nsTArray<nsHtml5SpeculativeLoad>& aSpeculativeLoadQueue) |
michael@0 | 30 | { |
michael@0 | 31 | mozilla::MutexAutoLock autoLock(mMutex); |
michael@0 | 32 | if (aOpQueue.IsEmpty()) { |
michael@0 | 33 | mOpQueue.SwapElements(aOpQueue); |
michael@0 | 34 | } else { |
michael@0 | 35 | aOpQueue.MoveElementsFrom(mOpQueue); |
michael@0 | 36 | } |
michael@0 | 37 | if (aSpeculativeLoadQueue.IsEmpty()) { |
michael@0 | 38 | mSpeculativeLoadQueue.SwapElements(aSpeculativeLoadQueue); |
michael@0 | 39 | } else { |
michael@0 | 40 | aSpeculativeLoadQueue.MoveElementsFrom(mSpeculativeLoadQueue); |
michael@0 | 41 | } |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | void |
michael@0 | 45 | nsHtml5TreeOpStage::MoveSpeculativeLoadsFrom(nsTArray<nsHtml5SpeculativeLoad>& aSpeculativeLoadQueue) |
michael@0 | 46 | { |
michael@0 | 47 | mozilla::MutexAutoLock autoLock(mMutex); |
michael@0 | 48 | if (mSpeculativeLoadQueue.IsEmpty()) { |
michael@0 | 49 | mSpeculativeLoadQueue.SwapElements(aSpeculativeLoadQueue); |
michael@0 | 50 | } else { |
michael@0 | 51 | mSpeculativeLoadQueue.MoveElementsFrom(aSpeculativeLoadQueue); |
michael@0 | 52 | } |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | void |
michael@0 | 56 | nsHtml5TreeOpStage::MoveSpeculativeLoadsTo(nsTArray<nsHtml5SpeculativeLoad>& aSpeculativeLoadQueue) |
michael@0 | 57 | { |
michael@0 | 58 | mozilla::MutexAutoLock autoLock(mMutex); |
michael@0 | 59 | if (aSpeculativeLoadQueue.IsEmpty()) { |
michael@0 | 60 | mSpeculativeLoadQueue.SwapElements(aSpeculativeLoadQueue); |
michael@0 | 61 | } else { |
michael@0 | 62 | aSpeculativeLoadQueue.MoveElementsFrom(mSpeculativeLoadQueue); |
michael@0 | 63 | } |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | #ifdef DEBUG |
michael@0 | 67 | void |
michael@0 | 68 | nsHtml5TreeOpStage::AssertEmpty() |
michael@0 | 69 | { |
michael@0 | 70 | mozilla::MutexAutoLock autoLock(mMutex); |
michael@0 | 71 | // This shouldn't really need the mutex |
michael@0 | 72 | NS_ASSERTION(mOpQueue.IsEmpty(), "The stage was supposed to be empty."); |
michael@0 | 73 | } |
michael@0 | 74 | #endif |