author Nicholas Nethercote <nnethercote@mozilla.com>
Wed, 25 Oct 2017 10:22:38 +1100
changeset 387909 3d0093f961eec929caa370444cd0f7fcbfbc82bc
parent 257202 a13c1f26e351dd6251da641fe7a9eb53790fc2d0
permissions -rw-r--r--
Bug 1410794 - Change some |string| occurrences in nsIPrefBranch.idl to |ACString|. r=erahm. This makes the code nicer. In particular, it removes many getter_Copies() calls. The patch also converts a lot of nsCStrings to nsAutoCString, which will avoid heap allocation in the common case. The patch also renames PREF_CopyCharPref() as PREF_GetCStringPref(), because it's actually getting a string, not a char, and that matches the existing GetCString() and GetDefaultCString() methods. Correspondingly, it also renames PREF_SetCharPref() as PREF_SetCStringPref(). The |aPrefName| arguments in nsIPrefBranch.idl remain as |string| because they almost always involve passing in C string literals, and passing "foo" is much nicer than passing NS_LITERAL_CSTRING("foo"). It's worth noting that early versions of this patch used |AUTF8String| instead of |ACString|. But it turns out that libpref stores prefs internally as Latin1. And |ACString| is compatible with Latin1 but |AUTF8String| isn't, because non-ASCII Latin1 strings are not valid UTF-8!

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 * 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/. */

#include "nsISupports.idl"

interface nsIRunnable;
%{ C++
template <class T> struct already_AddRefed;

 * Interface for the native event system layer.  This interface is designed
 * to be used on the main application thread only.
interface nsIAppShell : nsISupports
   * Enter an event loop.  Don't leave until exit() is called.
  void run();

   * Exit the handle event loop
  void exit();

   * Give hint to native event queue notification mechanism. If the native
   * platform needs to tradeoff performance vs. native event starvation this
   * hint tells the native dispatch code which to favor.  The default is to
   * prevent native event starvation.
   * Calls to this function may be nested. When the number of calls that pass
   * PR_TRUE is subtracted from the number of calls that pass PR_FALSE is
   * greater than 0, performance is given precedence over preventing event
   * starvation.
   * The starvationDelay arg is only used when favorPerfOverStarvation is
   * PR_FALSE. It is the amount of time in milliseconds to wait before the
   * PR_FALSE actually takes effect.
  void favorPerformanceHint(in boolean favorPerfOverStarvation,
                            in unsigned long starvationDelay);

   * Suspends the use of additional platform-specific methods (besides the
   * nsIAppShell->run() event loop) to run Gecko events on the main
   * application thread.  Under some circumstances these "additional methods"
   * can cause Gecko event handlers to be re-entered, sometimes leading to
   * hangs and crashes.  Calls to suspendNative() and resumeNative() may be
   * nested.  On some platforms (those that don't use any "additional
   * methods") this will be a no-op.  Does not (in itself) stop Gecko events
   * from being processed on the main application thread.  But if the
   * nsIAppShell->run() event loop is blocked when this call is made, Gecko
   * events will stop being processed until resumeNative() is called (even
   * if a plugin or library is temporarily processing events on a nested
   * event loop).
  void suspendNative();

   * Resumes the use of additional platform-specific methods to run Gecko
   * events on the main application thread.  Calls to suspendNative() and
   * resumeNative() may be nested.  On some platforms this will be a no-op.
  void resumeNative();

   * The current event loop nesting level.
  readonly attribute unsigned long eventloopNestingLevel;