dom/cellbroadcast/src/CellBroadcast.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/cellbroadcast/src/CellBroadcast.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,61 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef mozilla_dom_CellBroadcast_h__
    1.10 +#define mozilla_dom_CellBroadcast_h__
    1.11 +
    1.12 +#include "mozilla/Attributes.h"
    1.13 +#include "mozilla/DOMEventTargetHelper.h"
    1.14 +#include "mozilla/ErrorResult.h"
    1.15 +#include "nsICellBroadcastProvider.h"
    1.16 +#include "js/TypeDecls.h"
    1.17 +
    1.18 +class nsPIDOMWindow;
    1.19 +
    1.20 +namespace mozilla {
    1.21 +namespace dom {
    1.22 +
    1.23 +class CellBroadcast MOZ_FINAL : public DOMEventTargetHelper
    1.24 +{
    1.25 +  /**
    1.26 +   * Class CellBroadcast doesn't actually inherit nsICellBroadcastListener.
    1.27 +   * Instead, it owns an nsICellBroadcastListener derived instance mListener
    1.28 +   * and passes it to nsICellBroadcastProvider. The onreceived events are first
    1.29 +   * delivered to mListener and then forwarded to its owner, CellBroadcast. See
    1.30 +   * also bug 775997 comment #51.
    1.31 +   */
    1.32 +  class Listener;
    1.33 +
    1.34 +public:
    1.35 +  NS_DECL_NSICELLBROADCASTLISTENER
    1.36 +
    1.37 +  NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
    1.38 +
    1.39 +  static already_AddRefed<CellBroadcast>
    1.40 +  Create(nsPIDOMWindow* aOwner, ErrorResult& aRv);
    1.41 +
    1.42 +  CellBroadcast() MOZ_DELETE;
    1.43 +  CellBroadcast(nsPIDOMWindow *aWindow,
    1.44 +                nsICellBroadcastProvider* aProvider);
    1.45 +  // MOZ_FINAL suppresses -Werror,-Wdelete-non-virtual-dtor
    1.46 +  ~CellBroadcast();
    1.47 +
    1.48 +  nsPIDOMWindow*
    1.49 +  GetParentObject() const { return GetOwner(); }
    1.50 +
    1.51 +  virtual JSObject*
    1.52 +  WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    1.53 +
    1.54 +  IMPL_EVENT_HANDLER(received)
    1.55 +
    1.56 +private:
    1.57 +  nsCOMPtr<nsICellBroadcastProvider> mProvider;
    1.58 +  nsRefPtr<Listener> mListener;
    1.59 +};
    1.60 +
    1.61 +} // namespace dom
    1.62 +} // namespace mozilla
    1.63 +
    1.64 +#endif /* mozilla_dom_CellBroadcast_h__ */

mercurial