1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/plugins/ipc/NestedLoopTimer.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,48 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * vim: sw=4 ts=4 et : 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#include <QtCore/QTimer> 1.11 + 1.12 +#include "NestedLoopTimer.h" 1.13 +#include "mozilla/plugins/PluginModuleChild.h" 1.14 + 1.15 +namespace mozilla { 1.16 +namespace plugins { 1.17 + 1.18 +NestedLoopTimer::NestedLoopTimer(PluginModuleChild *pmc): 1.19 + QObject(), mModule(pmc), mQTimer(nullptr) 1.20 +{ 1.21 +} 1.22 + 1.23 +NestedLoopTimer::~NestedLoopTimer() 1.24 +{ 1.25 + if (mQTimer) { 1.26 + mQTimer->stop(); 1.27 + delete mQTimer; 1.28 + mQTimer = nullptr; 1.29 + } 1.30 +} 1.31 + 1.32 +void NestedLoopTimer::timeOut() 1.33 +{ 1.34 + // just detected a nested loop; start a timer that will 1.35 + // periodically rpc-call back into the browser and process some 1.36 + // events 1.37 + mQTimer = new QTimer(this); 1.38 + QObject::connect(mQTimer, SIGNAL(timeout()), this, 1.39 + SLOT(processSomeEvents())); 1.40 + mQTimer->setInterval(kNestedLoopDetectorIntervalMs); 1.41 + mQTimer->start(); 1.42 +} 1.43 + 1.44 +void NestedLoopTimer::processSomeEvents() 1.45 +{ 1.46 + if (mModule) 1.47 + mModule->CallProcessSomeEvents(); 1.48 +} 1.49 + 1.50 +} /* namespace plugins */ 1.51 +} /* namespace mozilla */