2012-01-16 16:23:44 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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
|
|
|
|
|
2012-01-16 21:14:56 +04:00
|
|
|
#include "Types.h"
|
2014-04-01 10:13:50 +04:00
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
|
|
|
#include "mozilla/Observer.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 {
|
|
|
|
namespace network {
|
|
|
|
|
2014-04-01 10:13:50 +04:00
|
|
|
class Connection MOZ_FINAL : public DOMEventTargetHelper
|
2014-01-16 14:53:48 +04:00
|
|
|
, public NetworkObserver
|
|
|
|
, 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
|
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
|
|
|
|
2014-10-11 01:28:35 +04:00
|
|
|
explicit Connection(nsPIDOMWindow *aWindow);
|
2012-01-16 21:14:56 +04:00
|
|
|
|
|
|
|
void Shutdown();
|
|
|
|
|
|
|
|
// For IObserver
|
2015-01-07 20:00:44 +03:00
|
|
|
void Notify(const hal::NetworkInformation& aNetworkInfo) MOZ_OVERRIDE;
|
2012-01-16 21:14:56 +04:00
|
|
|
|
2014-01-16 14:53:48 +04:00
|
|
|
// WebIDL
|
|
|
|
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) MOZ_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
|
|
|
|
2012-01-16 16:25:13 +04:00
|
|
|
private:
|
2014-07-09 01:23:17 +04:00
|
|
|
~Connection() {}
|
|
|
|
|
2012-01-16 21:14:56 +04:00
|
|
|
/**
|
|
|
|
* Update the connection information stored in the object using a
|
|
|
|
* NetworkInformation object.
|
|
|
|
*/
|
|
|
|
void UpdateFromNetworkInfo(const hal::NetworkInformation& aNetworkInfo);
|
|
|
|
|
|
|
|
/**
|
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;
|
2012-01-16 16:23:44 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace network
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_network_Connection_h
|