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 | #ifndef __IPC_GLUE_MESSAGEPUMP_H__ |
michael@0 | 6 | #define __IPC_GLUE_MESSAGEPUMP_H__ |
michael@0 | 7 | |
michael@0 | 8 | #include "base/message_pump_default.h" |
michael@0 | 9 | #include "base/time.h" |
michael@0 | 10 | #include "mozilla/Attributes.h" |
michael@0 | 11 | #include "nsAutoPtr.h" |
michael@0 | 12 | #include "nsCOMPtr.h" |
michael@0 | 13 | |
michael@0 | 14 | class nsIThread; |
michael@0 | 15 | class nsITimer; |
michael@0 | 16 | |
michael@0 | 17 | namespace mozilla { |
michael@0 | 18 | namespace ipc { |
michael@0 | 19 | |
michael@0 | 20 | class DoWorkRunnable; |
michael@0 | 21 | |
michael@0 | 22 | class MessagePump : public base::MessagePumpDefault |
michael@0 | 23 | { |
michael@0 | 24 | friend class DoWorkRunnable; |
michael@0 | 25 | |
michael@0 | 26 | public: |
michael@0 | 27 | MessagePump(); |
michael@0 | 28 | |
michael@0 | 29 | // From base::MessagePump. |
michael@0 | 30 | virtual void |
michael@0 | 31 | Run(base::MessagePump::Delegate* aDelegate) MOZ_OVERRIDE; |
michael@0 | 32 | |
michael@0 | 33 | // From base::MessagePump. |
michael@0 | 34 | virtual void |
michael@0 | 35 | ScheduleWork() MOZ_OVERRIDE; |
michael@0 | 36 | |
michael@0 | 37 | // From base::MessagePump. |
michael@0 | 38 | virtual void |
michael@0 | 39 | ScheduleWorkForNestedLoop() MOZ_OVERRIDE; |
michael@0 | 40 | |
michael@0 | 41 | // From base::MessagePump. |
michael@0 | 42 | virtual void |
michael@0 | 43 | ScheduleDelayedWork(const base::TimeTicks& aDelayedWorkTime) MOZ_OVERRIDE; |
michael@0 | 44 | |
michael@0 | 45 | protected: |
michael@0 | 46 | virtual ~MessagePump(); |
michael@0 | 47 | |
michael@0 | 48 | private: |
michael@0 | 49 | // Only called by DoWorkRunnable. |
michael@0 | 50 | void DoDelayedWork(base::MessagePump::Delegate* aDelegate); |
michael@0 | 51 | |
michael@0 | 52 | protected: |
michael@0 | 53 | // mDelayedWorkTimer and mThread are set in Run() by this class or its |
michael@0 | 54 | // subclasses. |
michael@0 | 55 | nsCOMPtr<nsITimer> mDelayedWorkTimer; |
michael@0 | 56 | nsIThread* mThread; |
michael@0 | 57 | |
michael@0 | 58 | private: |
michael@0 | 59 | // Only accessed by this class. |
michael@0 | 60 | nsRefPtr<DoWorkRunnable> mDoWorkEvent; |
michael@0 | 61 | }; |
michael@0 | 62 | |
michael@0 | 63 | class MessagePumpForChildProcess MOZ_FINAL: public MessagePump |
michael@0 | 64 | { |
michael@0 | 65 | public: |
michael@0 | 66 | MessagePumpForChildProcess() |
michael@0 | 67 | : mFirstRun(true) |
michael@0 | 68 | { } |
michael@0 | 69 | |
michael@0 | 70 | virtual void Run(base::MessagePump::Delegate* aDelegate) MOZ_OVERRIDE; |
michael@0 | 71 | |
michael@0 | 72 | private: |
michael@0 | 73 | ~MessagePumpForChildProcess() |
michael@0 | 74 | { } |
michael@0 | 75 | |
michael@0 | 76 | bool mFirstRun; |
michael@0 | 77 | }; |
michael@0 | 78 | |
michael@0 | 79 | class MessagePumpForNonMainThreads MOZ_FINAL : public MessagePump |
michael@0 | 80 | { |
michael@0 | 81 | public: |
michael@0 | 82 | MessagePumpForNonMainThreads() |
michael@0 | 83 | { } |
michael@0 | 84 | |
michael@0 | 85 | virtual void Run(base::MessagePump::Delegate* aDelegate) MOZ_OVERRIDE; |
michael@0 | 86 | |
michael@0 | 87 | private: |
michael@0 | 88 | ~MessagePumpForNonMainThreads() |
michael@0 | 89 | { } |
michael@0 | 90 | }; |
michael@0 | 91 | |
michael@0 | 92 | } /* namespace ipc */ |
michael@0 | 93 | } /* namespace mozilla */ |
michael@0 | 94 | |
michael@0 | 95 | #endif /* __IPC_GLUE_MESSAGEPUMP_H__ */ |