1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/plugins/ipc/ChildTimer.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,40 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * vim: sw=2 ts=8 et : 1.6 + */ 1.7 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.10 + 1.11 +#include "ChildTimer.h" 1.12 +#include "PluginInstanceChild.h" 1.13 +#include "nsComponentManagerUtils.h" 1.14 + 1.15 +namespace mozilla { 1.16 +namespace plugins { 1.17 + 1.18 +ChildTimer::ChildTimer(PluginInstanceChild* instance, 1.19 + uint32_t interval, 1.20 + bool repeat, 1.21 + TimerFunc func) 1.22 + : mInstance(instance) 1.23 + , mFunc(func) 1.24 + , mRepeating(repeat) 1.25 + , mID(gNextTimerID++) 1.26 +{ 1.27 + mTimer.Start(base::TimeDelta::FromMilliseconds(interval), 1.28 + this, &ChildTimer::Run); 1.29 +} 1.30 + 1.31 +uint32_t 1.32 +ChildTimer::gNextTimerID = 1; 1.33 + 1.34 +void 1.35 +ChildTimer::Run() 1.36 +{ 1.37 + if (!mRepeating) 1.38 + mTimer.Stop(); 1.39 + mFunc(mInstance->GetNPP(), mID); 1.40 +} 1.41 + 1.42 +} // namespace plugins 1.43 +} // namespace mozilla