dom/wifi/WifiProxyService.h
author Masayuki Nakano <masayuki@d-toybox.com>
Sat, 11 Jun 2016 11:06:37 +0900
changeset 341662 b64f33cd6b5431a6bd97c3afea39f943ca2b9022
parent 272011 bd079aadd3feeee3f9b9f73c5e0bc4bd6a870722
permissions -rw-r--r--
Bug 1278014 part.2 Define mozilla::SelectionType as an enum class and use it instead of RawSelectionType as far as possible r=smaug This patch defines mozilla::SelectionType as an enum class. This is safer than nsISelectionController::SELECTION_* since setting illegal value to its variable is checked at build time. So, as far as possible, this should be used everywhere (but of course, this isn't available in scriptable interfaces). And also this implements some useful methods for managing SelectionType and RawSelectionType which are implemented in layout/nsSelection.cpp because nsISelectionController is implemented by both PresShell and nsTextEditorState. Therefore, implementing one of them may make hard to find them. On the other hand, nsSelection.cpp is a better file name to look for them. Note that this patch creates mozilla::Selection::RawType() for binding. Native code should keep using Selection::Type() but the binding code needs to use RawType() due to impossible to convert from SelectionType to RawSelectionType without explicit cast. MozReview-Commit-ID: 81vX7A0hHQN

/* -*- 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 WifiProxyService_h
#define WifiProxyService_h

#include "nsIWifiService.h"
#include "nsCOMPtr.h"
#include "nsThread.h"
#include "mozilla/dom/WifiOptionsBinding.h"
#include "nsTArray.h"

namespace mozilla {

class WifiProxyService final : public nsIWifiProxyService
{
private:
  struct EventThreadListEntry
  {
    nsCOMPtr<nsIThread> mThread;
    nsCString mInterface;
  };

public:
  NS_DECL_ISUPPORTS
  NS_DECL_NSIWIFIPROXYSERVICE

  static already_AddRefed<WifiProxyService>
  FactoryCreate();

  void DispatchWifiEvent(const nsAString& aEvent, const nsACString& aInterface);
  void DispatchWifiResult(const mozilla::dom::WifiResultOptions& aOptions,
                          const nsACString& aInterface);

private:
  WifiProxyService();
  ~WifiProxyService();

  nsTArray<EventThreadListEntry> mEventThreadList;
  nsCOMPtr<nsIThread> mControlThread;
  nsCOMPtr<nsIWifiEventListener> mListener;
};

} // namespace mozilla

#endif // WifiProxyService_h