Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "nsHtml5TreeOpStage.h"
7 nsHtml5TreeOpStage::nsHtml5TreeOpStage()
8 : mMutex("nsHtml5TreeOpStage mutex")
9 {
10 }
12 nsHtml5TreeOpStage::~nsHtml5TreeOpStage()
13 {
14 }
16 void
17 nsHtml5TreeOpStage::MoveOpsFrom(nsTArray<nsHtml5TreeOperation>& aOpQueue)
18 {
19 mozilla::MutexAutoLock autoLock(mMutex);
20 if (mOpQueue.IsEmpty()) {
21 mOpQueue.SwapElements(aOpQueue);
22 } else {
23 mOpQueue.MoveElementsFrom(aOpQueue);
24 }
25 }
27 void
28 nsHtml5TreeOpStage::MoveOpsAndSpeculativeLoadsTo(nsTArray<nsHtml5TreeOperation>& aOpQueue,
29 nsTArray<nsHtml5SpeculativeLoad>& aSpeculativeLoadQueue)
30 {
31 mozilla::MutexAutoLock autoLock(mMutex);
32 if (aOpQueue.IsEmpty()) {
33 mOpQueue.SwapElements(aOpQueue);
34 } else {
35 aOpQueue.MoveElementsFrom(mOpQueue);
36 }
37 if (aSpeculativeLoadQueue.IsEmpty()) {
38 mSpeculativeLoadQueue.SwapElements(aSpeculativeLoadQueue);
39 } else {
40 aSpeculativeLoadQueue.MoveElementsFrom(mSpeculativeLoadQueue);
41 }
42 }
44 void
45 nsHtml5TreeOpStage::MoveSpeculativeLoadsFrom(nsTArray<nsHtml5SpeculativeLoad>& aSpeculativeLoadQueue)
46 {
47 mozilla::MutexAutoLock autoLock(mMutex);
48 if (mSpeculativeLoadQueue.IsEmpty()) {
49 mSpeculativeLoadQueue.SwapElements(aSpeculativeLoadQueue);
50 } else {
51 mSpeculativeLoadQueue.MoveElementsFrom(aSpeculativeLoadQueue);
52 }
53 }
55 void
56 nsHtml5TreeOpStage::MoveSpeculativeLoadsTo(nsTArray<nsHtml5SpeculativeLoad>& aSpeculativeLoadQueue)
57 {
58 mozilla::MutexAutoLock autoLock(mMutex);
59 if (aSpeculativeLoadQueue.IsEmpty()) {
60 mSpeculativeLoadQueue.SwapElements(aSpeculativeLoadQueue);
61 } else {
62 aSpeculativeLoadQueue.MoveElementsFrom(mSpeculativeLoadQueue);
63 }
64 }
66 #ifdef DEBUG
67 void
68 nsHtml5TreeOpStage::AssertEmpty()
69 {
70 mozilla::MutexAutoLock autoLock(mMutex);
71 // This shouldn't really need the mutex
72 NS_ASSERTION(mOpQueue.IsEmpty(), "The stage was supposed to be empty.");
73 }
74 #endif