2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2012-01-16 16:23:44 +04:00
|
|
|
|
|
|
|
#ifndef mozilla_dom_network_Connection_h
|
|
|
|
#define mozilla_dom_network_Connection_h
|
|
|
|
|
2014-04-01 10:13:50 +04:00
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
2014-03-05 07:54:55 +04:00
|
|
|
#include "mozilla/dom/NetworkInformationBinding.h"
|
2014-04-01 10:13:50 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsINetworkProperties.h"
|
2012-01-16 16:23:44 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2012-01-16 21:14:56 +04:00
|
|
|
|
|
|
|
namespace hal {
|
|
|
|
class NetworkInformation;
|
|
|
|
} // namespace hal
|
|
|
|
|
2012-01-16 16:23:44 +04:00
|
|
|
namespace dom {
|
2017-03-24 22:27:11 +03:00
|
|
|
|
|
|
|
namespace workers {
|
|
|
|
class WorkerPrivate;
|
|
|
|
} // namespace workers
|
|
|
|
|
2012-01-16 16:23:44 +04:00
|
|
|
namespace network {
|
|
|
|
|
2016-12-16 10:50:23 +03:00
|
|
|
class Connection : public DOMEventTargetHelper
|
|
|
|
, public nsINetworkProperties
|
2012-01-16 16:23:44 +04:00
|
|
|
{
|
|
|
|
public:
|
2013-02-07 14:19:08 +04:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2013-07-11 19:39:36 +04:00
|
|
|
NS_DECL_NSINETWORKPROPERTIES
|
2016-12-16 10:50:23 +03:00
|
|
|
NS_DECL_OWNINGTHREAD
|
2012-01-16 16:25:13 +04:00
|
|
|
|
2014-04-01 10:13:50 +04:00
|
|
|
NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
|
2012-01-16 21:14:56 +04:00
|
|
|
|
2016-12-16 10:50:23 +03:00
|
|
|
static bool IsEnabled(JSContext* aCx, JSObject* aObj);
|
2016-12-15 16:36:47 +03:00
|
|
|
|
2016-12-16 10:50:23 +03:00
|
|
|
static Connection*
|
|
|
|
CreateForWindow(nsPIDOMWindowInner* aWindow);
|
2016-12-15 16:21:09 +03:00
|
|
|
|
2016-12-16 10:50:23 +03:00
|
|
|
static already_AddRefed<Connection>
|
|
|
|
CreateForWorker(workers::WorkerPrivate* aWorkerPrivate,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
|
|
|
void Shutdown();
|
2016-12-15 19:06:22 +03:00
|
|
|
|
2014-01-16 14:53:48 +04:00
|
|
|
// WebIDL
|
|
|
|
|
2016-12-16 10:50:23 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
2014-01-16 14:53:48 +04:00
|
|
|
|
2014-03-05 07:54:55 +04:00
|
|
|
ConnectionType Type() const { return mType; }
|
2014-01-16 14:53:48 +04:00
|
|
|
|
2014-03-05 07:54:55 +04:00
|
|
|
IMPL_EVENT_HANDLER(typechange)
|
2014-01-16 14:53:48 +04:00
|
|
|
|
2016-12-16 10:50:23 +03:00
|
|
|
protected:
|
|
|
|
Connection(nsPIDOMWindowInner* aWindow);
|
|
|
|
virtual ~Connection();
|
2016-12-15 16:36:47 +03:00
|
|
|
|
2016-12-16 10:50:23 +03:00
|
|
|
void Update(ConnectionType aType, bool aIsWifi, bool aDHCPGateway,
|
|
|
|
bool aNotify);
|
|
|
|
|
|
|
|
virtual void ShutdownInternal() = 0;
|
2012-01-16 21:14:56 +04:00
|
|
|
|
2016-12-16 10:50:23 +03:00
|
|
|
private:
|
2012-01-16 21:14:56 +04:00
|
|
|
/**
|
2014-03-05 07:54:55 +04:00
|
|
|
* The type of current connection.
|
2012-01-16 21:14:56 +04:00
|
|
|
*/
|
2014-03-05 07:54:55 +04:00
|
|
|
ConnectionType mType;
|
2012-01-16 21:14:56 +04:00
|
|
|
|
2013-07-11 19:39:36 +04:00
|
|
|
/**
|
|
|
|
* If the connection is WIFI
|
|
|
|
*/
|
|
|
|
bool mIsWifi;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DHCP Gateway information for IPV4, in network byte order. 0 if unassigned.
|
|
|
|
*/
|
|
|
|
uint32_t mDHCPGateway;
|
2016-12-16 10:50:23 +03:00
|
|
|
|
|
|
|
bool mBeenShutDown;
|
2012-01-16 16:23:44 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace network
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_network_Connection_h
|