Bumping manifests a=b2g-bump
[gecko.git] / widget / gonk / nsAppShell.h
blob2b1f959e0c21e3b057c2b3832bb51e65d540e656
1 /* Copyright 2012 Mozilla Foundation and Mozilla contributors
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #ifndef nsAppShell_h
17 #define nsAppShell_h
19 #include <queue>
21 #include "mozilla/Mutex.h"
22 #include "nsBaseAppShell.h"
23 #include "nsTArray.h"
25 #include "utils/RefBase.h"
27 namespace mozilla {
28 bool ProcessNextEvent();
29 void NotifyEvent();
32 extern bool gDrawRequest;
34 class FdHandler;
35 typedef void(*FdHandlerCallback)(int, FdHandler *);
37 class FdHandler {
38 public:
39 FdHandler()
41 memset(name, 0, sizeof(name));
44 int fd;
45 char name[64];
46 FdHandlerCallback func;
47 void run()
49 func(fd, this);
53 namespace android {
54 class EventHub;
55 class InputReader;
56 class InputReaderThread;
59 class GeckoInputReaderPolicy;
60 class GeckoInputDispatcher;
62 class nsAppShell : public nsBaseAppShell {
63 public:
64 nsAppShell();
66 NS_DECL_ISUPPORTS_INHERITED
67 NS_DECL_NSIOBSERVER
69 nsresult Init();
71 NS_IMETHOD Exit() MOZ_OVERRIDE;
73 virtual bool ProcessNextNativeEvent(bool maywait);
75 void NotifyNativeEvent();
77 static void NotifyScreenInitialized();
78 static void NotifyScreenRotation();
80 protected:
81 virtual ~nsAppShell();
83 virtual void ScheduleNativeEventCallback();
85 private:
86 nsresult AddFdHandler(int fd, FdHandlerCallback handlerFunc,
87 const char* deviceName);
88 void InitInputDevices();
90 // This is somewhat racy but is perfectly safe given how the callback works
91 bool mNativeCallbackRequest;
93 // This gets flipped when we observe a browser-ui-startup-complete.
94 // browser-ui-startup-complete means that we're really ready to draw
95 // and can stop the boot animation
96 bool mEnableDraw;
97 nsTArray<FdHandler> mHandlers;
99 android::sp<android::EventHub> mEventHub;
100 android::sp<GeckoInputReaderPolicy> mReaderPolicy;
101 android::sp<GeckoInputDispatcher> mDispatcher;
102 android::sp<android::InputReader> mReader;
103 android::sp<android::InputReaderThread> mReaderThread;
106 #endif /* nsAppShell_h */