michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: sw=4 ts=4 et : michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include michael@0: michael@0: #include "NestedLoopTimer.h" michael@0: #include "mozilla/plugins/PluginModuleChild.h" michael@0: michael@0: namespace mozilla { michael@0: namespace plugins { michael@0: michael@0: NestedLoopTimer::NestedLoopTimer(PluginModuleChild *pmc): michael@0: QObject(), mModule(pmc), mQTimer(nullptr) michael@0: { michael@0: } michael@0: michael@0: NestedLoopTimer::~NestedLoopTimer() michael@0: { michael@0: if (mQTimer) { michael@0: mQTimer->stop(); michael@0: delete mQTimer; michael@0: mQTimer = nullptr; michael@0: } michael@0: } michael@0: michael@0: void NestedLoopTimer::timeOut() michael@0: { michael@0: // just detected a nested loop; start a timer that will michael@0: // periodically rpc-call back into the browser and process some michael@0: // events michael@0: mQTimer = new QTimer(this); michael@0: QObject::connect(mQTimer, SIGNAL(timeout()), this, michael@0: SLOT(processSomeEvents())); michael@0: mQTimer->setInterval(kNestedLoopDetectorIntervalMs); michael@0: mQTimer->start(); michael@0: } michael@0: michael@0: void NestedLoopTimer::processSomeEvents() michael@0: { michael@0: if (mModule) michael@0: mModule->CallProcessSomeEvents(); michael@0: } michael@0: michael@0: } /* namespace plugins */ michael@0: } /* namespace mozilla */