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
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #include "base/basictypes.h" |
michael@0 | 6 | |
michael@0 | 7 | #include "COMMessageFilter.h" |
michael@0 | 8 | #include "base/message_loop.h" |
michael@0 | 9 | #include "mozilla/plugins/PluginModuleChild.h" |
michael@0 | 10 | |
michael@0 | 11 | #include <stdio.h> |
michael@0 | 12 | |
michael@0 | 13 | namespace mozilla { |
michael@0 | 14 | namespace plugins { |
michael@0 | 15 | |
michael@0 | 16 | HRESULT |
michael@0 | 17 | COMMessageFilter::QueryInterface(REFIID riid, void** ppv) |
michael@0 | 18 | { |
michael@0 | 19 | if (riid == IID_IUnknown || riid == IID_IMessageFilter) { |
michael@0 | 20 | *ppv = static_cast<IMessageFilter*>(this); |
michael@0 | 21 | AddRef(); |
michael@0 | 22 | return S_OK; |
michael@0 | 23 | } |
michael@0 | 24 | return E_NOINTERFACE; |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | DWORD COMMessageFilter::AddRef() |
michael@0 | 28 | { |
michael@0 | 29 | ++mRefCnt; |
michael@0 | 30 | return mRefCnt; |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | DWORD COMMessageFilter::Release() |
michael@0 | 34 | { |
michael@0 | 35 | DWORD r = --mRefCnt; |
michael@0 | 36 | if (0 == r) |
michael@0 | 37 | delete this; |
michael@0 | 38 | return r; |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | DWORD |
michael@0 | 42 | COMMessageFilter::HandleInComingCall(DWORD dwCallType, |
michael@0 | 43 | HTASK htaskCaller, |
michael@0 | 44 | DWORD dwTickCount, |
michael@0 | 45 | LPINTERFACEINFO lpInterfaceInfo) |
michael@0 | 46 | { |
michael@0 | 47 | if (mPreviousFilter) |
michael@0 | 48 | return mPreviousFilter->HandleInComingCall(dwCallType, htaskCaller, |
michael@0 | 49 | dwTickCount, lpInterfaceInfo); |
michael@0 | 50 | return SERVERCALL_ISHANDLED; |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | DWORD |
michael@0 | 54 | COMMessageFilter::RetryRejectedCall(HTASK htaskCallee, |
michael@0 | 55 | DWORD dwTickCount, |
michael@0 | 56 | DWORD dwRejectType) |
michael@0 | 57 | { |
michael@0 | 58 | if (mPreviousFilter) |
michael@0 | 59 | return mPreviousFilter->RetryRejectedCall(htaskCallee, dwTickCount, |
michael@0 | 60 | dwRejectType); |
michael@0 | 61 | return -1; |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | DWORD |
michael@0 | 65 | COMMessageFilter::MessagePending(HTASK htaskCallee, |
michael@0 | 66 | DWORD dwTickCount, |
michael@0 | 67 | DWORD dwPendingType) |
michael@0 | 68 | { |
michael@0 | 69 | mPlugin->FlushPendingInterruptQueue(); |
michael@0 | 70 | if (mPreviousFilter) |
michael@0 | 71 | return mPreviousFilter->MessagePending(htaskCallee, dwTickCount, |
michael@0 | 72 | dwPendingType); |
michael@0 | 73 | return PENDINGMSG_WAITNOPROCESS; |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | void |
michael@0 | 77 | COMMessageFilter::Initialize(PluginModuleChild* module) |
michael@0 | 78 | { |
michael@0 | 79 | nsRefPtr<COMMessageFilter> f = new COMMessageFilter(module); |
michael@0 | 80 | ::CoRegisterMessageFilter(f, getter_AddRefs(f->mPreviousFilter)); |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | } // namespace plugins |
michael@0 | 84 | } // namespace mozilla |