xpcom/ds/nsObserverService.h
author Petru Lingurar <petru.lingurar@softvision.ro>
Fri, 13 Jul 2018 17:16:37 +0300
changeset 426733 c2b1f1b52866d2c58f5e23fe2df97c9127ebcacf
parent 295698 1d99e6c5a2bf41b983658369b97c5d152649695b
child 447214 c77a41fad0e6a6b22df9a077b536098adb42db86
permissions -rw-r--r--
Bug 1385464 - Start using support library v. 26; r=nalexander This patch also: Resolves missing resources and api changes - LeanplumActionBarActivity was removed because Support Library 26 deprecated ActionBarActivity. Class was already not in use. - CustomTabsService added two new methods which we need to override. Tested to make sure that previous functionality was maintained but with the addition of the two new methods maybe that feature could be improved. - For checking layout direction we'll use our own new method from ViewUtil which mimics what the now restricted method from the support library would do. - Upgraded to use AppCompatResources#getDrawable(..) in place of the now restricted AppCompatDrawableManager.get().getDrawable(..). Resolves obscure leaks and crashes after the upgrade - LoaderManager.destroyLoader(..) was added before the existing call to LoaderManager.restartLoader(..) to prevent potential Cursor leaks - Disable website suggestions depending on the address bar inputs when running in automation to avoid Robocop tests failing (they were entering serially maybe 100 characters in <5 ms which created around that many new Threads, operation that could cause the Executor to throw a RejectedExecutionException) At the moment this functionality is not covered by tests anyway and it was the only fix I could find that would not involve changing the whole implemenation for address bar suggestions, implementation which in the real world works ok. MozReview-Commit-ID: 2fX1SBHiSh0

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */

#ifndef nsObserverService_h___
#define nsObserverService_h___

#include "nsIObserverService.h"
#include "nsObserverList.h"
#include "nsIMemoryReporter.h"
#include "nsTHashtable.h"
#include "mozilla/Attributes.h"

// {D07F5195-E3D1-11d2-8ACD-00105A1B8860}
#define NS_OBSERVERSERVICE_CID \
    { 0xd07f5195, 0xe3d1, 0x11d2, { 0x8a, 0xcd, 0x0, 0x10, 0x5a, 0x1b, 0x88, 0x60 } }

class nsIMemoryReporter;

class nsObserverService final
  : public nsIObserverService
  , public nsIMemoryReporter
{
public:
  NS_DECLARE_STATIC_IID_ACCESSOR(NS_OBSERVERSERVICE_CID)

  nsObserverService();

  NS_DECL_ISUPPORTS
  NS_DECL_NSIOBSERVERSERVICE
  NS_DECL_NSIMEMORYREPORTER

  void Shutdown();

  static MOZ_MUST_USE nsresult Create(nsISupports* aOuter, const nsIID& aIID,
                                      void** aInstancePtr);

  // Unmark any strongly held observers implemented in JS so the cycle
  // collector will not traverse them.
  NS_IMETHOD UnmarkGrayStrongObservers();

private:
  ~nsObserverService(void);
  void RegisterReporter();

  static const size_t kSuspectReferentCount = 100;
  bool mShuttingDown;
  nsTHashtable<nsObserverList> mObserverTopicTable;
};

NS_DEFINE_STATIC_IID_ACCESSOR(nsObserverService, NS_OBSERVERSERVICE_CID)

#endif /* nsObserverService_h___ */