Bug 677166 - Part 3 - Implement mozConnection stub. r=sicking

This commit is contained in:
Mounir Lamouri 2012-01-16 13:23:44 +01:00
Родитель bc4f3af0e5
Коммит f6dade4914
8 изменённых файлов: 150 добавлений и 1 удалений

Просмотреть файл

@ -74,6 +74,7 @@
#include "mozilla/Hal.h"
#include "nsIWebNavigation.h"
#include "mozilla/ClearOnShutdown.h"
#include "Connection.h"
#ifdef MOZ_B2G_RIL
#include "TelephonyFactory.h"
@ -173,6 +174,8 @@ Navigator::Invalidate()
mTelephony = nsnull;
}
#endif
mConnection = nsnull;
}
nsPIDOMWindow *
@ -1071,7 +1074,11 @@ Navigator::GetMozTelephony(nsIDOMTelephony** aTelephony)
NS_IMETHODIMP
Navigator::GetMozConnection(nsIDOMMozConnection** aConnection)
{
*aConnection = nsnull;
if (!mConnection) {
mConnection = new network::Connection();
}
NS_ADDREF(*aConnection = mConnection);
return NS_OK;
}

Просмотреть файл

@ -58,6 +58,7 @@ class nsMimeTypeArray;
class nsGeolocation;
class nsDesktopNotificationCenter;
class nsPIDOMWindow;
class nsIDOMMozConnection;
#ifdef MOZ_B2G_RIL
#include "nsIDOMNavigatorTelephony.h"
@ -135,6 +136,7 @@ private:
#ifdef MOZ_B2G_RIL
nsCOMPtr<nsIDOMTelephony> mTelephony;
#endif
nsCOMPtr<nsIDOMMozConnection> mConnection;
nsWeakPtr mWindow;
};

Просмотреть файл

@ -518,6 +518,7 @@
#include "nsIDOMSmsFilter.h"
#include "nsIDOMSmsCursor.h"
#include "nsIPrivateDOMEvent.h"
#include "nsIDOMConnection.h"
#ifdef MOZ_B2G_RIL
#include "Telephony.h"
@ -1423,6 +1424,9 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(MozSmsCursor, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(MozConnection, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(CSSFontFaceRule, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(CSSFontFaceStyleDecl, nsCSSStyleDeclSH,
@ -4013,6 +4017,10 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsCursor)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(MozConnection, nsIDOMMozConnection)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozConnection)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(CSSFontFaceRule, nsIDOMCSSFontFaceRule)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSFontFaceRule)
DOM_CLASSINFO_MAP_END

Просмотреть файл

@ -437,6 +437,8 @@ DOMCI_CLASS(MozSmsRequest)
DOMCI_CLASS(MozSmsFilter)
DOMCI_CLASS(MozSmsCursor)
DOMCI_CLASS(MozConnection)
// @font-face in CSS
DOMCI_CLASS(CSSFontFaceRule)
DOMCI_CLASS(CSSFontFaceStyleDecl)

Просмотреть файл

@ -0,0 +1,59 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mounir Lamouri <mounir.lamouri@mozilla.com> (Original Author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "Connection.h"
#include "nsIDOMClassInfo.h"
DOMCI_DATA(MozConnection, mozilla::dom::network::Connection)
namespace mozilla {
namespace dom {
namespace network {
NS_INTERFACE_MAP_BEGIN(Connection)
NS_INTERFACE_MAP_ENTRY(nsIDOMMozConnection)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozConnection)
NS_INTERFACE_MAP_END
NS_IMPL_ADDREF(Connection)
NS_IMPL_RELEASE(Connection)
} // namespace network
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -0,0 +1,58 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mounir Lamouri <mounir.lamouri@mozilla.com> (Original Author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozilla_dom_network_Connection_h
#define mozilla_dom_network_Connection_h
#include "nsIDOMConnection.h"
namespace mozilla {
namespace dom {
namespace network {
class Connection : public nsIDOMMozConnection
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMMOZCONNECTION
};
} // namespace network
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_network_Connection_h

Просмотреть файл

@ -53,6 +53,7 @@ EXPORTS_mozilla/dom/network = \
$(NULL)
CPPSRCS = \
Connection.cpp \
$(NULL)
LOCAL_INCLUDES = \

Просмотреть файл

@ -14,8 +14,20 @@
/** Test for Network API **/
function checkInterface(aInterface) {
ok(!(aInterface in window), aInterface + " should be prefixed");
ok(("Moz" + aInterface) in window, aInterface + " should be prefixed");
}
ok('mozConnection' in navigator, "navigator.mozConnection should exist");
ok(navigator.mozConnection, "navigator.mozConnection returns an object");
ok(navigator.mozConnection instanceof MozConnection,
"navigator.mozConnection is a MozConnection object");
checkInterface("Connection");
</script>
</pre>
</body>