Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : * vim: sw=2 ts=8 et :
3 : */
4 : /* This Source Code Form is subject to the terms of the Mozilla Public
5 : * License, v. 2.0. If a copy of the MPL was not distributed with this
6 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 :
8 : #include "ChildAsyncCall.h"
9 : #include "PluginInstanceChild.h"
10 :
11 : namespace mozilla {
12 : namespace plugins {
13 :
14 0 : ChildAsyncCall::ChildAsyncCall(PluginInstanceChild* instance,
15 : PluginThreadCallback aFunc,
16 0 : void* aUserData)
17 : : CancelableRunnable("plugins::ChildAsyncCall")
18 : , mInstance(instance)
19 : , mFunc(aFunc)
20 0 : , mData(aUserData)
21 : {
22 0 : }
23 :
24 : nsresult
25 0 : ChildAsyncCall::Cancel()
26 : {
27 0 : mInstance = nullptr;
28 0 : mFunc = nullptr;
29 0 : mData = nullptr;
30 0 : return NS_OK;
31 : }
32 :
33 : void
34 0 : ChildAsyncCall::RemoveFromAsyncList()
35 : {
36 0 : if (mInstance) {
37 0 : MutexAutoLock lock(mInstance->mAsyncCallMutex);
38 0 : mInstance->mPendingAsyncCalls.RemoveElement(this);
39 : }
40 0 : }
41 :
42 : NS_IMETHODIMP
43 0 : ChildAsyncCall::Run()
44 : {
45 0 : RemoveFromAsyncList();
46 :
47 0 : if (mFunc)
48 0 : mFunc(mData);
49 :
50 0 : return NS_OK;
51 : }
52 :
53 : } // namespace plugins
54 : } // namespace mozilla
|