Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 "base/basictypes.h"
7 #include "COMMessageFilter.h"
8 #include "base/message_loop.h"
9 #include "mozilla/plugins/PluginModuleChild.h"
11 #include <stdio.h>
13 namespace mozilla {
14 namespace plugins {
16 HRESULT
17 COMMessageFilter::QueryInterface(REFIID riid, void** ppv)
18 {
19 if (riid == IID_IUnknown || riid == IID_IMessageFilter) {
20 *ppv = static_cast<IMessageFilter*>(this);
21 AddRef();
22 return S_OK;
23 }
24 return E_NOINTERFACE;
25 }
27 DWORD COMMessageFilter::AddRef()
28 {
29 ++mRefCnt;
30 return mRefCnt;
31 }
33 DWORD COMMessageFilter::Release()
34 {
35 DWORD r = --mRefCnt;
36 if (0 == r)
37 delete this;
38 return r;
39 }
41 DWORD
42 COMMessageFilter::HandleInComingCall(DWORD dwCallType,
43 HTASK htaskCaller,
44 DWORD dwTickCount,
45 LPINTERFACEINFO lpInterfaceInfo)
46 {
47 if (mPreviousFilter)
48 return mPreviousFilter->HandleInComingCall(dwCallType, htaskCaller,
49 dwTickCount, lpInterfaceInfo);
50 return SERVERCALL_ISHANDLED;
51 }
53 DWORD
54 COMMessageFilter::RetryRejectedCall(HTASK htaskCallee,
55 DWORD dwTickCount,
56 DWORD dwRejectType)
57 {
58 if (mPreviousFilter)
59 return mPreviousFilter->RetryRejectedCall(htaskCallee, dwTickCount,
60 dwRejectType);
61 return -1;
62 }
64 DWORD
65 COMMessageFilter::MessagePending(HTASK htaskCallee,
66 DWORD dwTickCount,
67 DWORD dwPendingType)
68 {
69 mPlugin->FlushPendingInterruptQueue();
70 if (mPreviousFilter)
71 return mPreviousFilter->MessagePending(htaskCallee, dwTickCount,
72 dwPendingType);
73 return PENDINGMSG_WAITNOPROCESS;
74 }
76 void
77 COMMessageFilter::Initialize(PluginModuleChild* module)
78 {
79 nsRefPtr<COMMessageFilter> f = new COMMessageFilter(module);
80 ::CoRegisterMessageFilter(f, getter_AddRefs(f->mPreviousFilter));
81 }
83 } // namespace plugins
84 } // namespace mozilla