widget/uikit/nsAppShell.h
author Sylvestre Ledru <sledru@mozilla.com>
Fri, 30 Nov 2018 11:46:48 +0100
changeset 505383 6f3709b3878117466168c40affa7bca0b60cf75b
parent 451029 3d28ca7c05d8f9ba3ba6ff1cd5449dce42ae95c1
child 505471 66eb1f485c1a3ea81372758bc92292c9428b17cd
permissions -rw-r--r--
Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format # ignore-this-changeset

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/*
 * Runs the main native UIKit run loop, interrupting it as needed to process
 * Gecko events.
 */

#ifndef nsAppShell_h_
#define nsAppShell_h_

#include "nsBaseAppShell.h"
#include "nsTArray.h"

#include <Foundation/NSAutoreleasePool.h>
#include <CoreFoundation/CFRunLoop.h>
#include <UIKit/UIWindow.h>

@class AppShellDelegate;

class nsAppShell : public nsBaseAppShell {
 public:
  NS_IMETHOD ResumeNative(void) override;

  nsAppShell();

  nsresult Init();

  NS_IMETHOD Run(void) override;
  NS_IMETHOD Exit(void) override;
  // Called by the application delegate
  void WillTerminate(void);

  static nsAppShell* gAppShell;
  static UIWindow* gWindow;
  static NSMutableArray* gTopLevelViews;

 protected:
  virtual ~nsAppShell();

  static void ProcessGeckoEvents(void* aInfo);
  virtual void ScheduleNativeEventCallback();
  virtual bool ProcessNextNativeEvent(bool aMayWait);

  NSAutoreleasePool* mAutoreleasePool;
  AppShellDelegate* mDelegate;
  CFRunLoopRef mCFRunLoop;
  CFRunLoopSourceRef mCFRunLoopSource;

  bool mTerminated;
  bool mNotifiedWillTerminate;
};

#endif  // nsAppShell_h_