This commit is contained in:
Carsten "Tomcat" Book 2014-09-22 13:11:06 +02:00
Родитель dab1cb48dc 79a0a7362d
Коммит 47ac1acafa
726 изменённых файлов: 42938 добавлений и 37251 удалений

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

@ -22,4 +22,4 @@
# changes to stick? As of bug 928195, this shouldn't be necessary! Please
# don't change CLOBBER for WebIDL changes any more.
The backout of bug 994190 needed a clobber.
Bug 1063304 moved IPDL PMobileConnection into its own namespace and needed a clobber.

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

@ -34,6 +34,7 @@
#include "States.h"
#include "Statistics.h"
#include "TextLeafAccessibleWrap.h"
#include "TreeWalker.h"
#ifdef MOZ_ACCESSIBILITY_ATK
#include "AtkSocketAccessible.h"
@ -391,22 +392,44 @@ nsAccessibilityService::ContentRangeInserted(nsIPresShell* aPresShell,
void
nsAccessibilityService::ContentRemoved(nsIPresShell* aPresShell,
nsIContent* aContainer,
nsIContent* aChild)
nsIContent* aChildNode)
{
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eTree)) {
logging::MsgBegin("TREE", "content removed");
logging::Node("container", aContainer);
logging::Node("content", aChild);
logging::Node("container", aChildNode->GetFlattenedTreeParent());
logging::Node("content", aChildNode);
}
#endif
DocAccessible* document = GetDocAccessible(aPresShell);
if (document) {
// Flatten hierarchy may be broken at this point so we cannot get a true
// container by traversing up the DOM tree. Find a parent of first accessible
// from the subtree of the given DOM node, that'll be a container. If no
// accessibles in subtree then we don't care about the change.
Accessible* child = document->GetAccessible(aChildNode);
if (!child) {
a11y::TreeWalker walker(document->GetContainerAccessible(aChildNode),
aChildNode, a11y::TreeWalker::eWalkCache);
child = walker.NextChild();
}
if (child) {
document->ContentRemoved(child->Parent(), aChildNode);
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eTree))
logging::AccessibleNNode("real container", child->Parent());
#endif
}
}
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eTree)) {
logging::MsgEnd();
logging::Stack();
}
#endif
DocAccessible* docAccessible = GetDocAccessible(aPresShell);
if (docAccessible)
docAccessible->ContentRemoved(aContainer, aChild);
}
void

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

@ -90,8 +90,7 @@ public:
/**
* Notification used to update the accessible tree when content is removed.
*/
void ContentRemoved(nsIPresShell* aPresShell, nsIContent* aContainer,
nsIContent* aChild);
void ContentRemoved(nsIPresShell* aPresShell, nsIContent* aChild);
virtual void UpdateText(nsIPresShell* aPresShell, nsIContent* aContent);

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

@ -1417,18 +1417,6 @@ DocAccessible::ContentInserted(nsIContent* aContainerNode,
}
}
void
DocAccessible::ContentRemoved(nsIContent* aContainerNode,
nsIContent* aChildNode)
{
// Update the whole tree of this document accessible when the container is
// null (document element is removed).
Accessible* container = aContainerNode ?
GetAccessibleOrContainer(aContainerNode) : this;
UpdateTree(container, aChildNode, false);
}
void
DocAccessible::RecreateAccessible(nsIContent* aContent)
{

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

@ -296,7 +296,16 @@ public:
/**
* Notify the document accessible that content was removed.
*/
void ContentRemoved(nsIContent* aContainerNode, nsIContent* aChildNode);
void ContentRemoved(Accessible* aContainer, nsIContent* aChildNode)
{
// Update the whole tree of this document accessible when the container is
// null (document element is removed).
UpdateTree((aContainer ? aContainer : this), aChildNode, false);
}
void ContentRemoved(nsIContent* aContainerNode, nsIContent* aChildNode)
{
ContentRemoved(GetAccessibleOrContainer(aContainerNode), aChildNode);
}
/**
* Updates accessible tree when rendered text is changed.

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

@ -5,6 +5,7 @@
[test_bug883708.xhtml]
[test_bug884251.xhtml]
[test_bug895082.html]
[test_bug1040735.html]
[test_canvas.html]
[test_colorpicker.xul]
[test_contextmenu.xul]

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

@ -0,0 +1,42 @@
<!DOCTYPE html>
<html>
<head>
<title>Adopt DOM node from anonymous subtree</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript">
function doTest()
{
document.body.appendChild(document.getElementById("mw_a"));
setTimeout(function() { ok(true, "no crash and assertions"); SimpleTest.finish(); } , 0);
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=1040735"
title="Bug 1040735 - DOM node reinsertion under anonymous content may trigger a11y child adoption">
Bug 1040735</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<marquee>
<div id="mw_a" style="visibility: hidden;">
<div style="visibility: visible;" id="mw_inside"></div>
</div>
</marquee>
</body>
</html>

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

@ -51,7 +51,7 @@
{ COMBOBOX_OPTION: [
{ TEXT_LEAF: [] }
] },
{ COMBOBOX_OPTION: [
{ COMBOBOX_OPTION: [
{ TEXT_LEAF: [] }
] },
]},
@ -71,6 +71,7 @@
{
this.selectNode = getNode(aID);
this.select = getAccessible(this.selectNode);
this.selectList = this.select.firstChild;
this.invoke = function removeOptGroup_invoke()
{
@ -79,7 +80,7 @@
}
this.eventSeq = [
new invokerChecker(EVENT_REORDER, this.select)
new invokerChecker(EVENT_REORDER, this.selectList)
];
this.finalCheck = function removeOptGroup_finalCheck()

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

@ -63,6 +63,7 @@
{
this.selectNode = getNode(aID);
this.select = getAccessible(this.selectNode);
this.selectList = this.select.firstChild;
this.invoke = function removeOptions_invoke()
{
@ -71,7 +72,7 @@
}
this.eventSeq = [
new invokerChecker(EVENT_REORDER, this.select)
new invokerChecker(EVENT_REORDER, this.selectList)
];
this.finalCheck = function removeOptions_finalCheck()

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

@ -246,6 +246,15 @@ pref("security.alternate_certificate_error_page", "certerror");
pref("security.warn_viewing_mixed", false); // Warning is disabled. See Bug 616712.
// 2 = strict certificate pinning checks.
// This default preference is more strict than Firefox because B2G
// currently does not have a way to install local root certificates.
// Strict checking is effectively equivalent to non-strict checking as
// long as that is true. If an ability to add local certificates is
// added, there may be a need to change this pref.
pref("security.cert_pinning.enforcement_level", 2);
// Override some named colors to avoid inverse OS themes
pref("ui.-moz-dialog", "#efebe7");
pref("ui.-moz-dialogtext", "#101010");

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

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="fe92ddd450e03b38edb2d465de7897971d68ac68">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="c7ef0bf06ce1c98cbe68aa52e2ecd862acb23e9c"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="3802009e1ab6c3ddfc3eb15522e3140a96b33336"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="b81855b6b67f285d6f27a4f8c1cfe2e0387ea57c"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>

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

@ -19,7 +19,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="c7ef0bf06ce1c98cbe68aa52e2ecd862acb23e9c"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="3802009e1ab6c3ddfc3eb15522e3140a96b33336"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="b81855b6b67f285d6f27a4f8c1cfe2e0387ea57c"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cd88d860656c31c7da7bb310d6a160d0011b0961"/>

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

@ -17,7 +17,7 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="c7ef0bf06ce1c98cbe68aa52e2ecd862acb23e9c"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="3802009e1ab6c3ddfc3eb15522e3140a96b33336"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="b81855b6b67f285d6f27a4f8c1cfe2e0387ea57c"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="f3e998242fb9a857cf50f5bf3a02304a530ea617"/>

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

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="fe92ddd450e03b38edb2d465de7897971d68ac68">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="c7ef0bf06ce1c98cbe68aa52e2ecd862acb23e9c"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="3802009e1ab6c3ddfc3eb15522e3140a96b33336"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="b81855b6b67f285d6f27a4f8c1cfe2e0387ea57c"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>

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

@ -19,7 +19,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="c7ef0bf06ce1c98cbe68aa52e2ecd862acb23e9c"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="3802009e1ab6c3ddfc3eb15522e3140a96b33336"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="b81855b6b67f285d6f27a4f8c1cfe2e0387ea57c"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cd88d860656c31c7da7bb310d6a160d0011b0961"/>

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

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="fe92ddd450e03b38edb2d465de7897971d68ac68">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="c7ef0bf06ce1c98cbe68aa52e2ecd862acb23e9c"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="3802009e1ab6c3ddfc3eb15522e3140a96b33336"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="b81855b6b67f285d6f27a4f8c1cfe2e0387ea57c"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
@ -135,10 +135,10 @@
<project name="device-flame" path="device/t2m/flame" remote="b2g" revision="960533f716ce31dfad357e87fa2f1d9ee5e94674"/>
<project name="codeaurora_kernel_msm" path="kernel" remote="b2g" revision="893238eb1215f8fd4f3747169170cc5e1cc33969"/>
<project name="kernel_lk" path="bootable/bootloader/lk" remote="b2g" revision="fda40423ffa573dc6cafd3780515010cb2a086be"/>
<project name="platform/external/bluetooth/bluedroid" path="external/bluetooth/bluedroid" revision="b2af89ae378a119819a9c86d9a12e573c7130459"/>
<project name="platform/external/bluetooth/bluedroid" path="external/bluetooth/bluedroid" revision="30b96dfca99cb384bf520a16b81f3aba56f09907"/>
<project name="platform/external/wpa_supplicant_8" path="external/wpa_supplicant_8" revision="5b71e40213f650459e95d35b6f14af7e88d8ab62"/>
<project name="platform_external_libnfc-nci" path="external/libnfc-nci" remote="t2m" revision="4186bdecb4dae911b39a8202252cc2310d91b0be"/>
<project name="platform/frameworks/av" path="frameworks/av" revision="c1814713bd2d07c2af0c236007badc8732a34324"/>
<project name="platform/frameworks/av" path="frameworks/av" revision="ea2f399b3ca0a23524d2828f85f69902caefc22e"/>
<project name="platform/frameworks/base" path="frameworks/base" revision="6b58ab45e3e56c1fc20708cc39fa2264c52558df"/>
<project name="platform/frameworks/native" path="frameworks/native" revision="a46a9f1ac0ed5662d614c277cbb14eb3f332f365"/>
<project name="platform/hardware/libhardware" path="hardware/libhardware" revision="7196881a0e9dd7bfbbcf0af64c8064e70f0fa094"/>
@ -154,5 +154,5 @@
<project name="platform_system_nfcd" path="system/nfcd" remote="b2g" revision="54a712b46fe937dacdaed9b1261c63847129a719"/>
<project name="platform/system/qcom" path="system/qcom" revision="63e3f6f176caad587d42bba4c16b66d953fb23c2"/>
<project name="platform/vendor/qcom-opensource/wlan/prima" path="vendor/qcom/opensource/wlan/prima" revision="d8952a42771045fca73ec600e2b42a4c7129d723"/>
<project name="platform/vendor/qcom/msm8610" path="device/qcom/msm8610" revision="5d1dbc698de7294697373b436dd44e240f40e1ac"/>
<project name="platform/vendor/qcom/msm8610" path="device/qcom/msm8610" revision="7704e16da545f4207812e593743d6743e1afb9c5"/>
</manifest>

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

@ -17,7 +17,7 @@
</project>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="c7ef0bf06ce1c98cbe68aa52e2ecd862acb23e9c"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="3802009e1ab6c3ddfc3eb15522e3140a96b33336"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="b81855b6b67f285d6f27a4f8c1cfe2e0387ea57c"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="f3e998242fb9a857cf50f5bf3a02304a530ea617"/>

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

@ -4,6 +4,6 @@
"remote": "",
"branch": ""
},
"revision": "b5f6c10e258311d9f04ed759291bbe6af10a772b",
"revision": "a491e07757d721d4bea7302cfbb2b18460a3820d",
"repo_path": "/integration/gaia-central"
}

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

@ -17,7 +17,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="c7ef0bf06ce1c98cbe68aa52e2ecd862acb23e9c"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="3802009e1ab6c3ddfc3eb15522e3140a96b33336"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="b81855b6b67f285d6f27a4f8c1cfe2e0387ea57c"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>

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

@ -15,7 +15,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="c7ef0bf06ce1c98cbe68aa52e2ecd862acb23e9c"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="3802009e1ab6c3ddfc3eb15522e3140a96b33336"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="b81855b6b67f285d6f27a4f8c1cfe2e0387ea57c"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>

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

@ -17,7 +17,7 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="c7ef0bf06ce1c98cbe68aa52e2ecd862acb23e9c"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="3802009e1ab6c3ddfc3eb15522e3140a96b33336"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="b81855b6b67f285d6f27a4f8c1cfe2e0387ea57c"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="562d357b72279a9e35d4af5aeecc8e1ffa2f44f1"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="f3e998242fb9a857cf50f5bf3a02304a530ea617"/>

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

@ -17,7 +17,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="c7ef0bf06ce1c98cbe68aa52e2ecd862acb23e9c"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="3802009e1ab6c3ddfc3eb15522e3140a96b33336"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="b81855b6b67f285d6f27a4f8c1cfe2e0387ea57c"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>

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

@ -438,6 +438,8 @@
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
@BINPATH@/components/MmsService.js
@BINPATH@/components/MmsService.manifest
@BINPATH@/components/MobileConnectionService.js
@BINPATH@/components/MobileConnectionService.manifest
@BINPATH@/components/MobileMessageDatabaseService.js
@BINPATH@/components/MobileMessageDatabaseService.manifest
@BINPATH@/components/RadioInterfaceLayer.js
@ -445,8 +447,6 @@
@BINPATH@/components/RILContentHelper.js
@BINPATH@/components/TelephonyService.js
@BINPATH@/components/TelephonyService.manifest
@BINPATH@/components/MobileConnectionGonkService.js
@BINPATH@/components/MobileConnectionGonkService.manifest
#endif // MOZ_WIDGET_GONK && MOZ_B2G_RIL
#ifndef MOZ_WIDGET_GONK

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

@ -755,9 +755,9 @@ class Automation(object):
args = []
if debuggerInfo:
args.extend(debuggerInfo["args"])
args.extend(debuggerInfo.args)
args.append(cmd)
cmd = os.path.abspath(debuggerInfo["path"])
cmd = os.path.abspath(debuggerInfo.path)
if self.IS_MAC:
args.append("-foreground")
@ -850,7 +850,7 @@ class Automation(object):
cmd, args = self.buildCommandLine(app, debuggerInfo, profileDir, testURL, extraArgs)
startTime = datetime.now()
if debuggerInfo and debuggerInfo["interactive"]:
if debuggerInfo and debuggerInfo.interactive:
# If an interactive debugger is attached, don't redirect output,
# don't use timeouts, and don't capture ctrl-c.
timeout = None

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

@ -207,11 +207,7 @@ def processSingleLeakFile(leakLogFileName, processType, leakThreshold):
r"(?P<size>-?\d+)\s+(?P<bytesLeaked>-?\d+)\s+"
r"-?\d+\s+(?P<numLeaked>-?\d+)")
processString = ""
if processType:
# eg 'plugin'
processString = " %s process:" % processType
processString = " %s process:" % processType
crashedOnPurpose = False
totalBytesLeaked = None
logAsWarning = False
@ -271,7 +267,7 @@ def processSingleLeakFile(leakLogFileName, processType, leakThreshold):
# totalBytesLeaked was seen and is non-zero.
if totalBytesLeaked > leakThreshold:
if processType and processType == "tab":
if processType == "tab":
# For now, ignore tab process leaks. See bug 1051230.
log.info("WARNING | leakcheck | ignoring leaks in tab process")
prefix = "WARNING"
@ -302,6 +298,15 @@ def processLeakLog(leakLogFile, leakThreshold = 0):
Use this function if you want an additional PASS/FAIL summary.
It must be used with the |XPCOM_MEM_BLOAT_LOG| environment variable.
The base of leakLogFile for a non-default process needs to end with
_proctype_pid12345.log
"proctype" is a string denoting the type of the process, which should
be the result of calling XRE_ChildProcessTypeToString(). 12345 is
a series of digits that is the pid for the process. The .log is
optional.
All other file names are treated as being for default processes.
"""
if not os.path.exists(leakLogFile):
@ -312,18 +317,20 @@ def processLeakLog(leakLogFile, leakThreshold = 0):
log.info("TEST-INFO | leakcheck | threshold set at %d bytes" % leakThreshold)
(leakLogFileDir, leakFileBase) = os.path.split(leakLogFile)
fileNameRegExp = re.compile(r".*?_([a-z]*)_pid\d*$")
if leakFileBase[-4:] == ".log":
leakFileBase = leakFileBase[:-4]
fileNameRegExp = re.compile(r".*?_([a-z]*)_pid\d*.log$")
fileNameRegExp = re.compile(r"_([a-z]*)_pid\d*.log$")
else:
fileNameRegExp = re.compile(r"_([a-z]*)_pid\d*$")
for fileName in os.listdir(leakLogFileDir):
if fileName.find(leakFileBase) != -1:
thisFile = os.path.join(leakLogFileDir, fileName)
processType = None
m = fileNameRegExp.search(fileName)
if m:
processType = m.group(1)
else:
processType = "default"
processSingleLeakFile(thisFile, processType, leakThreshold)
def replaceBackSlashes(input):

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

@ -508,9 +508,7 @@ gssapi/gssapi.h
gssapi.h
gtk/gtk.h
gtk/gtkx.h
gtk/gtkprinter.h
gtk/gtkprintjob.h
gtk/gtkprintunixdialog.h
gtk/gtkunixprint.h
#ifdef ANDROID
gui/BufferQueue.h
gui/ConsumerBase.h

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

@ -62,7 +62,7 @@ GLIB_VERSION=1.2.0
PERL_VERSION=5.006
CAIRO_VERSION=1.10
PANGO_VERSION=1.22.0
GTK2_VERSION=2.10.0
GTK2_VERSION=2.18.0
GTK3_VERSION=3.0.0
WINDRES_VERSION=2.14.90
W32API_VERSION=3.14

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

@ -107,7 +107,7 @@ nsDOMFileReader::Init()
// Instead of grabbing some random global from the context stack,
// let's use the default one (junk scope) for now.
// We should move away from this Init...
BindToOwner(xpc::GetNativeForGlobal(xpc::PrivilegedJunkScope()));
BindToOwner(xpc::NativeGlobal(xpc::PrivilegedJunkScope()));
return NS_OK;
}

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

@ -2154,7 +2154,7 @@ nsDocument::Init()
// we use the default compartment for this document, instead of creating
// wrapper in some random compartment when the document is exposed to js
// via some events.
nsCOMPtr<nsIGlobalObject> global = xpc::GetNativeForGlobal(xpc::PrivilegedJunkScope());
nsCOMPtr<nsIGlobalObject> global = xpc::NativeGlobal(xpc::PrivilegedJunkScope());
NS_ENSURE_TRUE(global, NS_ERROR_FAILURE);
mScopeObject = do_GetWeakReference(global);
MOZ_ASSERT(mScopeObject);

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

@ -968,7 +968,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
// }
// JSContext* cx = aes.cx();
nsIGlobalObject* nativeGlobal =
xpc::GetNativeForGlobal(js::GetGlobalForObjectCrossCompartment(wrappedJS->GetJSObject()));
xpc::NativeGlobal(js::GetGlobalForObjectCrossCompartment(wrappedJS->GetJSObject()));
AutoEntryScript aes(nativeGlobal);
JSContext* cx = aes.cx();
JS::Rooted<JSObject*> object(cx, wrappedJS->GetJSObject());

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

@ -352,7 +352,7 @@ nsXMLHttpRequest::Init()
// Instead of grabbing some random global from the context stack,
// let's use the default one (junk scope) for now.
// We should move away from this Init...
Construct(subjectPrincipal, xpc::GetNativeForGlobal(xpc::PrivilegedJunkScope()));
Construct(subjectPrincipal, xpc::NativeGlobal(xpc::PrivilegedJunkScope()));
return NS_OK;
}

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

@ -85,7 +85,7 @@ VP8TrackEncoder::Init(int32_t aWidth, int32_t aHeight, int32_t aDisplayWidth,
// Creating a wrapper to the image - setting image data to NULL. Actual
// pointer will be set in encode. Setting align to 1, as it is meaningless
// (actual memory is not allocated).
vpx_img_wrap(mVPXImageWrapper, IMG_FMT_I420,
vpx_img_wrap(mVPXImageWrapper, VPX_IMG_FMT_I420,
mFrameWidth, mFrameHeight, 1, nullptr);
config.g_w = mFrameWidth;
@ -279,9 +279,9 @@ nsresult VP8TrackEncoder::PrepareRawFrame(VideoChunk &aChunk)
const PlanarYCbCrImage::Data *data = yuv->GetData();
if (isYUV420(data) && !data->mCbSkip) { // 420 planar
mVPXImageWrapper->planes[PLANE_Y] = data->mYChannel;
mVPXImageWrapper->planes[PLANE_U] = data->mCbChannel;
mVPXImageWrapper->planes[PLANE_V] = data->mCrChannel;
mVPXImageWrapper->planes[VPX_PLANE_Y] = data->mYChannel;
mVPXImageWrapper->planes[VPX_PLANE_U] = data->mCbChannel;
mVPXImageWrapper->planes[VPX_PLANE_V] = data->mCrChannel;
mVPXImageWrapper->stride[VPX_PLANE_Y] = data->mYStride;
mVPXImageWrapper->stride[VPX_PLANE_U] = data->mCbCrStride;
mVPXImageWrapper->stride[VPX_PLANE_V] = data->mCbCrStride;
@ -337,9 +337,9 @@ nsresult VP8TrackEncoder::PrepareRawFrame(VideoChunk &aChunk)
return NS_ERROR_NOT_IMPLEMENTED;
}
mVPXImageWrapper->planes[PLANE_Y] = y;
mVPXImageWrapper->planes[PLANE_U] = cb;
mVPXImageWrapper->planes[PLANE_V] = cr;
mVPXImageWrapper->planes[VPX_PLANE_Y] = y;
mVPXImageWrapper->planes[VPX_PLANE_U] = cb;
mVPXImageWrapper->planes[VPX_PLANE_V] = cr;
mVPXImageWrapper->stride[VPX_PLANE_Y] = mFrameWidth;
mVPXImageWrapper->stride[VPX_PLANE_U] = halfWidth;
mVPXImageWrapper->stride[VPX_PLANE_V] = halfWidth;

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

@ -8,6 +8,7 @@ support-files =
[test_BufferedSeek.html]
[test_FrameSelection.html]
[test_MediaSource.html]
[test_MediaSource_disabled.html]
[test_SeekableAfterEndOfStream.html]
[test_SeekableAfterEndOfStreamSplit.html]
[test_SeekableBeforeEndOfStream.html]

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

@ -12,12 +12,6 @@
SimpleTest.waitForExplicitFinish();
addLoadEvent(function () {
ok(!window.MediaSource && !window.SourceBuffer && !window.SourceBufferList,
"MediaSource should be hidden behind a pref");
SimpleTest.doesThrow(() => new MediaSource, "MediaSource should be hidden behind a pref");
});
runWithMSE(function () {
SimpleTest.doesThrow(() => new SourceBuffer, "new SourceBuffer should fail");
SimpleTest.doesThrow(() => new SourceBufferList, "new SourceBufferList direct should fail");

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

@ -0,0 +1,28 @@
<!DOCTYPE HTML>
<html>
<head>
<title>MSE: disabling via pref</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
function test() {
ok(!window.MediaSource && !window.SourceBuffer && !window.SourceBufferList,
"MediaSource should be hidden behind a pref");
SimpleTest.doesThrow(() => new MediaSource,
"MediaSource should be hidden behind a pref");
SimpleTest.finish();
}
SpecialPowers.pushPrefEnv({"set": [["media.mediasource.enabled", false]]},
test);
</script>
</pre>
</body>
</html>

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

@ -925,7 +925,7 @@ bool WebMReader::DecodeVideoFrame(bool &aKeyframeSkip,
vpx_image_t *img;
while ((img = vpx_codec_get_frame(&mVPX, &iter))) {
NS_ASSERTION(img->fmt == IMG_FMT_I420, "WebM image format is not I420");
NS_ASSERTION(img->fmt == VPX_IMG_FMT_I420, "WebM image format is not I420");
// Chroma shifts are rounded down as per the decoding examples in the VP8 SDK
VideoData::YCbCrBuffer b;

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

@ -0,0 +1,148 @@
/* 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/. */
/* global Components, Services, dump */
"use strict";
const Cu = Components.utils;
const Cc = Components.classes;
const Ci = Components.interfaces;
this.EXPORTED_SYMBOLS = ["TrustedHostedAppsUtils"];
Cu.import("resource://gre/modules/Services.jsm");
#ifdef MOZ_WIDGET_ANDROID
// On Android, define the "debug" function as a binding of the "d" function
// from the AndroidLog module so it gets the "debug" priority and a log tag.
// We always report debug messages on Android because it's unnecessary
// to restrict reporting, per bug 1003469.
let debug = Cu
.import("resource://gre/modules/AndroidLog.jsm", {})
.AndroidLog.d.bind(null, "TrustedHostedAppsUtils");
#else
// Elsewhere, report debug messages only if dom.mozApps.debug is set to true.
// The pref is only checked once, on startup, so restart after changing it.
let debug = Services.prefs.getBoolPref("dom.mozApps.debug") ?
aMsg => dump("-*- TrustedHostedAppsUtils.jsm : " + aMsg + "\n") :
() => {};
#endif
/**
* Verification functions for Trusted Hosted Apps.
* (Manifest signature verification is in Webapps.jsm as part of
* regular signature verification.)
*/
this.TrustedHostedAppsUtils = {
/**
* Check if the given host is pinned in the CA pinning database.
*/
isHostPinned: function (aUrl) {
let uri;
try {
uri = Services.io.newURI(aUrl, null, null);
} catch(e) {
debug("Host parsing failed: " + e);
return false;
}
// TODO: use nsSiteSecurityService.isSecureURI()
if (!uri.host || "https" != uri.scheme) {
return false;
}
// Check certificate pinning
let siteSecurityService;
try {
siteSecurityService = Cc["@mozilla.org/ssservice;1"]
.getService(Ci.nsISiteSecurityService);
} catch (e) {
debug("nsISiteSecurityService error: " + e);
// unrecoverable error, don't bug the user
throw "CERTDB_ERROR";
}
if (siteSecurityService.isSecureHost(Ci.nsISiteSecurityService.HEADER_HPKP, uri.host, 0)) {
debug("\tvalid certificate pinning for host: " + uri.host + "\n");
return true;
}
debug("\tHost NOT pinned: " + uri.host + "\n");
return false;
},
/**
* Take a CSP policy string as input and ensure that it contains at
* least the directives that are required ('script-src' and
* 'style-src'). If the CSP policy string is 'undefined' or does
* not contain some of the required csp directives the function will
* return empty list with status set to false. Otherwise a parsed
* list of the unique sources listed from the required csp
* directives is returned.
*/
getCSPWhiteList: function(aCsp) {
let isValid = false;
let whiteList = [];
let requiredDirectives = [ "script-src", "style-src" ];
if (aCsp) {
let validDirectives = [];
let directives = aCsp.split(";");
// TODO: Use nsIContentSecurityPolicy
directives
.map(aDirective => aDirective.trim().split(" "))
.filter(aList => aList.length > 1)
// we only restrict on requiredDirectives
.filter(aList => (requiredDirectives.indexOf(aList[0]) != -1))
.forEach(aList => {
// aList[0] contains the directive name.
// aList[1..n] contains sources.
let directiveName = aList.shift()
let sources = aList;
if ((-1 == validDirectives.indexOf(directiveName))) {
validDirectives.push(directiveName);
}
whiteList.push(...sources.filter(
// 'self' is checked separately during manifest check
aSource => (aSource !="'self'" && whiteList.indexOf(aSource) == -1)
));
});
// Check if all required directives are present.
isValid = requiredDirectives.length === validDirectives.length;
if (!isValid) {
debug("White list doesn't contain all required directives!");
whiteList = [];
}
}
debug("White list contains " + whiteList.length + " hosts");
return { list: whiteList, valid: isValid };
},
/**
* Verify that the given csp is valid:
* 1. contains required directives "script-src" and "style-src"
* 2. required directives contain only "https" URLs
* 3. domains of the restricted sources exist in the CA pinning database
*/
verifyCSPWhiteList: function(aCsp) {
let domainWhitelist = this.getCSPWhiteList(aCsp);
if (!domainWhitelist.valid) {
debug("TRUSTED_APPLICATION_WHITELIST_PARSING_FAILED");
return false;
}
if (!domainWhitelist.list.every(aUrl => this.isHostPinned(aUrl))) {
debug("TRUSTED_APPLICATION_WHITELIST_VALIDATION_FAILED");
return false;
}
return true;
}
};

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

@ -64,6 +64,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
XPCOMUtils.defineLazyModuleGetter(this, "ScriptPreloader",
"resource://gre/modules/ScriptPreloader.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TrustedHostedAppsUtils",
"resource://gre/modules/TrustedHostedAppsUtils.jsm");
#ifdef MOZ_WIDGET_GONK
XPCOMUtils.defineLazyGetter(this, "libcutils", function() {
Cu.import("resource://gre/modules/systemlibs.js");
@ -1411,6 +1414,24 @@ this.DOMApplicationRegistry = {
return;
}
// Check if launching trusted hosted app
if (this.kTrustedHosted == app.kind) {
debug("Launching Trusted Hosted App!");
// sanity check on manifest host's CA
// (proper CA check with pinning is done by regular networking code)
if (!TrustedHostedAppsUtils.isHostPinned(aManifestURL)) {
debug("Trusted App Host certificate Not OK");
aOnFailure("TRUSTED_APPLICATION_HOST_CERTIFICATE_INVALID");
return;
}
debug("Trusted App Host pins exist");
if (!TrustedHostedAppsUtils.verifyCSPWhiteList(app.csp)) {
aOnFailure("TRUSTED_APPLICATION_WHITELIST_VALIDATION_FAILED");
return;
}
}
// We have to clone the app object as nsIDOMApplication objects are
// stringified as an empty object. (see bug 830376)
let appClone = AppsUtils.cloneAppObject(app);
@ -2295,6 +2316,23 @@ this.DOMApplicationRegistry = {
// in which case we don't need to load it.
if (app.manifest) {
if (checkManifest()) {
if (this.kTrustedHosted == this.appKind(app, app.manifest)) {
// sanity check on manifest host's CA
// (proper CA check with pinning is done by regular networking code)
if (!TrustedHostedAppsUtils.isHostPinned(app.manifestURL)) {
sendError("TRUSTED_APPLICATION_HOST_CERTIFICATE_INVALID");
return;
}
// Signature of the manifest should be verified here.
// Bug 1059216.
if (!TrustedHostedAppsUtils.verifyCSPWhiteList(app.manifest.csp)) {
sendError("TRUSTED_APPLICATION_WHITELIST_VALIDATION_FAILED");
return;
}
}
installApp();
}
return;
@ -2319,6 +2357,19 @@ this.DOMApplicationRegistry = {
app.manifest = xhr.response;
if (checkManifest()) {
app.etag = xhr.getResponseHeader("Etag");
if (this.kTrustedHosted == this.appKind(app, app.manifest)) {
// checking trusted host for pinning is not needed here, since
// network code will have already done that
// Signature of the manifest should be verified here.
// Bug 1059216.
if (!TrustedHostedAppsUtils.verifyCSPWhiteList(app.manifest.csp)) {
sendError("TRUSTED_APPLICATION_WHITELIST_VALIDATION_FAILED");
return;
}
}
installApp();
}
} else {

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

@ -44,6 +44,7 @@ EXTRA_PP_JS_MODULES += [
'AppsUtils.jsm',
'OperatorApps.jsm',
'ScriptPreloader.jsm',
'TrustedHostedAppsUtils.jsm',
'Webapps.jsm',
]

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

@ -7,6 +7,7 @@ support-files =
[test_apps_service.xul]
[test_bug_945152.html]
run-if = os == 'linux'
[test_tha_utils.html]
[test_manifest_helper.xul]
[test_operator_app_install.js]
[test_operator_app_install.xul]

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

@ -196,8 +196,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=826058
yield undefined;
info("Uninstalled hosted appcache app");
/**
* DISABLED FOR NOW UNTIL WE CAN TEST PINNING PROPERLY
*/
// Install the trusted app.
setAppVersion(4, continueTest);
/*setAppVersion(4, continueTest);
yield undefined;
ok(true, "Installing trusted app");
var request = navigator.mozApps.install(gTrustedManifestURL);
@ -215,14 +218,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=826058
}
is(app.installState, "installed", "Trusted App is installed");
is(app.manifest.type, "trusted", "App is trusted");
*/
// Check the cached app.
checkAppState(app, true, 4, continueTest);
yield undefined;
/*checkAppState(app, true, 4, continueTest);
yield undefined;*/
// Check for updates. The current infrastructure always returns a new appcache
// manifest, so there should always be an update.
var lastCheck = app.lastUpdateCheck;
/*var lastCheck = app.lastUpdateCheck;
ok(true, "Setting callbacks");
app.ondownloadapplied = function() ok(true, "downloadapplied fired.");
app.ondownloadavailable = function() ok(false, "downloadavailable fired");
@ -231,15 +234,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=826058
request.onerror = mozAppsError;
request.onsuccess = continueTest;
yield undefined;
todo(app.lastUpdateCheck > lastCheck, "lastUpdateCheck updated appropriately");
todo(app.lastUpdateCheck > lastCheck, "lastUpdateCheck updated appropriately");*/
// Uninstall the app.
request = navigator.mozApps.mgmt.uninstall(app);
/*request = navigator.mozApps.mgmt.uninstall(app);
request.onerror = mozAppsError;
request.onsuccess = continueTest;
yield undefined;
info("Uninstalled trusted app");
info("Uninstalled trusted app");*/
}
function setAppVersion(version, cb) {

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

@ -0,0 +1,237 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test for Trusted Hosted Apps Utils</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
<script type="application/javascript;version=1.7">
Components.utils.import("resource://gre/modules/TrustedHostedAppsUtils.jsm");
SimpleTest.waitForExplicitFinish();
let tests = [{
key: "getCSPWhiteList with no argument",
func: function test1() {
let cspWhiteList = TrustedHostedAppsUtils.getCSPWhiteList();
ok(!cspWhiteList.valid, "Should be invalid");
is(cspWhiteList.list.length, 0, "List should be empty");
nextTest();
}
},{
key: "getCSPWhiteList without style-src",
func: function test2() {
let cspWhiteList = TrustedHostedAppsUtils.getCSPWhiteList(
"script-src https://script.example.com; stylee-src https://style.example.com"
);
ok(!cspWhiteList.valid, "Should be invalid");
is(cspWhiteList.list.length, 0, "List should be empty");
nextTest();
}
},{
key: "getCSPWhiteList without script-src",
func: function test3() {
let cspWhiteList = TrustedHostedAppsUtils.getCSPWhiteList(
"script-source https://script.example.com; style-src https://style.example.com"
);
ok(!cspWhiteList.valid, "Should be invalid");
is(cspWhiteList.list.length, 0, "List should be empty");
nextTest();
}
},{
key: "getCSPWhiteList without source",
func: function test4() {
let cspWhiteList = TrustedHostedAppsUtils.getCSPWhiteList(
"script-src; style-src https://style.example.com"
);
ok(!cspWhiteList.valid, "Should be invalid");
is(cspWhiteList.list.length, 0, "List should be empty");
nextTest();
}
},{
key: "getCSPWhiteList working",
func: function test5() {
let cspWhiteList = TrustedHostedAppsUtils.getCSPWhiteList(
"script-src https://script.example.com; style-src https://style.example.com"
);
ok(cspWhiteList.valid, "Should be valid");
is(cspWhiteList.list.length, 2, "List should have two sources");
ok(cspWhiteList.list.every(aEl => ["https://script.example.com", "https://style.example.com"].indexOf(aEl) != -1), "Sources: " + cspWhiteList.list);
nextTest();
}
},{
key: "getCSPWhiteList working with duplicates",
func: function test6() {
let cspWhiteList = TrustedHostedAppsUtils.getCSPWhiteList(
"script-src https://script.example.com;" +
"style-src https://style.example.com;" +
"style-src https://style.example.com;" +
"style-src https://style.example.com;" +
"style-src https://style.example.com;"
);
ok(cspWhiteList.valid, "Should be valid");
is(cspWhiteList.list.length, 2, "List should have two sources");
ok(cspWhiteList.list.every(aEl => ["https://script.example.com", "https://style.example.com"].indexOf(aEl) != -1), "Sources: " + cspWhiteList.list);
nextTest();
}
},{
key: "getCSPWhiteList working with duplicates and many sources",
func: function test7() {
let cspWhiteList = TrustedHostedAppsUtils.getCSPWhiteList(
"script-src https://script.example.com https://script2.example.com;" +
"style-src https://style.example.com;" +
"style-src https://style.example.com https://script1.example.com;" +
"style-src https://style.example.com https://style2.example.com;" +
"style-src https://style3.example.com;"
);
ok(cspWhiteList.valid, "Should be valid");
is(cspWhiteList.list.length, 6, "List should have 6 sources");
ok(cspWhiteList.list.every(aEl => ["https://script.example.com",
"https://script1.example.com",
"https://script2.example.com",
"https://style.example.com",
"https://style2.example.com",
"https://style3.example.com"].indexOf(aEl) != -1),
"Sources: " + cspWhiteList.list);
nextTest();
}
},{
key: "getCSPWhiteList only adds sources from required directives",
func: function test8() {
let cspWhiteList = TrustedHostedAppsUtils.getCSPWhiteList(
"script-src https://script.example.com https://script2.example.com;" +
"style-src https://style.example.com;" +
"img-src https://img.example.com;" +
"audio-src https://audio.example.com https://audio2.example.com;" +
"video-src https://video.example.com;" +
"default-src *;" +
"media-src http://media.example.com;" +
"child-src http://child.example.com;" +
"frame-src http://frame.example.com;" +
"frame-ancestrs http://frame-a.example.com;" +
"font-src http://font.example.com;" +
"connect-src http://connect.example.com;"
);
ok(cspWhiteList.valid, "Should be valid");
is(cspWhiteList.list.length, 3, "List should have 3 sources");
ok(cspWhiteList.list.every(aEl => ["https://script.example.com",
"https://script2.example.com",
"https://style.example.com"].indexOf(aEl) != -1),
"Sources: " + cspWhiteList.list);
nextTest();
}
},{
key: "getCSPWhiteList allows 'self' but doesn't add it",
func: function test9() {
let cspWhiteList = TrustedHostedAppsUtils.getCSPWhiteList(
"script-src 'self';" +
"style-src 'self'"
);
ok(cspWhiteList.valid, "Should be valid");
is(cspWhiteList.list.length, 0, "List should have no source");
nextTest();
}
},{
key: "getCSPWhiteList allows *",
func: function test10() {
let cspWhiteList = TrustedHostedAppsUtils.getCSPWhiteList(
"script-src *;" +
"style-src https://style.example.com"
);
ok(cspWhiteList.valid, "Should be valid");
is(cspWhiteList.list.length, 2, "List should have 2 sources");
nextTest();
}
},{
key: "isHostPinned doesn't allow *",
func: function test11() {
let isHostPinned = TrustedHostedAppsUtils.isHostPinned("*");
ok(!isHostPinned, "Should not be pinned");
nextTest();
}
},{
key: "isHostPinned doesn't allow http urls",
func: function test12() {
let isHostPinned = TrustedHostedAppsUtils.isHostPinned("http://example.com");
ok(!isHostPinned, "Should not be pinned:(" + isHostPinned + ") http://example.com");
nextTest();
}
},{
key: "isHostPinned doesn't allow shema-less urls",
func: function test13() {
let isHostPinned = TrustedHostedAppsUtils.isHostPinned("example.com");
ok(!isHostPinned, "Should not be pinned:(" + isHostPinned + ") example.com");
nextTest();
}
},{
key: "isHostPinned doesn't allow 'unsafe-eval'",
func: function test14() {
let isHostPinned = TrustedHostedAppsUtils.isHostPinned("'unsafe-eval'");
ok(!isHostPinned, "Should not be pinned:(" + isHostPinned + ") 'unsafe-eval'");
nextTest();
}
},{
key: "isHostPinned doesn't allow 'unsafe-inline'",
func: function test15() {
let isHostPinned = TrustedHostedAppsUtils.isHostPinned("'unsafe-inline'");
ok(!isHostPinned, "Should not be pinned:(" + isHostPinned + ") 'unsafe-inline'");
nextTest();
}
},{
key: "isHostPinned doesn't allow foobar",
func: function test16() {
let isHostPinned = TrustedHostedAppsUtils.isHostPinned("foobar");
ok(!isHostPinned, "Should not be pinned:(" + isHostPinned + ") foobar");
nextTest();
}
},{
key: "isHostPinned doesn't allow https://www.example.com:*",
func: function test17() {
let isHostPinned = TrustedHostedAppsUtils.isHostPinned("https://example.com:*");
ok(!isHostPinned, "Should not be pinned:(" + isHostPinned + ") https://example.com:*");
nextTest();
}
},{
key: "isHostPinned doesn't allow https://*.example.com",
func: function test18() {
let isHostPinned = TrustedHostedAppsUtils.isHostPinned("https://*.example.com");
ok(!isHostPinned, "Should not be pinned:(" + isHostPinned + ") https://*.example.com");
nextTest();
}
}];
let testGenerator = function _testGenerator() {
for (let i = 0; i < tests.length; ++i) {
yield tests[i];
}
}();
let nextTest = () => {
try {
let t = testGenerator.next();
info("test: " + t.key);
t.func();
} catch(e) {
if (e instanceof StopIteration) {
SimpleTest.finish();
} else {
throw e;
}
}
}
document.addEventListener("DOMContentLoaded", function () {
nextTest();
});
</script>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>
<div id="container"></div>
</body>
</html>

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

@ -892,115 +892,6 @@ Navigator::RegisterProtocolHandler(const nsAString& aProtocol,
mWindow->GetOuterWindow());
}
bool
Navigator::MozIsLocallyAvailable(const nsAString &aURI,
bool aWhenOffline,
ErrorResult& aRv)
{
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), aURI);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return false;
}
// This method of checking the cache will only work for http/https urls.
bool match;
rv = uri->SchemeIs("http", &match);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return false;
}
if (!match) {
rv = uri->SchemeIs("https", &match);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return false;
}
if (!match) {
aRv.Throw(NS_ERROR_DOM_BAD_URI);
return false;
}
}
// Same origin check.
JSContext *cx = nsContentUtils::GetCurrentJSContext();
if (!cx) {
aRv.Throw(NS_ERROR_FAILURE);
return false;
}
rv = nsContentUtils::GetSecurityManager()->CheckSameOrigin(cx, uri);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return false;
}
// These load flags cause an error to be thrown if there is no
// valid cache entry, and skip the load if there is.
// If the cache is busy, assume that it is not yet available rather
// than waiting for it to become available.
uint32_t loadFlags = nsIChannel::INHIBIT_CACHING |
nsICachingChannel::LOAD_NO_NETWORK_IO |
nsICachingChannel::LOAD_ONLY_IF_MODIFIED |
nsICachingChannel::LOAD_BYPASS_LOCAL_CACHE_IF_BUSY;
if (aWhenOffline) {
loadFlags |= nsICachingChannel::LOAD_CHECK_OFFLINE_CACHE |
nsICachingChannel::LOAD_ONLY_FROM_CACHE |
nsIRequest::LOAD_FROM_CACHE;
}
if (!mWindow) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return false;
}
nsCOMPtr<nsILoadGroup> loadGroup;
nsCOMPtr<nsIDocument> doc = mWindow->GetDoc();
if (doc) {
loadGroup = doc->GetDocumentLoadGroup();
}
nsCOMPtr<nsIChannel> channel;
rv = NS_NewChannel(getter_AddRefs(channel), uri,
nullptr, loadGroup, nullptr, loadFlags);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return false;
}
nsCOMPtr<nsIInputStream> stream;
rv = channel->Open(getter_AddRefs(stream));
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return false;
}
stream->Close();
nsresult status;
rv = channel->GetStatus(&status);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return false;
}
if (NS_FAILED(status)) {
return false;
}
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
bool isAvailable;
rv = httpChannel->GetRequestSucceeded(&isAvailable);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return false;
}
return isAvailable;
}
nsDOMDeviceStorage*
Navigator::GetDeviceStorage(const nsAString& aType, ErrorResult& aRv)
{

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

@ -207,8 +207,6 @@ public:
nsTArray<nsRefPtr<nsDOMDeviceStorage> >& aStores,
ErrorResult& aRv);
DesktopNotificationCenter* GetMozNotification(ErrorResult& aRv);
bool MozIsLocallyAvailable(const nsAString& aURI, bool aWhenOffline,
ErrorResult& aRv);
MobileMessageManager* GetMozMobileMessage();
Telephony* GetMozTelephony(ErrorResult& aRv);
network::Connection* GetConnection(ErrorResult& aRv);

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

@ -154,7 +154,7 @@ GetIncumbentGlobal()
// there's nothing on the JS stack, which will cause us to check the
// incumbent script stack below.
if (JSObject *global = JS::GetScriptedCallerGlobal(cx)) {
return xpc::GetNativeForGlobal(global);
return xpc::NativeGlobal(global);
}
// Ok, nothing from the JS engine. Let's use whatever's on the
@ -175,7 +175,7 @@ GetCurrentGlobal()
return nullptr;
}
return xpc::GetNativeForGlobal(global);
return xpc::NativeGlobal(global);
}
nsIPrincipal*
@ -302,6 +302,12 @@ AutoJSAPI::Init(nsIGlobalObject* aGlobalObject)
return Init(aGlobalObject, nsContentUtils::GetDefaultJSContextForThread());
}
bool
AutoJSAPI::Init(JSObject* aObject)
{
return Init(xpc::NativeGlobal(aObject));
}
bool
AutoJSAPI::InitWithLegacyErrorReporting(nsIGlobalObject* aGlobalObject)
{

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

@ -214,6 +214,10 @@ public:
// false and use of cx() will cause an assertion.
bool Init(nsIGlobalObject* aGlobalObject);
// This is a helper that grabs the native global associated with aObject and
// invokes the above Init() with that.
bool Init(JSObject* aObject);
// Unsurprisingly, this uses aCx and enters the compartment of aGlobalObject.
// If aGlobalObject or its associated JS global are null then it returns
// false and use of cx() will cause an assertion.

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

@ -1612,12 +1612,12 @@ nsFocusManager::Blur(nsPIDOMWindow* aWindowToClear,
widget->SetFocus(false);
}
}
}
// if the object being blurred is a remote browser, deactivate remote content
if (TabParent* remote = TabParent::GetFrom(content)) {
remote->Deactivate();
LOGFOCUS(("Remote browser deactivated"));
}
if (TabParent* remote = TabParent::GetFrom(content)) {
remote->Deactivate();
LOGFOCUS(("Remote browser deactivated"));
}
}

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

@ -484,7 +484,7 @@ SystemErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
}
if (!globalObject) {
globalObject = xpc::GetNativeForGlobal(xpc::PrivilegedJunkScope());
globalObject = xpc::NativeGlobal(xpc::PrivilegedJunkScope());
}
if (globalObject) {
@ -2581,7 +2581,7 @@ NS_DOMReadStructuredClone(JSContext* cx,
if (tag == SCTAG_DOM_IMAGEDATA) {
return ReadStructuredCloneImageData(cx, reader);
} else if (tag == SCTAG_DOM_WEBCRYPTO_KEY) {
nsIGlobalObject *global = xpc::GetNativeForGlobal(JS::CurrentGlobalOrNull(cx));
nsIGlobalObject *global = xpc::NativeGlobal(JS::CurrentGlobalOrNull(cx));
if (!global) {
return nullptr;
}

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

@ -61,7 +61,7 @@ nsStructuredCloneContainer::InitFromJSVal(JS::Handle<JS::Value> aData)
// part of the "own" "deep clone" sub-steps, so we need an AutoEntryScript.
// http://www.whatwg.org/specs/web-apps/current-work/#internal-structured-cloning-algorithm
nsIGlobalObject* nativeGlobal =
xpc::GetNativeForGlobal(js::GetGlobalForObjectCrossCompartment(&aData.toObject()));
xpc::NativeGlobal(js::GetGlobalForObjectCrossCompartment(&aData.toObject()));
dom::AutoEntryScript aes(nativeGlobal);
success = JS_WriteStructuredClone(aes.cx(), aData, &jsBytes, &mSize,
nullptr, nullptr,

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

@ -109,7 +109,7 @@ CallbackObject::CallSetup::CallSetup(CallbackObject* aCallback,
} else {
// No DOM Window. Store the global and use the SafeJSContext.
JSObject* glob = js::GetGlobalForObjectCrossCompartment(realCallback);
globalObject = xpc::GetNativeForGlobal(glob);
globalObject = xpc::NativeGlobal(glob);
MOZ_ASSERT(globalObject);
cx = nsContentUtils::GetSafeJSContext();
}

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

@ -2102,6 +2102,9 @@ def MakeClearCachedValueNativeName(member):
def MakeJSImplClearCachedValueNativeName(member):
return "_" + MakeClearCachedValueNativeName(member)
def IDLToCIdentifier(name):
return name.replace("-", "_")
class MethodDefiner(PropertyDefiner):
"""
@ -2288,7 +2291,7 @@ class MethodDefiner(PropertyDefiner):
jitinfo = "nullptr"
else:
selfHostedName = "nullptr"
accessor = m.get("nativeName", m["name"])
accessor = m.get("nativeName", IDLToCIdentifier(m["name"]))
if m.get("methodInfo", True):
# Cast this in case the methodInfo is a
# JSTypedMethodJitInfo.
@ -2380,7 +2383,7 @@ class AttrDefiner(PropertyDefiner):
def getter(attr):
if self.static:
accessor = 'get_' + attr.identifier.name
accessor = 'get_' + IDLToCIdentifier(attr.identifier.name)
jitinfo = "nullptr"
else:
if attr.hasLenientThis():
@ -2391,7 +2394,8 @@ class AttrDefiner(PropertyDefiner):
accessor = "genericGetter"
else:
accessor = "GenericBindingGetter"
jitinfo = "&%s_getterinfo" % attr.identifier.name
jitinfo = ("&%s_getterinfo" %
IDLToCIdentifier(attr.identifier.name))
return "{ { JS_CAST_NATIVE_TO(%s, JSPropertyOp), %s } }" % \
(accessor, jitinfo)
@ -2401,7 +2405,7 @@ class AttrDefiner(PropertyDefiner):
attr.getExtendedAttribute("Replaceable") is None):
return "JSOP_NULLWRAPPER"
if self.static:
accessor = 'set_' + attr.identifier.name
accessor = 'set_' + IDLToCIdentifier(attr.identifier.name)
jitinfo = "nullptr"
else:
if attr.hasLenientThis():
@ -2412,7 +2416,7 @@ class AttrDefiner(PropertyDefiner):
accessor = "genericSetter"
else:
accessor = "GenericBindingSetter"
jitinfo = "&%s_setterinfo" % attr.identifier.name
jitinfo = "&%s_setterinfo" % IDLToCIdentifier(attr.identifier.name)
return "{ { JS_CAST_NATIVE_TO(%s, JSStrictPropertyOp), %s } }" % \
(accessor, jitinfo)
@ -2555,7 +2559,7 @@ class CGJsonifyAttributesMethod(CGAbstractMethod):
}
}
""",
name=m.identifier.name)
name=IDLToCIdentifier(m.identifier.name))
ret += 'return true;\n'
return ret
@ -7308,7 +7312,7 @@ class CGAbstractStaticBindingMethod(CGAbstractStaticMethod):
def MakeNativeName(name):
return name[0].upper() + name[1:]
return name[0].upper() + IDLToCIdentifier(name[1:])
class CGGenericMethod(CGAbstractBindingMethod):
@ -7394,7 +7398,7 @@ class CGSpecializedMethod(CGAbstractStaticMethod):
"""
def __init__(self, descriptor, method):
self.method = method
name = CppKeywords.checkMethodName(method.identifier.name)
name = CppKeywords.checkMethodName(IDLToCIdentifier(method.identifier.name))
args = [Argument('JSContext*', 'cx'),
Argument('JS::Handle<JSObject*>', 'obj'),
Argument('%s*' % descriptor.nativeType, 'self'),
@ -7637,7 +7641,7 @@ class CGStaticMethod(CGAbstractStaticBindingMethod):
"""
def __init__(self, descriptor, method):
self.method = method
name = method.identifier.name
name = IDLToCIdentifier(method.identifier.name)
CGAbstractStaticBindingMethod.__init__(self, descriptor, name)
def generate_code(self):
@ -7695,7 +7699,7 @@ class CGSpecializedGetter(CGAbstractStaticMethod):
"""
def __init__(self, descriptor, attr):
self.attr = attr
name = 'get_' + attr.identifier.name
name = 'get_' + IDLToCIdentifier(attr.identifier.name)
args = [
Argument('JSContext*', 'cx'),
Argument('JS::Handle<JSObject*>', 'obj'),
@ -7761,7 +7765,7 @@ class CGStaticGetter(CGAbstractStaticBindingMethod):
"""
def __init__(self, descriptor, attr):
self.attr = attr
name = 'get_' + attr.identifier.name
name = 'get_' + IDLToCIdentifier(attr.identifier.name)
CGAbstractStaticBindingMethod.__init__(self, descriptor, name)
def generate_code(self):
@ -7827,7 +7831,7 @@ class CGSpecializedSetter(CGAbstractStaticMethod):
"""
def __init__(self, descriptor, attr):
self.attr = attr
name = 'set_' + attr.identifier.name
name = 'set_' + IDLToCIdentifier(attr.identifier.name)
args = [Argument('JSContext*', 'cx'),
Argument('JS::Handle<JSObject*>', 'obj'),
Argument('%s*' % descriptor.nativeType, 'self'),
@ -7852,7 +7856,7 @@ class CGStaticSetter(CGAbstractStaticBindingMethod):
"""
def __init__(self, descriptor, attr):
self.attr = attr
name = 'set_' + attr.identifier.name
name = 'set_' + IDLToCIdentifier(attr.identifier.name)
CGAbstractStaticBindingMethod.__init__(self, descriptor, name)
def generate_code(self):
@ -8007,10 +8011,12 @@ class CGMemberJITInfo(CGThing):
def define(self):
if self.member.isAttr():
getterinfo = ("%s_getterinfo" % self.member.identifier.name)
getterinfo = ("%s_getterinfo" %
IDLToCIdentifier(self.member.identifier.name))
# We need the cast here because JSJitGetterOp has a "void* self"
# while we have the right type.
getter = ("(JSJitGetterOp)get_%s" % self.member.identifier.name)
getter = ("(JSJitGetterOp)get_%s" %
IDLToCIdentifier(self.member.identifier.name))
getterinfal = "infallible" in self.descriptor.getExtendedAttributes(self.member, getter=True)
getterconst = (self.member.getExtendedAttribute("SameObject") or
self.member.getExtendedAttribute("Constant"))
@ -8044,10 +8050,12 @@ class CGMemberJITInfo(CGThing):
if (not self.member.readonly or
self.member.getExtendedAttribute("PutForwards") is not None or
self.member.getExtendedAttribute("Replaceable") is not None):
setterinfo = ("%s_setterinfo" % self.member.identifier.name)
setterinfo = ("%s_setterinfo" %
IDLToCIdentifier(self.member.identifier.name))
# Actually a JSJitSetterOp, but JSJitGetterOp is first in the
# union.
setter = ("(JSJitGetterOp)set_%s" % self.member.identifier.name)
setter = ("(JSJitGetterOp)set_%s" %
IDLToCIdentifier(self.member.identifier.name))
# Setters are always fallible, since they have to do a typed unwrap.
result += self.defineJitInfo(setterinfo, setter, "Setter",
False, False, "AliasEverything",
@ -8056,8 +8064,10 @@ class CGMemberJITInfo(CGThing):
None)
return result
if self.member.isMethod():
methodinfo = ("%s_methodinfo" % self.member.identifier.name)
name = CppKeywords.checkMethodName(self.member.identifier.name)
methodinfo = ("%s_methodinfo" %
IDLToCIdentifier(self.member.identifier.name))
name = CppKeywords.checkMethodName(
IDLToCIdentifier(self.member.identifier.name))
if self.member.returnsPromise():
name = CGMethodPromiseWrapper.makeName(name)
# Actually a JSJitMethodOp, but JSJitGetterOp is first in the union.
@ -8271,7 +8281,9 @@ class CGStaticMethodJitinfo(CGGeneric):
" JSJitInfo::AliasEverything, JSVAL_TYPE_MISSING, false, false,\n"
" false, false, 0\n"
"};\n" %
(method.identifier.name, method.identifier.name))
(IDLToCIdentifier(method.identifier.name),
CppKeywords.checkMethodName(
IDLToCIdentifier(method.identifier.name))))
def getEnumValueName(value):
@ -11494,7 +11506,7 @@ class CGDictionary(CGThing):
@staticmethod
def makeMemberName(name):
return "m" + name[0].upper() + name[1:].replace("-", "_")
return "m" + name[0].upper() + IDLToCIdentifier(name[1:])
def getMemberType(self, memberInfo):
_, conversionInfo = memberInfo
@ -11701,7 +11713,7 @@ class CGDictionary(CGThing):
@staticmethod
def makeIdName(name):
return name.replace("-", "_") + "_id"
return IDLToCIdentifier(name) + "_id"
@staticmethod
def getDictionaryDependenciesFromType(type):

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

@ -470,6 +470,16 @@ class Descriptor(DescriptorProvider):
m.getExtendedAttribute("AvailableIn") == "PrivilegedApps"):
self.featureDetectibleThings.add("%s.%s" % (self.interface.identifier.name, m.identifier.name))
for member in self.interface.members:
if not member.isAttr() and not member.isMethod():
continue
binaryName = member.getExtendedAttribute("BinaryName")
if binaryName:
assert isinstance(binaryName, list)
assert len(binaryName) == 1
self._binaryNames.setdefault(member.identifier.name,
binaryName[0])
# Build the prototype chain.
self.prototypeChain = []
parent = interface

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

@ -7,7 +7,7 @@ import string
propList = eval(sys.stdin.read())
props = ""
for [prop, id, flags, pref] in propList:
for [name, prop, id, flags, pref] in propList:
extendedAttrs = ["Throws", "TreatNullAs=EmptyString"]
# To limit the overhead of Func= annotations, we only generate them when
# necessary, which is when the
@ -26,6 +26,28 @@ for [prop, id, flags, pref] in propList:
# (e.g. on nsComputedDOMStyle).
props += " [%s] attribute DOMString %s;\n" % (", ".join(extendedAttrs),
prop)
# Per spec, what's actually supposed to happen here is that we're supposed
# to have properties for:
#
# 1) Each supported CSS property name, camelCased.
# 2) Each supported name that contains dashes but doesn't start with a
# dash, without any changes to the name.
# 3) cssFloat
#
# Note that "float" will cause a property called "float" to exist due to (1)
# in that list.
#
# In practice, cssFloat is the only case in which "name" doesn't contain "-"
# but also doesn't match "prop". So the stuff we did with "prop" covers (3)
# and all of (1) except "float". If we now output attributes for all the
# cases where "name" doesn't match "prop" and "name" doesn't start with "-",
# that will cover "float" and (2).
if prop != name and name[0] != "-":
extendedAttrs.append('BinaryName="%s"' % prop)
# Throw in a '_' before the attribute name, because some of these
# property names collide with IDL reserved words.
props += " [%s] attribute DOMString _%s;\n" % (", ".join(extendedAttrs),
name)
idlFile = open(sys.argv[1], "r");
idlTemplate = idlFile.read();

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

@ -3362,7 +3362,8 @@ class IDLAttribute(IDLInterfaceMember):
identifier == "AvailableIn" or
identifier == "NewObject" or
identifier == "UnsafeInPrerendering" or
identifier == "CheckPermissions"):
identifier == "CheckPermissions" or
identifier == "BinaryName"):
# Known attributes that we don't need to do anything with here
pass
else:
@ -3963,7 +3964,8 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
identifier == "Pref" or
identifier == "Func" or
identifier == "AvailableIn" or
identifier == "CheckPermissions"):
identifier == "CheckPermissions" or
identifier == "BinaryName"):
# Known attributes that we don't need to do anything with here
pass
else:

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

@ -689,10 +689,13 @@ public:
// binaryNames tests
void MethodRenamedTo();
void OtherMethodRenamedTo();
void MethodRenamedTo(int8_t);
int8_t AttributeGetterRenamedTo();
int8_t AttributeRenamedTo();
void SetAttributeRenamedTo(int8_t);
int8_t OtherAttributeRenamedTo();
void SetOtherAttributeRenamedTo(int8_t);
// Dictionary tests
void PassDictionary(JSContext*, const Dict&);
@ -831,6 +834,10 @@ public:
TestInterface*, const Dict&, double,
const Optional<float>&);
void SetDashed_attribute(int8_t);
int8_t Dashed_attribute();
void Dashed_method();
// Methods and properties imported via "implements"
bool ImplementedProperty();
void SetImplementedProperty(bool);

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

@ -656,9 +656,13 @@ interface TestInterface {
// binaryNames tests
void methodRenamedFrom();
[BinaryName="otherMethodRenamedTo"]
void otherMethodRenamedFrom();
void methodRenamedFrom(byte argument);
readonly attribute byte attributeGetterRenamedFrom;
attribute byte attributeRenamedFrom;
[BinaryName="otherAttributeRenamedTo"]
attribute byte otherAttributeRenamedFrom;
void passDictionary(optional Dict x);
[Cached, Pure]
@ -830,6 +834,9 @@ interface TestInterface {
attribute TestCallbackInterface jsonifierShouldSkipThis3;
jsonifier;
attribute byte dashed-attribute;
void dashed-method();
// If you add things here, add them to TestExampleGen and TestJSImplGen as well
};

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

@ -520,9 +520,13 @@ interface TestExampleInterface {
// binaryNames tests
void methodRenamedFrom();
[BinaryName="otherMethodRenamedTo"]
void otherMethodRenamedFrom();
void methodRenamedFrom(byte argument);
readonly attribute byte attributeGetterRenamedFrom;
attribute byte attributeRenamedFrom;
[BinaryName="otherAttributeRenamedTo"]
attribute byte otherAttributeRenamedFrom;
void passDictionary(optional Dict x);
[Cached, Pure]
@ -679,6 +683,9 @@ interface TestExampleInterface {
attribute TestCallbackInterface jsonifierShouldSkipThis3;
jsonifier;
attribute byte dashed-attribute;
void dashed-method();
// If you add things here, add them to TestCodeGen and TestJSImplGen as well
};

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

@ -536,9 +536,13 @@ interface TestJSImplInterface {
// binaryNames tests
void methodRenamedFrom();
[BinaryName="otherMethodRenamedTo"]
void otherMethodRenamedFrom();
void methodRenamedFrom(byte argument);
readonly attribute byte attributeGetterRenamedFrom;
attribute byte attributeRenamedFrom;
[BinaryName="otherAttributeRenamedTo"]
attribute byte otherAttributeRenamedFrom;
void passDictionary(optional Dict x);
[Cached, Pure]
@ -712,6 +716,9 @@ interface TestJSImplInterface {
attribute TestCallbackInterface jsonifierShouldSkipThis3;
jsonifier;
attribute byte dashed-attribute;
void dashed-method();
// If you add things here, add them to TestCodeGen as well
};

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

@ -7,9 +7,11 @@
#include "BluetoothRilListener.h"
#include "BluetoothHfpManager.h"
#include "nsIIccProvider.h"
#include "nsIMobileConnectionInfo.h"
#include "nsIRadioInterfaceLayer.h"
#include "nsRadioInterfaceLayer.h"
#include "nsIMobileConnectionService.h"
#include "nsITelephonyService.h"
#include "nsRadioInterfaceLayer.h" // For NS_RILCONTENTHELPER_CONTRACTID.
#include "nsServiceManagerUtils.h"
#include "nsString.h"
@ -179,11 +181,15 @@ MobileConnectionListener::Listen(bool aStart)
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(service, false);
nsCOMPtr<nsIMobileConnection> connection;
service->GetItemByServiceId(mClientId, getter_AddRefs(connection));
NS_ENSURE_TRUE(connection, false);
nsresult rv;
if (aStart) {
rv = service->RegisterListener(mClientId, this);
rv = connection->RegisterListener(this);
} else {
rv = service->UnregisterListener(mClientId, this);
rv = connection->UnregisterListener(this);
}
return NS_SUCCEEDED(rv);
@ -329,17 +335,17 @@ TelephonyListener::Listen(bool aStart)
*/
BluetoothRilListener::BluetoothRilListener()
{
nsCOMPtr<nsIMobileConnectionService> service =
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
NS_ENSURE_TRUE_VOID(service);
// Query number of total clients (sim slots)
uint32_t numOfClients;
nsCOMPtr<nsIRadioInterfaceLayer> radioInterfaceLayer =
do_GetService(NS_RADIOINTERFACELAYER_CONTRACTID);
NS_ENSURE_TRUE_VOID(radioInterfaceLayer);
radioInterfaceLayer->GetNumRadioInterfaces(&numOfClients);
// Init MobileConnectionListener array and IccInfoListener
for (uint32_t i = 0; i < numOfClients; i++) {
mMobileConnListeners.AppendElement(new MobileConnectionListener(i));
uint32_t numItems = 0;
if (NS_SUCCEEDED(service->GetNumItems(&numItems))) {
// Init MobileConnectionListener array and IccInfoListener
for (uint32_t i = 0; i < numItems; i++) {
mMobileConnListeners.AppendElement(new MobileConnectionListener(i));
}
}
mTelephonyListener = new TelephonyListener();
@ -375,8 +381,15 @@ BluetoothRilListener::SelectClient()
NS_ENSURE_TRUE_VOID(service);
for (uint32_t i = 0; i < mMobileConnListeners.Length(); i++) {
nsCOMPtr<nsIMobileConnection> connection;
service->GetItemByServiceId(i, getter_AddRefs(connection));
if (!connection) {
BT_WARNING("%s: Failed to get mobile connection", __FUNCTION__);
continue;
}
nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
service->GetVoiceConnectionInfo(i, getter_AddRefs(voiceInfo));
connection->GetVoice(getter_AddRefs(voiceInfo));
if (!voiceInfo) {
BT_WARNING("%s: Failed to get voice connection info", __FUNCTION__);
continue;

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

@ -612,12 +612,16 @@ BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
void
BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
{
nsCOMPtr<nsIMobileConnectionService> connection =
nsCOMPtr<nsIMobileConnectionService> mcService =
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
NS_ENSURE_TRUE_VOID(mcService);
nsCOMPtr<nsIMobileConnection> connection;
mcService->GetItemByServiceId(aClientId, getter_AddRefs(connection));
NS_ENSURE_TRUE_VOID(connection);
nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
connection->GetVoiceConnectionInfo(aClientId, getter_AddRefs(voiceInfo));
connection->GetVoice(getter_AddRefs(voiceInfo));
NS_ENSURE_TRUE_VOID(voiceInfo);
nsString type;

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

@ -606,12 +606,16 @@ BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
void
BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
{
nsCOMPtr<nsIMobileConnectionService> connection =
nsCOMPtr<nsIMobileConnectionService> mcService =
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
NS_ENSURE_TRUE_VOID(mcService);
nsCOMPtr<nsIMobileConnection> connection;
mcService->GetItemByServiceId(aClientId, getter_AddRefs(connection));
NS_ENSURE_TRUE_VOID(connection);
nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
connection->GetVoiceConnectionInfo(aClientId, getter_AddRefs(voiceInfo));
connection->GetVoice(getter_AddRefs(voiceInfo));
NS_ENSURE_TRUE_VOID(voiceInfo);
nsString type;
@ -646,7 +650,7 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
* - manual: set mNetworkSelectionMode to 1 (manual)
*/
nsString mode;
connection->GetNetworkSelectionMode(aClientId, mode);
connection->GetNetworkSelectionMode(mode);
if (mode.EqualsLiteral("manual")) {
mNetworkSelectionMode = 1;
} else {

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

@ -7,9 +7,11 @@
#include "BluetoothRilListener.h"
#include "BluetoothHfpManager.h"
#include "nsIIccProvider.h"
#include "nsIMobileConnectionInfo.h"
#include "nsIRadioInterfaceLayer.h"
#include "nsRadioInterfaceLayer.h"
#include "nsIMobileConnectionService.h"
#include "nsITelephonyService.h"
#include "nsRadioInterfaceLayer.h" // For NS_RILCONTENTHELPER_CONTRACTID.
#include "nsServiceManagerUtils.h"
#include "nsString.h"
@ -179,11 +181,15 @@ MobileConnectionListener::Listen(bool aStart)
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(service, false);
nsCOMPtr<nsIMobileConnection> connection;
mcService->GetItemByServiceId(mClientId, getter_AddRefs(connection));
NS_ENSURE_TRUE(connection, false);
nsresult rv;
if (aStart) {
rv = service->RegisterListener(mClientId, this);
rv = connection->RegisterListener(this);
} else {
rv = service->UnregisterListener(mClientId, this);
rv = connection->UnregisterListener(this);
}
return NS_SUCCEEDED(rv);
@ -329,17 +335,17 @@ TelephonyListener::Listen(bool aStart)
*/
BluetoothRilListener::BluetoothRilListener()
{
nsCOMPtr<nsIMobileConnectionService> service =
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
NS_ENSURE_TRUE_VOID(service);
// Query number of total clients (sim slots)
uint32_t numOfClients;
nsCOMPtr<nsIRadioInterfaceLayer> radioInterfaceLayer =
do_GetService(NS_RADIOINTERFACELAYER_CONTRACTID);
NS_ENSURE_TRUE_VOID(radioInterfaceLayer);
radioInterfaceLayer->GetNumRadioInterfaces(&numOfClients);
// Init MobileConnectionListener array and IccInfoListener
for (uint32_t i = 0; i < numOfClients; i++) {
mMobileConnListeners.AppendElement(new MobileConnectionListener(i));
uint32_t numItems = 0;
if (NS_SUCCEEDED(service->GetNumItems(&numItems))) {
// Init MobileConnectionListener array and IccInfoListener
for (uint32_t i = 0; i < numItems; i++) {
mMobileConnListeners.AppendElement(new MobileConnectionListener(i));
}
}
mTelephonyListener = new TelephonyListener();
@ -375,8 +381,15 @@ BluetoothRilListener::SelectClient()
NS_ENSURE_TRUE_VOID(service);
for (uint32_t i = 0; i < mMobileConnListeners.Length(); i++) {
nsCOMPtr<nsIMobileConnection> connection;
service->GetItemByServiceId(i, getter_AddRefs(connection));
if (!connection) {
BT_WARNING("%s: Failed to get mobile connection", __FUNCTION__);
continue;
}
nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
service->GetVoiceConnectionInfo(i, getter_AddRefs(voiceInfo));
connection->GetVoice(getter_AddRefs(voiceInfo));
if (!voiceInfo) {
BT_WARNING("%s: Failed to get voice connection info", __FUNCTION__);
continue;

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

@ -615,12 +615,16 @@ BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
void
BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
{
nsCOMPtr<nsIMobileConnectionService> connection =
nsCOMPtr<nsIMobileConnectionService> mcService =
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
NS_ENSURE_TRUE_VOID(mcService);
nsCOMPtr<nsIMobileConnection> connection;
mcService->GetItemByServiceId(aClientId, getter_AddRefs(connection));
NS_ENSURE_TRUE_VOID(connection);
nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
connection->GetVoiceConnectionInfo(aClientId, getter_AddRefs(voiceInfo));
connection->GetVoice(getter_AddRefs(voiceInfo));
NS_ENSURE_TRUE_VOID(voiceInfo);
nsString type;

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

@ -606,12 +606,16 @@ BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
void
BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
{
nsCOMPtr<nsIMobileConnectionService> connection =
nsCOMPtr<nsIMobileConnectionService> mcService =
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
NS_ENSURE_TRUE_VOID(mcService);
nsCOMPtr<nsIMobileConnection> connection;
mcService->GetItemByServiceId(aClientId, getter_AddRefs(connection));
NS_ENSURE_TRUE_VOID(connection);
nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
connection->GetVoiceConnectionInfo(aClientId, getter_AddRefs(voiceInfo));
connection->GetVoice(getter_AddRefs(voiceInfo));
NS_ENSURE_TRUE_VOID(voiceInfo);
nsString type;
@ -646,7 +650,7 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
* - manual: set mNetworkSelectionMode to 1 (manual)
*/
nsString mode;
connection->GetNetworkSelectionMode(aClientId, mode);
connection->GetNetworkSelectionMode(mode);
if (mode.EqualsLiteral("manual")) {
mNetworkSelectionMode = 1;
} else {

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

@ -16,7 +16,8 @@ void
WebGL2Context::CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset,
GLintptr writeOffset, GLsizeiptr size)
{
MOZ_CRASH("Not Implemented.");
MakeContextCurrent();
gl->fCopyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size);
}
void

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

@ -3131,7 +3131,7 @@ WebGLContext::CompileShader(WebGLShader *shader)
}
#endif
compiler = ShConstructCompiler((ShShaderType) shader->ShaderType(),
compiler = ShConstructCompiler(shader->ShaderType(),
SH_WEBGL_SPEC,
targetShaderSourceLanguage,
&resources);
@ -3224,7 +3224,7 @@ WebGLContext::CompileShader(WebGLShader *shader)
for (size_t i = 0; i < num_uniforms; i++) {
size_t length;
int size;
ShDataType type;
sh::GLenum type;
ShPrecisionType precision;
int staticUse;
ShGetVariableInfo(compiler, SH_ACTIVE_UNIFORMS, (int)i,
@ -3251,7 +3251,7 @@ WebGLContext::CompileShader(WebGLShader *shader)
for (size_t i = 0; i < num_attributes; i++) {
size_t length;
int size;
ShDataType type;
sh::GLenum type;
ShPrecisionType precision;
int staticUse;
ShGetVariableInfo(compiler, SH_ACTIVE_ATTRIBUTES, (int)i,

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

@ -1443,8 +1443,8 @@ WebGLContext::ValidateUniformLocation(const char* info, WebGLUniformLocation *lo
bool
WebGLContext::ValidateSamplerUniformSetter(const char* info, WebGLUniformLocation *location, GLint value)
{
if (location->Info().type != SH_SAMPLER_2D &&
location->Info().type != SH_SAMPLER_CUBE)
if (location->Info().type != LOCAL_GL_SAMPLER_2D &&
location->Info().type != LOCAL_GL_SAMPLER_CUBE)
{
return true;
}

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

@ -126,8 +126,8 @@ WebGLProgram::UpperBoundNumSamplerUniforms() {
continue;
for (size_t j = 0; j < shader->mUniformInfos.Length(); ++j) {
WebGLUniformInfo u = shader->mUniformInfos[j];
if (u.type == SH_SAMPLER_2D ||
u.type == SH_SAMPLER_CUBE)
if (u.type == LOCAL_GL_SAMPLER_2D ||
u.type == LOCAL_GL_SAMPLER_CUBE)
{
numSamplerUniforms += u.arraySize;
}

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

@ -38,7 +38,7 @@ public:
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
GLuint GLName() { return mGLName; }
GLenum ShaderType() { return mType; }
sh::GLenum ShaderType() { return mType; }
void SetSource(const nsAString& src) {
// XXX do some quick gzip here maybe -- getting this will be very rare
@ -85,7 +85,7 @@ protected:
}
GLuint mGLName;
GLenum mType;
sh::GLenum mType;
nsString mSource;
nsString mTranslatedSource;
nsCString mTranslationLog; // The translation log should contain only ASCII characters

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

@ -6,6 +6,7 @@
#ifndef WEBGLUNIFORMINFO_H_
#define WEBGLUNIFORMINFO_H_
#include "GLDefs.h"
#include "angle/ShaderLang.h"
namespace mozilla {
@ -13,35 +14,35 @@ namespace mozilla {
struct WebGLUniformInfo {
uint32_t arraySize;
bool isArray;
ShDataType type;
sh::GLenum type;
explicit WebGLUniformInfo(uint32_t s = 0, bool a = false, ShDataType t = SH_NONE)
explicit WebGLUniformInfo(uint32_t s = 0, bool a = false, sh::GLenum t = LOCAL_GL_NONE)
: arraySize(s), isArray(a), type(t) {}
int ElementSize() const {
switch (type) {
case SH_INT:
case SH_FLOAT:
case SH_BOOL:
case SH_SAMPLER_2D:
case SH_SAMPLER_CUBE:
case LOCAL_GL_INT:
case LOCAL_GL_FLOAT:
case LOCAL_GL_BOOL:
case LOCAL_GL_SAMPLER_2D:
case LOCAL_GL_SAMPLER_CUBE:
return 1;
case SH_INT_VEC2:
case SH_FLOAT_VEC2:
case SH_BOOL_VEC2:
case LOCAL_GL_INT_VEC2:
case LOCAL_GL_FLOAT_VEC2:
case LOCAL_GL_BOOL_VEC2:
return 2;
case SH_INT_VEC3:
case SH_FLOAT_VEC3:
case SH_BOOL_VEC3:
case LOCAL_GL_INT_VEC3:
case LOCAL_GL_FLOAT_VEC3:
case LOCAL_GL_BOOL_VEC3:
return 3;
case SH_INT_VEC4:
case SH_FLOAT_VEC4:
case SH_BOOL_VEC4:
case SH_FLOAT_MAT2:
case LOCAL_GL_INT_VEC4:
case LOCAL_GL_FLOAT_VEC4:
case LOCAL_GL_BOOL_VEC4:
case LOCAL_GL_FLOAT_MAT2:
return 4;
case SH_FLOAT_MAT3:
case LOCAL_GL_FLOAT_MAT3:
return 9;
case SH_FLOAT_MAT4:
case LOCAL_GL_FLOAT_MAT4:
return 16;
default:
MOZ_ASSERT(false); // should never get here

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

@ -1286,7 +1286,7 @@ public:
mDataIsSet = false;
// Get the current global object from the context
nsIGlobalObject *global = xpc::GetNativeForGlobal(JS::CurrentGlobalOrNull(aCx));
nsIGlobalObject *global = xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
if (!global) {
mEarlyRv = NS_ERROR_DOM_UNKNOWN_ERR;
return;
@ -1955,7 +1955,7 @@ public:
const ObjectOrString& aAlgorithm, bool aExtractable,
const Sequence<nsString>& aKeyUsages)
{
nsIGlobalObject* global = xpc::GetNativeForGlobal(JS::CurrentGlobalOrNull(aCx));
nsIGlobalObject* global = xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
if (!global) {
mEarlyRv = NS_ERROR_DOM_UNKNOWN_ERR;
return;
@ -2082,7 +2082,7 @@ public:
const ObjectOrString& aAlgorithm, bool aExtractable,
const Sequence<nsString>& aKeyUsages)
{
nsIGlobalObject* global = xpc::GetNativeForGlobal(JS::CurrentGlobalOrNull(aCx));
nsIGlobalObject* global = xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
if (!global) {
mEarlyRv = NS_ERROR_DOM_UNKNOWN_ERR;
return;

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

@ -127,6 +127,7 @@
#endif
#include "mozilla/dom/indexedDB/PIndexedDBChild.h"
#include "mozilla/dom/mobileconnection/MobileConnectionChild.h"
#include "mozilla/dom/mobilemessage/SmsChild.h"
#include "mozilla/dom/devicestorage/DeviceStorageRequestChild.h"
#include "mozilla/dom/PFileSystemRequestChild.h"
@ -155,17 +156,13 @@
#include "mozilla/net/NeckoMessageUtils.h"
#include "mozilla/RemoteSpellCheckEngineChild.h"
#ifdef MOZ_B2G_RIL
#include "mozilla/dom/mobileconnection/MobileConnectionChild.h"
using namespace mozilla::dom::mobileconnection;
#endif
using namespace base;
using namespace mozilla;
using namespace mozilla::docshell;
using namespace mozilla::dom::bluetooth;
using namespace mozilla::dom::devicestorage;
using namespace mozilla::dom::ipc;
using namespace mozilla::dom::mobileconnection;
using namespace mozilla::dom::mobilemessage;
using namespace mozilla::dom::indexedDB;
using namespace mozilla::dom::telephony;
@ -202,7 +199,7 @@ public:
NS_DECL_ISUPPORTS
MemoryReportRequestChild(uint32_t aGeneration, bool aAnonymize,
const FileDescriptor& aDMDFile);
const MaybeFileDesc& aDMDFile);
NS_IMETHOD Run();
private:
virtual ~MemoryReportRequestChild();
@ -215,11 +212,13 @@ private:
NS_IMPL_ISUPPORTS(MemoryReportRequestChild, nsIRunnable)
MemoryReportRequestChild::MemoryReportRequestChild(
uint32_t aGeneration, bool aAnonymize, const FileDescriptor& aDMDFile)
: mGeneration(aGeneration), mAnonymize(aAnonymize),
mDMDFile(aDMDFile)
uint32_t aGeneration, bool aAnonymize, const MaybeFileDesc& aDMDFile)
: mGeneration(aGeneration), mAnonymize(aAnonymize)
{
MOZ_COUNT_CTOR(MemoryReportRequestChild);
if (aDMDFile.type() == MaybeFileDesc::TFileDescriptor) {
mDMDFile = aDMDFile.get_FileDescriptor();
}
}
MemoryReportRequestChild::~MemoryReportRequestChild()
@ -707,7 +706,7 @@ PMemoryReportRequestChild*
ContentChild::AllocPMemoryReportRequestChild(const uint32_t& aGeneration,
const bool &aAnonymize,
const bool &aMinimizeMemoryUsage,
const FileDescriptor& aDMDFile)
const MaybeFileDesc& aDMDFile)
{
MemoryReportRequestChild *actor =
new MemoryReportRequestChild(aGeneration, aAnonymize, aDMDFile);
@ -765,7 +764,7 @@ ContentChild::RecvPMemoryReportRequestConstructor(
const uint32_t& aGeneration,
const bool& aAnonymize,
const bool& aMinimizeMemoryUsage,
const FileDescriptor& aDMDFile)
const MaybeFileDesc& aDMDFile)
{
MemoryReportRequestChild *actor =
static_cast<MemoryReportRequestChild*>(aChild);

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

@ -161,7 +161,7 @@ public:
AllocPMemoryReportRequestChild(const uint32_t& aGeneration,
const bool& aAnonymize,
const bool& aMinimizeMemoryUsage,
const FileDescriptor& aDMDFile) MOZ_OVERRIDE;
const MaybeFileDesc& aDMDFile) MOZ_OVERRIDE;
virtual bool
DeallocPMemoryReportRequestChild(PMemoryReportRequestChild* actor) MOZ_OVERRIDE;
@ -170,7 +170,7 @@ public:
const uint32_t& aGeneration,
const bool& aAnonymize,
const bool &aMinimizeMemoryUsage,
const FileDescriptor &aDMDFile) MOZ_OVERRIDE;
const MaybeFileDesc &aDMDFile) MOZ_OVERRIDE;
virtual PCycleCollectWithLogsChild*
AllocPCycleCollectWithLogsChild(const bool& aDumpAllTraces,

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

@ -49,9 +49,10 @@
#include "mozilla/dom/FileSystemRequestParent.h"
#include "mozilla/dom/GeolocationBinding.h"
#include "mozilla/dom/FileDescriptorSetParent.h"
#include "mozilla/dom/mobileconnection/MobileConnectionParent.h"
#include "mozilla/dom/mobilemessage/SmsParent.h"
#include "mozilla/dom/telephony/TelephonyParent.h"
#include "mozilla/dom/time/DateCacheCleaner.h"
#include "SmsParent.h"
#include "mozilla/hal_sandbox/PHalParent.h"
#include "mozilla/ipc/BackgroundChild.h"
#include "mozilla/ipc/BackgroundParent.h"
@ -178,10 +179,6 @@ using namespace mozilla::system;
#include "nsIIPCBackgroundChildCreateCallback.h"
#endif
#ifdef MOZ_B2G_RIL
#include "mozilla/dom/mobileconnection/MobileConnectionParent.h"
using namespace mozilla::dom::mobileconnection;
#endif
#if defined(MOZ_CONTENT_SANDBOX) && defined(XP_LINUX)
#include "mozilla/Sandbox.h"
@ -196,6 +193,7 @@ using namespace mozilla::dom::bluetooth;
using namespace mozilla::dom::devicestorage;
using namespace mozilla::dom::indexedDB;
using namespace mozilla::dom::power;
using namespace mozilla::dom::mobileconnection;
using namespace mozilla::dom::mobilemessage;
using namespace mozilla::dom::telephony;
using namespace mozilla::hal;
@ -341,7 +339,6 @@ namespace mozilla {
namespace dom {
#ifdef MOZ_NUWA_PROCESS
int32_t ContentParent::sNuwaPid = 0;
bool ContentParent::sNuwaReady = false;
#endif
@ -587,7 +584,6 @@ ContentParent::RunNuwaProcess()
/* aIsNuwaProcess = */ true);
nuwaProcess->Init();
#ifdef MOZ_NUWA_PROCESS
sNuwaPid = nuwaProcess->Pid();
sNuwaReady = false;
#endif
return nuwaProcess.forget();
@ -1989,7 +1985,6 @@ ContentParent::~ContentParent()
#ifdef MOZ_NUWA_PROCESS
if (IsNuwaProcess()) {
sNuwaReady = false;
sNuwaPid = 0;
}
#endif
}
@ -2596,7 +2591,7 @@ ContentParent::Observe(nsISupports* aSubject,
// The pre-%n part of the string should be all ASCII, so the byte
// offset in identOffset should be correct as a char offset.
MOZ_ASSERT(cmsg[identOffset - 1] == '=');
FileDescriptor dmdFileDesc;
MaybeFileDesc dmdFileDesc = void_t();
#ifdef MOZ_DMD
nsAutoString dmdIdent(Substring(msg, identOffset));
if (!dmdIdent.IsEmpty()) {
@ -2984,7 +2979,7 @@ PMemoryReportRequestParent*
ContentParent::AllocPMemoryReportRequestParent(const uint32_t& aGeneration,
const bool &aAnonymize,
const bool &aMinimizeMemoryUsage,
const FileDescriptor &aDMDFile)
const MaybeFileDesc &aDMDFile)
{
MemoryReportRequestParent* parent = new MemoryReportRequestParent();
return parent;
@ -3681,12 +3676,6 @@ ContentParent::DoSendAsyncMessage(JSContext* aCx,
if (aCpows && !GetCPOWManager()->Wrap(aCx, aCpows, &cpows)) {
return false;
}
#ifdef MOZ_NUWA_PROCESS
if (IsNuwaProcess() && IsNuwaReady()) {
// Nuwa won't receive frame messages after it is frozen.
return true;
}
#endif
return SendAsyncMessage(nsString(aMessage), data, cpows, Principal(aPrincipal));
}

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

@ -79,10 +79,6 @@ class ContentParent MOZ_FINAL : public PContentParent
public:
#ifdef MOZ_NUWA_PROCESS
static int32_t NuwaPid() {
return sNuwaPid;
}
static bool IsNuwaReady() {
return sNuwaReady;
}
@ -455,7 +451,7 @@ private:
AllocPMemoryReportRequestParent(const uint32_t& aGeneration,
const bool &aAnonymize,
const bool &aMinimizeMemoryUsage,
const FileDescriptor &aDMDFile) MOZ_OVERRIDE;
const MaybeFileDesc &aDMDFile) MOZ_OVERRIDE;
virtual bool DeallocPMemoryReportRequestParent(PMemoryReportRequestParent* actor) MOZ_OVERRIDE;
virtual PCycleCollectWithLogsParent*
@ -716,7 +712,6 @@ private:
#endif
#ifdef MOZ_NUWA_PROCESS
static int32_t sNuwaPid;
static bool sNuwaReady;
#endif
};

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

@ -303,6 +303,11 @@ struct VolumeInfo {
bool isFake;
};
union MaybeFileDesc {
FileDescriptor;
void_t;
};
intr protocol PContent
{
parent opens PCompositor;
@ -377,7 +382,7 @@ child:
async SetProcessSandbox();
PMemoryReportRequest(uint32_t generation, bool anonymize,
bool minimizeMemoryUsage, FileDescriptor DMDFile);
bool minimizeMemoryUsage, MaybeFileDesc DMDFile);
/**
* Notify the AudioChannelService in the child processes.

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

@ -1893,10 +1893,34 @@ MediaManager::GetBackend(uint64_t aWindowId)
return mBackend;
}
static void
StopSharingCallback(MediaManager *aThis,
uint64_t aWindowID,
StreamListeners *aListeners,
void *aData)
{
if (aListeners) {
auto length = aListeners->Length();
for (size_t i = 0; i < length; ++i) {
GetUserMediaCallbackMediaStreamListener *listener = aListeners->ElementAt(i);
if (listener->Stream()) { // aka HasBeenActivate()ed
listener->Invalidate();
}
listener->Remove();
listener->StopScreenWindowSharing();
}
aListeners->Clear();
aThis->RemoveWindowID(aWindowID);
}
}
void
MediaManager::OnNavigation(uint64_t aWindowID)
{
NS_ASSERTION(NS_IsMainThread(), "OnNavigation called off main thread");
LOG(("OnNavigation for %llu", aWindowID));
// Invalidate this window. The runnables check this value before making
// a call to content.
@ -1911,24 +1935,13 @@ MediaManager::OnNavigation(uint64_t aWindowID)
// This is safe since we're on main-thread, and the windowlist can only
// be added to from the main-thread
StreamListeners* listeners = GetWindowListeners(aWindowID);
if (!listeners) {
return;
nsPIDOMWindow *window = static_cast<nsPIDOMWindow*>
(nsGlobalWindow::GetInnerWindowWithId(aWindowID));
if (window) {
IterateWindowListeners(window, StopSharingCallback, nullptr);
} else {
RemoveWindowID(aWindowID);
}
uint32_t length = listeners->Length();
for (uint32_t i = 0; i < length; i++) {
nsRefPtr<GetUserMediaCallbackMediaStreamListener> listener =
listeners->ElementAt(i);
if (listener->Stream()) { // aka HasBeenActivate()ed
listener->Invalidate();
}
listener->Remove();
}
listeners->Clear();
RemoveWindowID(aWindowID);
// listeners has been deleted
}
void
@ -2213,92 +2226,93 @@ MediaManager::GetActiveMediaCaptureWindows(nsISupportsArray **aArray)
return NS_OK;
}
// XXX flags might be better...
struct CaptureWindowStateData {
bool *mVideo;
bool *mAudio;
bool *mScreenShare;
bool *mWindowShare;
bool *mAppShare;
};
static void
CaptureWindowStateCallback(MediaManager *aThis,
uint64_t aWindowID,
StreamListeners *aListeners,
void *aData)
{
struct CaptureWindowStateData *data = (struct CaptureWindowStateData *) aData;
if (aListeners) {
auto length = aListeners->Length();
for (size_t i = 0; i < length; ++i) {
GetUserMediaCallbackMediaStreamListener *listener = aListeners->ElementAt(i);
if (listener->CapturingVideo()) {
*data->mVideo = true;
}
if (listener->CapturingAudio()) {
*data->mAudio = true;
}
if (listener->CapturingScreen()) {
*data->mScreenShare = true;
}
if (listener->CapturingWindow()) {
*data->mWindowShare = true;
}
if (listener->CapturingApplication()) {
*data->mAppShare = true;
}
}
}
}
NS_IMETHODIMP
MediaManager::MediaCaptureWindowState(nsIDOMWindow* aWindow, bool* aVideo,
bool* aAudio, bool *aScreenShare,
bool* aWindowShare, bool *aAppShare)
{
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
struct CaptureWindowStateData data;
data.mVideo = aVideo;
data.mAudio = aAudio;
data.mScreenShare = aScreenShare;
data.mWindowShare = aWindowShare;
data.mAppShare = aAppShare;
*aVideo = false;
*aAudio = false;
*aScreenShare = false;
*aWindowShare = false;
*aAppShare = false;
nsresult rv = MediaCaptureWindowStateInternal(aWindow, aVideo, aAudio, aScreenShare, aWindowShare, aAppShare);
#ifdef DEBUG
nsCOMPtr<nsPIDOMWindow> piWin = do_QueryInterface(aWindow);
if (piWin) {
IterateWindowListeners(piWin, CaptureWindowStateCallback, &data);
}
#ifdef DEBUG
LOG(("%s: window %lld capturing %s %s %s %s %s", __FUNCTION__, piWin ? piWin->WindowID() : -1,
*aVideo ? "video" : "", *aAudio ? "audio" : "",
*aScreenShare ? "screenshare" : "", *aWindowShare ? "windowshare" : "",
*aAppShare ? "appshare" : ""));
#endif
return rv;
}
nsresult
MediaManager::MediaCaptureWindowStateInternal(nsIDOMWindow* aWindow, bool* aVideo,
bool* aAudio, bool *aScreenShare,
bool* aWindowShare, bool *aAppShare)
{
// We need to return the union of all streams in all innerwindows that
// correspond to that outerwindow.
// Iterate the docshell tree to find all the child windows, find
// all the listeners for each one, get the booleans, and merge the
// results.
nsCOMPtr<nsPIDOMWindow> piWin = do_QueryInterface(aWindow);
if (piWin) {
if (piWin->IsInnerWindow() || piWin->GetCurrentInnerWindow()) {
uint64_t windowID;
if (piWin->IsInnerWindow()) {
windowID = piWin->WindowID();
} else {
windowID = piWin->GetCurrentInnerWindow()->WindowID();
}
StreamListeners* listeners = GetActiveWindows()->Get(windowID);
if (listeners) {
uint32_t length = listeners->Length();
for (uint32_t i = 0; i < length; ++i) {
nsRefPtr<GetUserMediaCallbackMediaStreamListener> listener =
listeners->ElementAt(i);
if (listener->CapturingVideo()) {
*aVideo = true;
}
if (listener->CapturingAudio()) {
*aAudio = true;
}
if (listener->CapturingScreen()) {
*aScreenShare = true;
}
if (listener->CapturingWindow()) {
*aWindowShare = true;
}
if (listener->CapturingApplication()) {
*aAppShare = true;
}
}
}
}
// iterate any children of *this* window (iframes, etc)
nsCOMPtr<nsIDocShell> docShell = piWin->GetDocShell();
if (docShell) {
int32_t i, count;
docShell->GetChildCount(&count);
for (i = 0; i < count; ++i) {
nsCOMPtr<nsIDocShellTreeItem> item;
docShell->GetChildAt(i, getter_AddRefs(item));
nsCOMPtr<nsPIDOMWindow> win = item ? item->GetWindow() : nullptr;
MediaCaptureWindowStateInternal(win, aVideo, aAudio, aScreenShare, aWindowShare, aAppShare);
}
}
}
return NS_OK;
}
// XXX abstract out the iteration over all children and provide a function pointer and data ptr
static void
StopScreensharingCallback(MediaManager *aThis,
uint64_t aWindowID,
StreamListeners *aListeners,
void *aData)
{
if (aListeners) {
auto length = aListeners->Length();
for (size_t i = 0; i < length; ++i) {
aListeners->ElementAt(i)->StopScreenWindowSharing();
}
}
}
void
MediaManager::StopScreensharing(uint64_t aWindowID)
@ -2311,18 +2325,17 @@ MediaManager::StopScreensharing(uint64_t aWindowID)
if (!window) {
return;
}
StopScreensharing(window);
IterateWindowListeners(window, &StopScreensharingCallback, nullptr);
}
// lets us do all sorts of things to the listeners
void
MediaManager::StopScreensharing(nsPIDOMWindow *aWindow)
MediaManager::IterateWindowListeners(nsPIDOMWindow *aWindow,
WindowListenerCallback aCallback,
void *aData)
{
// We need to stop window/screensharing for all streams in all innerwindows that
// correspond to that outerwindow.
// Iterate the docshell tree to find all the child windows, find
// all the listeners for each one, and tell them to stop
// window/screensharing
// Iterate the docshell tree to find all the child windows, and for each
// invoke the callback
nsCOMPtr<nsPIDOMWindow> piWin = do_QueryInterface(aWindow);
if (piWin) {
if (piWin->IsInnerWindow() || piWin->GetCurrentInnerWindow()) {
@ -2333,12 +2346,8 @@ MediaManager::StopScreensharing(nsPIDOMWindow *aWindow)
windowID = piWin->GetCurrentInnerWindow()->WindowID();
}
StreamListeners* listeners = GetActiveWindows()->Get(windowID);
if (listeners) {
uint32_t length = listeners->Length();
for (uint32_t i = 0; i < length; ++i) {
listeners->ElementAt(i)->StopScreenWindowSharing();
}
}
// pass listeners so it can modify/delete the list
(*aCallback)(this, windowID, listeners, aData);
}
// iterate any children of *this* window (iframes, etc)
@ -2352,13 +2361,14 @@ MediaManager::StopScreensharing(nsPIDOMWindow *aWindow)
nsCOMPtr<nsPIDOMWindow> win = item ? item->GetWindow() : nullptr;
if (win) {
StopScreensharing(win);
IterateWindowListeners(win, aCallback, aData);
}
}
}
}
}
void
MediaManager::StopMediaStreams()
{

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

@ -528,6 +528,12 @@ public:
MediaEngineAudioSource* GetSource();
};
// we could add MediaManager if needed
typedef void (*WindowListenerCallback)(MediaManager *aThis,
uint64_t aWindowID,
StreamListeners *aListeners,
void *aData);
class MediaManager MOZ_FINAL : public nsIMediaManagerService,
public nsIObserver
{
@ -600,12 +606,10 @@ private:
~MediaManager() {}
nsresult MediaCaptureWindowStateInternal(nsIDOMWindow* aWindow, bool* aVideo,
bool* aAudio, bool *aScreenShare,
bool* aWindowShare, bool *aAppShare);
void StopScreensharing(uint64_t aWindowID);
void StopScreensharing(nsPIDOMWindow *aWindow);
void IterateWindowListeners(nsPIDOMWindow *aWindow,
WindowListenerCallback aCallback,
void *aData);
void StopMediaStreams();

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

@ -557,9 +557,10 @@ RTCPeerConnection.prototype = {
createOffer: function(onSuccess, onError, options) {
// TODO: Remove old constraint-like RTCOptions support soon (Bug 1064223).
// Note that webidl bindings make o.mandatory implicit but not o.optional.
function convertLegacyOptions(o) {
if (!(o.mandatory || o.optional) ||
Object.keys(o).length != ((o.mandatory && o.optional)? 2 : 1)) {
if (!(Object.keys(o.mandatory).length || o.optional) ||
Object.keys(o).length != (o.optional? 2 : 1)) {
return false;
}
let old = o.mandatory || {};

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

@ -4,7 +4,7 @@
* 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/. */
#include "DOMMMIError.h"
#include "mozilla/dom/DOMMMIError.h"
#include "mozilla/dom/DOMMMIErrorBinding.h"
using namespace mozilla::dom;

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

@ -4,7 +4,7 @@
* 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/. */
#include "MobileCellInfo.h"
#include "mozilla/dom/MobileCellInfo.h"
#include "mozilla/dom/MozMobileCellInfoBinding.h"
using namespace mozilla::dom;

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

@ -2,7 +2,7 @@
* 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/. */
#include "MobileConnection.h"
#include "mozilla/dom/MobileConnection.h"
#include "MobileConnectionCallback.h"
#include "mozilla/dom/CFStateChangeEvent.h"
@ -42,6 +42,7 @@
using mozilla::ErrorResult;
using namespace mozilla::dom;
using namespace mozilla::dom::mobileconnection;
class MobileConnection::Listener MOZ_FINAL : public nsIMobileConnectionListener
{
@ -77,8 +78,9 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(MobileConnection)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MobileConnection,
DOMEventTargetHelper)
// Don't traverse mListener because it doesn't keep any reference to
// MobileConnection but a raw pointer instead. Neither does mService because
// it's an xpcom service and is only released at shutting down.
// MobileConnection but a raw pointer instead. Neither does mMobileConnection
// because it's an xpcom service owned object and is only released at shutting
// down.
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVoice)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mData)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
@ -101,25 +103,32 @@ NS_IMPL_RELEASE_INHERITED(MobileConnection, DOMEventTargetHelper)
MobileConnection::MobileConnection(nsPIDOMWindow* aWindow, uint32_t aClientId)
: DOMEventTargetHelper(aWindow)
, mClientId(aClientId)
{
SetIsDOMBinding();
mService = do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
nsCOMPtr<nsIMobileConnectionService> service =
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
// Not being able to acquire the service isn't fatal since we check
// for it explicitly below.
if (!mService) {
if (!service) {
NS_WARNING("Could not acquire nsIMobileConnectionService!");
return;
}
nsresult rv = service->GetItemByServiceId(aClientId,
getter_AddRefs(mMobileConnection));
if (NS_FAILED(rv) || !mMobileConnection) {
NS_WARNING("Could not acquire nsIMobileConnection!");
return;
}
mListener = new Listener(this);
mVoice = new MobileConnectionInfo(GetOwner());
mData = new MobileConnectionInfo(GetOwner());
if (CheckPermission("mobileconnection")) {
DebugOnly<nsresult> rv = mService->RegisterListener(mClientId, mListener);
DebugOnly<nsresult> rv = mMobileConnection->RegisterListener(mListener);
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"Failed registering mobile connection messages with service");
UpdateVoice();
@ -131,8 +140,8 @@ void
MobileConnection::Shutdown()
{
if (mListener) {
if (mService) {
mService->UnregisterListener(mClientId, mListener);
if (mMobileConnection) {
mMobileConnection->UnregisterListener(mListener);
}
mListener->Disconnect();
@ -175,24 +184,24 @@ MobileConnection::CheckPermission(const char* aType) const
void
MobileConnection::UpdateVoice()
{
if (!mService) {
if (!mMobileConnection) {
return;
}
nsCOMPtr<nsIMobileConnectionInfo> info;
mService->GetVoiceConnectionInfo(mClientId, getter_AddRefs(info));
mMobileConnection->GetVoice(getter_AddRefs(info));
mVoice->Update(info);
}
void
MobileConnection::UpdateData()
{
if (!mService) {
if (!mMobileConnection) {
return;
}
nsCOMPtr<nsIMobileConnectionInfo> info;
mService->GetDataConnectionInfo(mClientId, getter_AddRefs(info));
mMobileConnection->GetData(getter_AddRefs(info));
mData->Update(info);
}
@ -203,11 +212,11 @@ MobileConnection::GetLastKnownNetwork(nsString& aRetVal) const
{
aRetVal.SetIsVoid(true);
if (!mService) {
if (!mMobileConnection) {
return;
}
mService->GetLastKnownNetwork(mClientId, aRetVal);
mMobileConnection->GetLastKnownNetwork(aRetVal);
}
void
@ -215,11 +224,11 @@ MobileConnection::GetLastKnownHomeNetwork(nsString& aRetVal) const
{
aRetVal.SetIsVoid(true);
if (!mService) {
if (!mMobileConnection) {
return;
}
mService->GetLastKnownHomeNetwork(mClientId, aRetVal);
mMobileConnection->GetLastKnownHomeNetwork(aRetVal);
}
// All fields below require the "mobileconnection" permission.
@ -241,11 +250,11 @@ MobileConnection::GetIccId(nsString& aRetVal) const
{
aRetVal.SetIsVoid(true);
if (!mService) {
if (!mMobileConnection) {
return;
}
mService->GetIccId(mClientId, aRetVal);
mMobileConnection->GetIccId(aRetVal);
}
Nullable<MobileNetworkSelectionMode>
@ -254,12 +263,12 @@ MobileConnection::GetNetworkSelectionMode() const
Nullable<MobileNetworkSelectionMode> retVal =
Nullable<MobileNetworkSelectionMode>();
if (!mService) {
if (!mMobileConnection) {
return retVal;
}
nsAutoString mode;
mService->GetNetworkSelectionMode(mClientId, mode);
mMobileConnection->GetNetworkSelectionMode(mode);
CONVERT_STRING_TO_NULLABLE_ENUM(mode, MobileNetworkSelectionMode, retVal);
return retVal;
@ -270,12 +279,12 @@ MobileConnection::GetRadioState() const
{
Nullable<MobileRadioState> retVal = Nullable<MobileRadioState>();
if (!mService) {
if (!mMobileConnection) {
return retVal;
}
nsAutoString state;
mService->GetRadioState(mClientId, state);
mMobileConnection->GetRadioState(state);
CONVERT_STRING_TO_NULLABLE_ENUM(state, MobileRadioState, retVal);
return retVal;
@ -284,45 +293,33 @@ MobileConnection::GetRadioState() const
void
MobileConnection::GetSupportedNetworkTypes(nsTArray<MobileNetworkType>& aTypes) const
{
if (!mService) {
if (!mMobileConnection) {
return;
}
nsCOMPtr<nsIVariant> variant;
mService->GetSupportedNetworkTypes(mClientId,
getter_AddRefs(variant));
char16_t** types = nullptr;
uint32_t length = 0;
uint16_t type;
nsIID iid;
uint32_t count;
void* data;
nsresult rv = mMobileConnection->GetSupportedNetworkTypes(&types, &length);
NS_ENSURE_SUCCESS_VOID(rv);
// Convert the nsIVariant to an array. We own the resulting buffer and its
// elements.
if (NS_FAILED(variant->GetAsArray(&type, &iid, &count, &data))) {
return;
}
for (uint32_t i = 0; i < length; ++i) {
nsDependentString rawType(types[i]);
Nullable<MobileNetworkType> type = Nullable<MobileNetworkType>();
CONVERT_STRING_TO_NULLABLE_ENUM(rawType, MobileNetworkType, type);
// We expect the element type is wstring.
if (type == nsIDataType::VTYPE_WCHAR_STR) {
char16_t** rawArray = reinterpret_cast<char16_t**>(data);
for (uint32_t i = 0; i < count; ++i) {
nsDependentString rawType(rawArray[i]);
Nullable<MobileNetworkType> type = Nullable<MobileNetworkType>();
CONVERT_STRING_TO_NULLABLE_ENUM(rawType, MobileNetworkType, type);
if (!type.IsNull()) {
aTypes.AppendElement(type.Value());
}
if (!type.IsNull()) {
aTypes.AppendElement(type.Value());
}
}
NS_Free(data);
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(length, types);
}
already_AddRefed<DOMRequest>
MobileConnection::GetNetworks(ErrorResult& aRv)
{
if (!mService) {
if (!mMobileConnection) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -331,7 +328,7 @@ MobileConnection::GetNetworks(ErrorResult& aRv)
nsRefPtr<MobileConnectionCallback> requestCallback =
new MobileConnectionCallback(GetOwner(), request);
nsresult rv = mService->GetNetworks(mClientId, requestCallback);
nsresult rv = mMobileConnection->GetNetworks(requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
@ -343,7 +340,7 @@ MobileConnection::GetNetworks(ErrorResult& aRv)
already_AddRefed<DOMRequest>
MobileConnection::SelectNetwork(MobileNetworkInfo& aNetwork, ErrorResult& aRv)
{
if (!mService) {
if (!mMobileConnection) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -352,7 +349,7 @@ MobileConnection::SelectNetwork(MobileNetworkInfo& aNetwork, ErrorResult& aRv)
nsRefPtr<MobileConnectionCallback> requestCallback =
new MobileConnectionCallback(GetOwner(), request);
nsresult rv = mService->SelectNetwork(mClientId, &aNetwork, requestCallback);
nsresult rv = mMobileConnection->SelectNetwork(&aNetwork, requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
@ -364,7 +361,7 @@ MobileConnection::SelectNetwork(MobileNetworkInfo& aNetwork, ErrorResult& aRv)
already_AddRefed<DOMRequest>
MobileConnection::SelectNetworkAutomatically(ErrorResult& aRv)
{
if (!mService) {
if (!mMobileConnection) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -373,8 +370,8 @@ MobileConnection::SelectNetworkAutomatically(ErrorResult& aRv)
nsRefPtr<MobileConnectionCallback> requestCallback =
new MobileConnectionCallback(GetOwner(), request);
nsresult rv = mService->SelectNetworkAutomatically(mClientId,
requestCallback);
nsresult rv =
mMobileConnection->SelectNetworkAutomatically(requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
@ -387,7 +384,7 @@ already_AddRefed<DOMRequest>
MobileConnection::SetPreferredNetworkType(MobilePreferredNetworkType& aType,
ErrorResult& aRv)
{
if (!mService) {
if (!mMobileConnection) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -399,8 +396,8 @@ MobileConnection::SetPreferredNetworkType(MobilePreferredNetworkType& aType,
nsRefPtr<MobileConnectionCallback> requestCallback =
new MobileConnectionCallback(GetOwner(), request);
nsresult rv = mService->SetPreferredNetworkType(mClientId, type,
requestCallback);
nsresult rv =
mMobileConnection->SetPreferredNetworkType(type, requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
@ -412,7 +409,7 @@ MobileConnection::SetPreferredNetworkType(MobilePreferredNetworkType& aType,
already_AddRefed<DOMRequest>
MobileConnection::GetPreferredNetworkType(ErrorResult& aRv)
{
if (!mService) {
if (!mMobileConnection) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -421,7 +418,7 @@ MobileConnection::GetPreferredNetworkType(ErrorResult& aRv)
nsRefPtr<MobileConnectionCallback> requestCallback =
new MobileConnectionCallback(GetOwner(), request);
nsresult rv = mService->GetPreferredNetworkType(mClientId, requestCallback);
nsresult rv = mMobileConnection->GetPreferredNetworkType(requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
@ -434,7 +431,7 @@ already_AddRefed<DOMRequest>
MobileConnection::SetRoamingPreference(MobileRoamingMode& aMode,
ErrorResult& aRv)
{
if (!mService) {
if (!mMobileConnection) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -446,7 +443,7 @@ MobileConnection::SetRoamingPreference(MobileRoamingMode& aMode,
nsRefPtr<MobileConnectionCallback> requestCallback =
new MobileConnectionCallback(GetOwner(), request);
nsresult rv = mService->SetRoamingPreference(mClientId, mode, requestCallback);
nsresult rv = mMobileConnection->SetRoamingPreference(mode, requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
@ -458,7 +455,7 @@ MobileConnection::SetRoamingPreference(MobileRoamingMode& aMode,
already_AddRefed<DOMRequest>
MobileConnection::GetRoamingPreference(ErrorResult& aRv)
{
if (!mService) {
if (!mMobileConnection) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -467,7 +464,7 @@ MobileConnection::GetRoamingPreference(ErrorResult& aRv)
nsRefPtr<MobileConnectionCallback> requestCallback =
new MobileConnectionCallback(GetOwner(), request);
nsresult rv = mService->GetRoamingPreference(mClientId, requestCallback);
nsresult rv = mMobileConnection->GetRoamingPreference(requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
@ -479,7 +476,7 @@ MobileConnection::GetRoamingPreference(ErrorResult& aRv)
already_AddRefed<DOMRequest>
MobileConnection::SetVoicePrivacyMode(bool aEnabled, ErrorResult& aRv)
{
if (!mService) {
if (!mMobileConnection) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -488,8 +485,8 @@ MobileConnection::SetVoicePrivacyMode(bool aEnabled, ErrorResult& aRv)
nsRefPtr<MobileConnectionCallback> requestCallback =
new MobileConnectionCallback(GetOwner(), request);
nsresult rv = mService->SetVoicePrivacyMode(mClientId, aEnabled,
requestCallback);
nsresult rv =
mMobileConnection->SetVoicePrivacyMode(aEnabled, requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
@ -501,7 +498,7 @@ MobileConnection::SetVoicePrivacyMode(bool aEnabled, ErrorResult& aRv)
already_AddRefed<DOMRequest>
MobileConnection::GetVoicePrivacyMode(ErrorResult& aRv)
{
if (!mService) {
if (!mMobileConnection) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -510,7 +507,7 @@ MobileConnection::GetVoicePrivacyMode(ErrorResult& aRv)
nsRefPtr<MobileConnectionCallback> requestCallback =
new MobileConnectionCallback(GetOwner(), request);
nsresult rv = mService->GetVoicePrivacyMode(mClientId, requestCallback);
nsresult rv = mMobileConnection->GetVoicePrivacyMode(requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
@ -522,7 +519,7 @@ MobileConnection::GetVoicePrivacyMode(ErrorResult& aRv)
already_AddRefed<DOMRequest>
MobileConnection::SendMMI(const nsAString& aMMIString, ErrorResult& aRv)
{
if (!mService) {
if (!mMobileConnection) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -531,7 +528,7 @@ MobileConnection::SendMMI(const nsAString& aMMIString, ErrorResult& aRv)
nsRefPtr<MobileConnectionCallback> requestCallback =
new MobileConnectionCallback(GetOwner(), request);
nsresult rv = mService->SendMMI(mClientId, aMMIString, requestCallback);
nsresult rv = mMobileConnection->SendMMI(aMMIString, requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
@ -543,7 +540,7 @@ MobileConnection::SendMMI(const nsAString& aMMIString, ErrorResult& aRv)
already_AddRefed<DOMRequest>
MobileConnection::CancelMMI(ErrorResult& aRv)
{
if (!mService) {
if (!mMobileConnection) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -552,7 +549,7 @@ MobileConnection::CancelMMI(ErrorResult& aRv)
nsRefPtr<MobileConnectionCallback> requestCallback =
new MobileConnectionCallback(GetOwner(), request);
nsresult rv = mService->CancelMMI(mClientId, requestCallback);
nsresult rv = mMobileConnection->CancelMMI(requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
@ -564,7 +561,7 @@ MobileConnection::CancelMMI(ErrorResult& aRv)
already_AddRefed<DOMRequest>
MobileConnection::GetCallForwardingOption(uint16_t aReason, ErrorResult& aRv)
{
if (!mService) {
if (!mMobileConnection) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -573,7 +570,7 @@ MobileConnection::GetCallForwardingOption(uint16_t aReason, ErrorResult& aRv)
nsRefPtr<MobileConnectionCallback> requestCallback =
new MobileConnectionCallback(GetOwner(), request);
nsresult rv = mService->GetCallForwarding(mClientId, aReason, requestCallback);
nsresult rv = mMobileConnection->GetCallForwarding(aReason, requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
@ -586,7 +583,7 @@ already_AddRefed<DOMRequest>
MobileConnection::SetCallForwardingOption(const MozCallForwardingOptions& aOptions,
ErrorResult& aRv)
{
if (!mService) {
if (!mMobileConnection) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -608,7 +605,7 @@ MobileConnection::SetCallForwardingOption(const MozCallForwardingOptions& aOptio
nsRefPtr<MobileConnectionCallback> requestCallback =
new MobileConnectionCallback(GetOwner(), request);
nsresult rv = mService->SetCallForwarding(mClientId, options, requestCallback);
nsresult rv = mMobileConnection->SetCallForwarding(options, requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
@ -621,7 +618,7 @@ already_AddRefed<DOMRequest>
MobileConnection::GetCallBarringOption(const MozCallBarringOptions& aOptions,
ErrorResult& aRv)
{
if (!mService) {
if (!mMobileConnection) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -643,7 +640,7 @@ MobileConnection::GetCallBarringOption(const MozCallBarringOptions& aOptions,
nsRefPtr<MobileConnectionCallback> requestCallback =
new MobileConnectionCallback(GetOwner(), request);
nsresult rv = mService->GetCallBarring(mClientId, options, requestCallback);
nsresult rv = mMobileConnection->GetCallBarring(options, requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
@ -656,7 +653,7 @@ already_AddRefed<DOMRequest>
MobileConnection::SetCallBarringOption(const MozCallBarringOptions& aOptions,
ErrorResult& aRv)
{
if (!mService) {
if (!mMobileConnection) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -678,7 +675,7 @@ MobileConnection::SetCallBarringOption(const MozCallBarringOptions& aOptions,
nsRefPtr<MobileConnectionCallback> requestCallback =
new MobileConnectionCallback(GetOwner(), request);
nsresult rv = mService->SetCallBarring(mClientId, options, requestCallback);
nsresult rv = mMobileConnection->SetCallBarring(options, requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
@ -691,7 +688,7 @@ already_AddRefed<DOMRequest>
MobileConnection::ChangeCallBarringPassword(const MozCallBarringOptions& aOptions,
ErrorResult& aRv)
{
if (!mService) {
if (!mMobileConnection) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -713,8 +710,8 @@ MobileConnection::ChangeCallBarringPassword(const MozCallBarringOptions& aOption
nsRefPtr<MobileConnectionCallback> requestCallback =
new MobileConnectionCallback(GetOwner(), request);
nsresult rv = mService->ChangeCallBarringPassword(mClientId, options,
requestCallback);
nsresult rv =
mMobileConnection->ChangeCallBarringPassword(options, requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
@ -726,7 +723,7 @@ MobileConnection::ChangeCallBarringPassword(const MozCallBarringOptions& aOption
already_AddRefed<DOMRequest>
MobileConnection::GetCallWaitingOption(ErrorResult& aRv)
{
if (!mService) {
if (!mMobileConnection) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -735,7 +732,7 @@ MobileConnection::GetCallWaitingOption(ErrorResult& aRv)
nsRefPtr<MobileConnectionCallback> requestCallback =
new MobileConnectionCallback(GetOwner(), request);
nsresult rv = mService->GetCallWaiting(mClientId, requestCallback);
nsresult rv = mMobileConnection->GetCallWaiting(requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
@ -747,7 +744,7 @@ MobileConnection::GetCallWaitingOption(ErrorResult& aRv)
already_AddRefed<DOMRequest>
MobileConnection::SetCallWaitingOption(bool aEnabled, ErrorResult& aRv)
{
if (!mService) {
if (!mMobileConnection) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -756,7 +753,7 @@ MobileConnection::SetCallWaitingOption(bool aEnabled, ErrorResult& aRv)
nsRefPtr<MobileConnectionCallback> requestCallback =
new MobileConnectionCallback(GetOwner(), request);
nsresult rv = mService->SetCallWaiting(mClientId, aEnabled, requestCallback);
nsresult rv = mMobileConnection->SetCallWaiting(aEnabled, requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
@ -768,7 +765,7 @@ MobileConnection::SetCallWaitingOption(bool aEnabled, ErrorResult& aRv)
already_AddRefed<DOMRequest>
MobileConnection::GetCallingLineIdRestriction(ErrorResult& aRv)
{
if (!mService) {
if (!mMobileConnection) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -777,8 +774,8 @@ MobileConnection::GetCallingLineIdRestriction(ErrorResult& aRv)
nsRefPtr<MobileConnectionCallback> requestCallback =
new MobileConnectionCallback(GetOwner(), request);
nsresult rv = mService->GetCallingLineIdRestriction(mClientId,
requestCallback);
nsresult rv =
mMobileConnection->GetCallingLineIdRestriction(requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
@ -791,7 +788,7 @@ already_AddRefed<DOMRequest>
MobileConnection::SetCallingLineIdRestriction(uint16_t aMode,
ErrorResult& aRv)
{
if (!mService) {
if (!mMobileConnection) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -800,8 +797,8 @@ MobileConnection::SetCallingLineIdRestriction(uint16_t aMode,
nsRefPtr<MobileConnectionCallback> requestCallback =
new MobileConnectionCallback(GetOwner(), request);
nsresult rv = mService->SetCallingLineIdRestriction(mClientId, aMode,
requestCallback);
nsresult rv =
mMobileConnection->SetCallingLineIdRestriction(aMode, requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
@ -813,7 +810,7 @@ MobileConnection::SetCallingLineIdRestriction(uint16_t aMode,
already_AddRefed<DOMRequest>
MobileConnection::ExitEmergencyCbMode(ErrorResult& aRv)
{
if (!mService) {
if (!mMobileConnection) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -822,7 +819,7 @@ MobileConnection::ExitEmergencyCbMode(ErrorResult& aRv)
nsRefPtr<MobileConnectionCallback> requestCallback =
new MobileConnectionCallback(GetOwner(), request);
nsresult rv = mService->ExitEmergencyCbMode(mClientId, requestCallback);
nsresult rv = mMobileConnection->ExitEmergencyCbMode(requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
@ -834,7 +831,7 @@ MobileConnection::ExitEmergencyCbMode(ErrorResult& aRv)
already_AddRefed<DOMRequest>
MobileConnection::SetRadioEnabled(bool aEnabled, ErrorResult& aRv)
{
if (!mService) {
if (!mMobileConnection) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
@ -843,7 +840,7 @@ MobileConnection::SetRadioEnabled(bool aEnabled, ErrorResult& aRv)
nsRefPtr<MobileConnectionCallback> requestCallback =
new MobileConnectionCallback(GetOwner(), request);
nsresult rv = mService->SetRadioEnabled(mClientId, aEnabled, requestCallback);
nsresult rv = mMobileConnection->SetRadioEnabled(aEnabled, requestCallback);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;

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

@ -5,10 +5,10 @@
#ifndef mozilla_dom_MobileConnection_h
#define mozilla_dom_MobileConnection_h
#include "MobileConnectionInfo.h"
#include "MobileNetworkInfo.h"
#include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/dom/DOMRequest.h"
#include "mozilla/dom/MobileConnectionInfo.h"
#include "mozilla/dom/MobileNetworkInfo.h"
#include "mozilla/dom/MozMobileConnectionBinding.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIMobileConnectionService.h"
@ -163,8 +163,7 @@ private:
~MobileConnection();
private:
uint32_t mClientId;
nsCOMPtr<nsIMobileConnectionService> mService;
nsCOMPtr<nsIMobileConnection> mMobileConnection;
nsRefPtr<Listener> mListener;
nsRefPtr<MobileConnectionInfo> mVoice;
nsRefPtr<MobileConnectionInfo> mData;

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

@ -4,9 +4,17 @@
* 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/. */
#include "MobileConnectionArray.h"
#include "mozilla/dom/MobileConnectionArray.h"
#include "mozilla/dom/MozMobileConnectionArrayBinding.h"
#include "mozilla/Preferences.h"
#include "nsServiceManagerUtils.h"
// Service instantiation
#include "ipc/MobileConnectionIPCService.h"
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
#include "nsIGonkMobileConnectionService.h"
#endif
#include "nsXULAppAPI.h" // For XRE_GetProcessType()
using namespace mozilla::dom;
@ -23,14 +31,9 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MobileConnectionArray)
NS_INTERFACE_MAP_END
MobileConnectionArray::MobileConnectionArray(nsPIDOMWindow* aWindow)
: mInitialized(false)
: mLengthInitialized(false)
, mWindow(aWindow)
{
uint32_t numRil = mozilla::Preferences::GetUint("ril.numRadioInterfaces", 1);
MOZ_ASSERT(numRil > 0);
mMobileConnections.SetLength(numRil);
SetIsDOMBinding();
}
@ -38,17 +41,6 @@ MobileConnectionArray::~MobileConnectionArray()
{
}
void
MobileConnectionArray::Init()
{
mInitialized = true;
for (uint32_t id = 0; id < mMobileConnections.Length(); id++) {
nsRefPtr<MobileConnection> mobileConnection = new MobileConnection(mWindow, id);
mMobileConnections[id] = mobileConnection;
}
}
nsPIDOMWindow*
MobileConnectionArray::GetParentObject() const
{
@ -70,20 +62,53 @@ MobileConnectionArray::Item(uint32_t aIndex)
}
uint32_t
MobileConnectionArray::Length() const
MobileConnectionArray::Length()
{
if (!mLengthInitialized) {
mLengthInitialized = true;
nsCOMPtr<nsIMobileConnectionService> service =
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(service, 0);
uint32_t length = 0;
nsresult rv = service->GetNumItems(&length);
NS_ENSURE_SUCCESS(rv, 0);
mMobileConnections.SetLength(length);
}
return mMobileConnections.Length();
}
MobileConnection*
MobileConnectionArray::IndexedGetter(uint32_t aIndex, bool& aFound)
{
if (!mInitialized) {
Init();
aFound = aIndex < Length();
if (!aFound) {
return nullptr;
}
aFound = false;
aFound = aIndex < mMobileConnections.Length();
if (!mMobileConnections[aIndex]) {
mMobileConnections[aIndex] = new MobileConnection(mWindow, aIndex);
}
return aFound ? mMobileConnections[aIndex] : nullptr;
return mMobileConnections[aIndex];
}
already_AddRefed<nsIMobileConnectionService>
NS_CreateMobileConnectionService()
{
nsCOMPtr<nsIMobileConnectionService> service;
if (XRE_GetProcessType() == GeckoProcessType_Content) {
service = new mozilla::dom::mobileconnection::MobileConnectionIPCService();
} else {
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
service = do_CreateInstance(GONK_MOBILECONNECTION_SERVICE_CONTRACTID);
#endif
}
return service.forget();
}

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

@ -7,8 +7,8 @@
#ifndef mozilla_dom_network_MobileConnectionArray_h__
#define mozilla_dom_network_MobileConnectionArray_h__
#include "mozilla/dom/MobileConnection.h"
#include "nsWrapperCache.h"
#include "MobileConnection.h"
namespace mozilla {
namespace dom {
@ -34,7 +34,7 @@ public:
Item(uint32_t aIndex);
uint32_t
Length() const;
Length();
MobileConnection*
IndexedGetter(uint32_t aIndex, bool& aFound);
@ -42,10 +42,7 @@ public:
private:
~MobileConnectionArray();
void
Init();
bool mInitialized;
bool mLengthInitialized;
nsCOMPtr<nsPIDOMWindow> mWindow;
nsTArray<nsRefPtr<MobileConnection>> mMobileConnections;

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

@ -4,14 +4,16 @@
#include "MobileConnectionCallback.h"
#include "DOMMMIError.h"
#include "mozilla/dom/DOMMMIError.h"
#include "mozilla/dom/MobileNetworkInfo.h"
#include "mozilla/dom/MozMobileConnectionBinding.h"
#include "mozilla/dom/ToJSValue.h"
#include "nsJSUtils.h"
#include "nsServiceManagerUtils.h"
using namespace mozilla::dom;
namespace mozilla {
namespace dom {
namespace mobileconnection {
NS_IMPL_ISUPPORTS(MobileConnectionCallback, nsIMobileConnectionCallback)
@ -317,3 +319,7 @@ MobileConnectionCallback::NotifyError(const nsAString& aName,
return NS_ERROR_FAILURE;
}
} // namespace mobileconnection
} // namespace dom
} // namespace mozilla

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

@ -2,16 +2,17 @@
* 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 mozilla_dom_MobileConnectionCallback_h
#define mozilla_dom_MobileConnectionCallback_h
#ifndef mozilla_dom_mobileconnection_MobileConnectionCallback_h
#define mozilla_dom_mobileconnection_MobileConnectionCallback_h
#include "mozilla/dom/DOMRequest.h"
#include "mozilla/dom/MobileConnectionIPCSerializer.h"
#include "mozilla/dom/mobileconnection/MobileConnectionIPCSerializer.h"
#include "nsCOMPtr.h"
#include "nsIMobileConnectionService.h"
namespace mozilla {
namespace dom {
namespace mobileconnection {
/**
* A callback object for handling asynchronous request/response. This object is
@ -20,7 +21,7 @@ namespace dom {
* The modules hold the reference of MobileConnectionCallback in OOP mode and
* non-OOP mode are different.
* - OOP mode: MobileConnectionRequestChild
* - non-OOP mode: MobileConnectionGonkService
* - non-OOP mode: MobileConnectionService
* The reference should be released after Notify*Success/Error is called.
*/
class MobileConnectionCallback MOZ_FINAL : public nsIMobileConnectionCallback
@ -72,7 +73,8 @@ private:
nsRefPtr<DOMRequest> mRequest;
};
} // name space dom
} // name space mozilla
} // namespace mobileconnection
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_MobileConnectionCallback_h
#endif // mozilla_dom_mobileconnection_MobileConnectionCallback_h

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

@ -4,7 +4,7 @@
* 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/. */
#include "MobileConnectionInfo.h"
#include "mozilla/dom/MobileConnectionInfo.h"
#include "mozilla/dom/ScriptSettings.h"

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

@ -7,8 +7,8 @@
#ifndef mozilla_dom_MobileConnectionInfo_h
#define mozilla_dom_MobileConnectionInfo_h
#include "MobileCellInfo.h"
#include "MobileNetworkInfo.h"
#include "mozilla/dom/MobileCellInfo.h"
#include "mozilla/dom/MobileNetworkInfo.h"
#include "mozilla/dom/MozMobileConnectionInfoBinding.h"
#include "nsIMobileConnectionInfo.h"
#include "nsPIDOMWindow.h"

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

@ -4,7 +4,7 @@
* 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/. */
#include "MobileNetworkInfo.h"
#include "mozilla/dom/MobileNetworkInfo.h"
using namespace mozilla::dom;

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

@ -1,2 +0,0 @@
component {05e20430-fe65-4984-8df9-a6a504b24a91} MobileConnectionGonkService.js
contract @mozilla.org/mobileconnection/mobileconnectiongonkservice;1 {05e20430-fe65-4984-8df9-a6a504b24a91}

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

@ -14,11 +14,13 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
var RIL = {};
Cu.import("resource://gre/modules/ril_consts.js", RIL);
const MOBILECONNECTIONGONKSERVICE_CONTRACTID =
"@mozilla.org/mobileconnection/mobileconnectiongonkservice;1";
const GONK_MOBILECONNECTIONSERVICE_CONTRACTID =
"@mozilla.org/mobileconnection/gonkmobileconnectionservice;1";
const MOBILECONNECTIONGONKSERVICE_CID =
Components.ID("{05e20430-fe65-4984-8df9-a6a504b24a91}");
const GONK_MOBILECONNECTIONSERVICE_CID =
Components.ID("{0c9c1a96-2c72-4c55-9e27-0ca73eb16f63}");
const MOBILECONNECTIONINFO_CID =
Components.ID("{8162b3c0-664b-45f6-96cd-f07b4e193b0e}");
const MOBILENETWORKINFO_CID =
Components.ID("{a6c8416c-09b4-46d1-bf29-6520d677d085}");
const MOBILECELLINFO_CID =
@ -44,7 +46,7 @@ XPCOMUtils.defineLazyServiceGetter(this, "gRadioInterfaceLayer",
let DEBUG = RIL.DEBUG_RIL;
function debug(s) {
dump("MobileConnectionGonkService: " + s + "\n");
dump("MobileConnectionService: " + s + "\n");
}
function MobileNetworkInfo() {
@ -83,6 +85,27 @@ MobileCellInfo.prototype = {
})
};
function MobileConnectionInfo() {}
MobileConnectionInfo.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionInfo]),
classID: MOBILECONNECTIONINFO_CID,
classInfo: XPCOMUtils.generateCI({
classID: MOBILECONNECTIONINFO_CID,
classDescription: "MobileConnectionInfo",
interfaces: [Ci.nsIMobileConnectionInfo]
}),
state: null,
connected: false,
emergencyCallsOnly: false,
roaming: false,
network: null,
cell: null,
type: null,
signalStrength: null,
relSignalStrength: null
};
function CallForwardingOptions(aOptions) {
this.active = aOptions.active;
this.action = aOptions.action;
@ -114,33 +137,17 @@ MMIResult.prototype = {
function MobileConnectionProvider(aClientId, aRadioInterface) {
this._clientId = aClientId;
this._radioInterface = aRadioInterface;
this._operatorInfo = {};
this._operatorInfo = new MobileNetworkInfo();
// An array of nsIMobileConnectionListener instances.
this._listeners = [];
this.supportedNetworkTypes = this._getSupportedNetworkTypes();
// These objects implement the nsIMobileConnectionInfo interface,
// although the actual implementation lives in the content process. So are
// the child attributes `network` and `cell`, which implement
// nsIMobileNetworkInfo and nsIMobileCellInfo respectively.
this.voiceInfo = {connected: false,
emergencyCallsOnly: false,
roaming: false,
network: null,
cell: null,
type: null,
signalStrength: null,
relSignalStrength: null};
this.dataInfo = {connected: false,
emergencyCallsOnly: false,
roaming: false,
network: null,
cell: null,
type: null,
signalStrength: null,
relSignalStrength: null};
this.voice = new MobileConnectionInfo();
this.data = new MobileConnectionInfo();
}
MobileConnectionProvider.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnection]),
_clientId: null,
_radioInterface: null,
_operatorInfo: null,
@ -152,10 +159,10 @@ MobileConnectionProvider.prototype = {
*/
_selectingNetwork: null,
voiceInfo: null,
dataInfo: null,
voice: null,
data: null,
iccId: null,
networkSelectMode: null,
networkSelectionMode: null,
radioState: null,
lastKnownNetwork: null,
lastKnownHomeNetwork: null,
@ -212,12 +219,12 @@ MobileConnectionProvider.prototype = {
*/
_isValidCallForwardingReason: function(aReason) {
switch (aReason) {
case Ci.nsIMobileConnectionService.CALL_FORWARD_REASON_UNCONDITIONAL:
case Ci.nsIMobileConnectionService.CALL_FORWARD_REASON_MOBILE_BUSY:
case Ci.nsIMobileConnectionService.CALL_FORWARD_REASON_NO_REPLY:
case Ci.nsIMobileConnectionService.CALL_FORWARD_REASON_NOT_REACHABLE:
case Ci.nsIMobileConnectionService.CALL_FORWARD_REASON_ALL_CALL_FORWARDING:
case Ci.nsIMobileConnectionService.CALL_FORWARD_REASON_ALL_CONDITIONAL_CALL_FORWARDING:
case Ci.nsIMobileConnection.CALL_FORWARD_REASON_UNCONDITIONAL:
case Ci.nsIMobileConnection.CALL_FORWARD_REASON_MOBILE_BUSY:
case Ci.nsIMobileConnection.CALL_FORWARD_REASON_NO_REPLY:
case Ci.nsIMobileConnection.CALL_FORWARD_REASON_NOT_REACHABLE:
case Ci.nsIMobileConnection.CALL_FORWARD_REASON_ALL_CALL_FORWARDING:
case Ci.nsIMobileConnection.CALL_FORWARD_REASON_ALL_CONDITIONAL_CALL_FORWARDING:
return true;
default:
return false;
@ -229,10 +236,10 @@ MobileConnectionProvider.prototype = {
*/
_isValidCallForwardingAction: function(aAction) {
switch (aAction) {
case Ci.nsIMobileConnectionService.CALL_FORWARD_ACTION_DISABLE:
case Ci.nsIMobileConnectionService.CALL_FORWARD_ACTION_ENABLE:
case Ci.nsIMobileConnectionService.CALL_FORWARD_ACTION_REGISTRATION:
case Ci.nsIMobileConnectionService.CALL_FORWARD_ACTION_ERASURE:
case Ci.nsIMobileConnection.CALL_FORWARD_ACTION_DISABLE:
case Ci.nsIMobileConnection.CALL_FORWARD_ACTION_ENABLE:
case Ci.nsIMobileConnection.CALL_FORWARD_ACTION_REGISTRATION:
case Ci.nsIMobileConnection.CALL_FORWARD_ACTION_ERASURE:
return true;
default:
return false;
@ -244,11 +251,11 @@ MobileConnectionProvider.prototype = {
*/
_isValidCallBarringProgram: function(aProgram) {
switch (aProgram) {
case Ci.nsIMobileConnectionService.CALL_BARRING_PROGRAM_ALL_OUTGOING:
case Ci.nsIMobileConnectionService.CALL_BARRING_PROGRAM_OUTGOING_INTERNATIONAL:
case Ci.nsIMobileConnectionService.CALL_BARRING_PROGRAM_OUTGOING_INTERNATIONAL_EXCEPT_HOME:
case Ci.nsIMobileConnectionService.CALL_BARRING_PROGRAM_ALL_INCOMING:
case Ci.nsIMobileConnectionService.CALL_BARRING_PROGRAM_INCOMING_ROAMING:
case Ci.nsIMobileConnection.CALL_BARRING_PROGRAM_ALL_OUTGOING:
case Ci.nsIMobileConnection.CALL_BARRING_PROGRAM_OUTGOING_INTERNATIONAL:
case Ci.nsIMobileConnection.CALL_BARRING_PROGRAM_OUTGOING_INTERNATIONAL_EXCEPT_HOME:
case Ci.nsIMobileConnection.CALL_BARRING_PROGRAM_ALL_INCOMING:
case Ci.nsIMobileConnection.CALL_BARRING_PROGRAM_INCOMING_ROAMING:
return true;
default:
return false;
@ -278,9 +285,9 @@ MobileConnectionProvider.prototype = {
*/
_isValidClirMode: function(aMode) {
switch (aMode) {
case Ci.nsIMobileConnectionService.CLIR_DEFAULT:
case Ci.nsIMobileConnectionService.CLIR_INVOCATION:
case Ci.nsIMobileConnectionService.CLIR_SUPPRESSION:
case Ci.nsIMobileConnection.CLIR_DEFAULT:
case Ci.nsIMobileConnection.CLIR_INVOCATION:
case Ci.nsIMobileConnection.CLIR_SUPPRESSION:
return true;
default:
return false;
@ -293,7 +300,7 @@ MobileConnectionProvider.prototype = {
*/
_checkRoamingBetweenOperators: function(aNetworkInfo) {
// TODO: Bug 864489 - B2G RIL: use ipdl as IPC in MozIccManager
// Should get iccInfo from IccGonkProvider.
// Should get iccInfo from GonkIccProvider.
let iccInfo = this._radioInterface.rilContext.iccInfo;
let operator = aNetworkInfo.network;
let state = aNetworkInfo.state;
@ -321,16 +328,52 @@ MobileConnectionProvider.prototype = {
return true;
},
_updateInfo: function(aDestInfo, aSrcInfo) {
_updateConnectionInfo: function(aDestInfo, aSrcInfo) {
let isUpdated = false;
for (let key in aSrcInfo) {
// For updating MobileConnectionInfo
if (key === "cell" && aSrcInfo.cell) {
if (!aDestInfo.cell) {
if (key === "network" || key === "cell") {
// nsIMobileNetworkInfo and nsIMobileCellInfo are handled explicitly below.
continue;
}
if (aDestInfo[key] !== aSrcInfo[key]) {
isUpdated = true;
aDestInfo[key] = aSrcInfo[key];
}
}
// Make sure we also reset the operator and signal strength information
// if we drop off the network.
if (aDestInfo.state !== RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED) {
aDestInfo.cell = null;
aDestInfo.network = null;
aDestInfo.signalStrength = null;
aDestInfo.relSignalStrength = null;
} else {
aDestInfo.network = this._operatorInfo;
if (aSrcInfo.cell == null) {
if (aDestInfo.cell != null) {
isUpdated = true;
aDestInfo.cell = null;
}
} else {
if (aDestInfo.cell == null) {
aDestInfo.cell = new MobileCellInfo();
}
isUpdated = this._updateInfo(aDestInfo.cell, aSrcInfo.cell) || isUpdated;
} else if (aDestInfo[key] !== aSrcInfo[key]) {
}
}
// Check roaming state
isUpdated = this._checkRoamingBetweenOperators(aDestInfo) || isUpdated;
return isUpdated;
},
_updateInfo: function(aDestInfo, aSrcInfo) {
let isUpdated = false;
for (let key in aSrcInfo) {
if (aDestInfo[key] !== aSrcInfo[key]) {
isUpdated = true;
aDestInfo[key] = aSrcInfo[key];
}
@ -386,30 +429,13 @@ MobileConnectionProvider.prototype = {
},
updateVoiceInfo: function(aNewInfo, aBatch = false) {
let isUpdated = this._updateInfo(this.voiceInfo, aNewInfo);
// Make sure we also reset the operator and signal strength information
// if we drop off the network.
if (this.voiceInfo.state !== RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED) {
this.voiceInfo.cell = null;
this.voiceInfo.network = null;
this.voiceInfo.signalStrength = null;
this.voiceInfo.relSignalStrength = null;
} else {
this.voiceInfo.network = this._operatorInfo;
}
// Check roaming state
isUpdated = this._checkRoamingBetweenOperators(this.voiceInfo) || isUpdated;
let isUpdated = this._updateConnectionInfo(this.voice, aNewInfo);
if (isUpdated && !aBatch) {
this.deliverListenerEvent("notifyVoiceChanged");
}
},
updateDataInfo: function(aNewInfo, aBatch = false) {
let isUpdated = false;
// For the data connection, the `connected` flag indicates whether
// there's an active data call. We get correct `connected` state here.
let active = gNetworkManager.active;
@ -420,22 +446,7 @@ MobileConnectionProvider.prototype = {
aNewInfo.connected = true;
}
isUpdated = this._updateInfo(this.dataInfo, aNewInfo);
// Make sure we also reset the operator and signal strength information
// if we drop off the network.
if (this.dataInfo.state !== RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED) {
this.dataInfo.cell = null;
this.dataInfo.network = null;
this.dataInfo.signalStrength = null;
this.dataInfo.relSignalStrength = null;
} else {
this.dataInfo.network = this._operatorInfo;
}
// Check roaming state
isUpdated = this._checkRoamingBetweenOperators(this.dataInfo) || isUpdated;
let isUpdated = this._updateConnectionInfo(this.data, aNewInfo);
if (isUpdated && !aBatch) {
this.deliverListenerEvent("notifyDataChanged");
}
@ -458,13 +469,13 @@ MobileConnectionProvider.prototype = {
}
// If the voice is unregistered, no need to send notification.
if (this.voiceInfo.state !== RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED &&
if (this.voice.state !== RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED &&
isUpdated && !aBatch) {
this.deliverListenerEvent("notifyVoiceChanged");
}
// If the data is unregistered, no need to send notification.
if (this.dataInfo.state !== RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED &&
if (this.data.state !== RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED &&
isUpdated && !aBatch) {
this.deliverListenerEvent("notifyDataChanged");
}
@ -472,15 +483,15 @@ MobileConnectionProvider.prototype = {
updateSignalInfo: function(aNewInfo, aBatch = false) {
// If the voice is not registered, no need to update signal information.
if (this.voiceInfo.state === RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED) {
if (this._updateInfo(this.voiceInfo, aNewInfo.voice) && !aBatch) {
if (this.voice.state === RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED) {
if (this._updateInfo(this.voice, aNewInfo.voice) && !aBatch) {
this.deliverListenerEvent("notifyVoiceChanged");
}
}
// If the data is not registered, no need to update signal information.
if (this.dataInfo.state === RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED) {
if (this._updateInfo(this.dataInfo, aNewInfo.data) && !aBatch) {
if (this.data.state === RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED) {
if (this._updateInfo(this.data, aNewInfo.data) && !aBatch) {
this.deliverListenerEvent("notifyDataChanged");
}
}
@ -504,6 +515,11 @@ MobileConnectionProvider.prototype = {
this.deliverListenerEvent("notifyRadioStateChanged");
},
getSupportedNetworkTypes: function(aTypes) {
aTypes.value = this.supportedNetworkTypes.slice();
return aTypes.value.length;
},
getNetworks: function(aCallback) {
this._radioInterface.sendWorkerMessage("getAvailableNetworks", null,
(function(aResponse) {
@ -950,7 +966,7 @@ MobileConnectionProvider.prototype = {
},
};
function MobileConnectionGonkService() {
function MobileConnectionService() {
this._providers = [];
let numClients = gRadioInterfaceLayer.numRadioInterfaces;
@ -966,15 +982,15 @@ function MobileConnectionGonkService() {
debug("init complete");
}
MobileConnectionGonkService.prototype = {
classID: MOBILECONNECTIONGONKSERVICE_CID,
classInfo: XPCOMUtils.generateCI({classID: MOBILECONNECTIONGONKSERVICE_CID,
contractID: MOBILECONNECTIONGONKSERVICE_CONTRACTID,
classDescription: "MobileConnectionGonkService",
interfaces: [Ci.nsIMobileConnectionGonkService,
MobileConnectionService.prototype = {
classID: GONK_MOBILECONNECTIONSERVICE_CID,
classInfo: XPCOMUtils.generateCI({classID: GONK_MOBILECONNECTIONSERVICE_CID,
contractID: GONK_MOBILECONNECTIONSERVICE_CONTRACTID,
classDescription: "MobileConnectionService",
interfaces: [Ci.nsIGonkMobileConnectionService,
Ci.nsIMobileConnectionService],
flags: Ci.nsIClassInfo.SINGLETON}),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionGonkService,
QueryInterface: XPCOMUtils.generateQI([Ci.nsIGonkMobileConnectionService,
Ci.nsIMobileConnectionService,
Ci.nsIObserver]),
@ -997,296 +1013,21 @@ MobileConnectionGonkService.prototype = {
/**
* nsIMobileConnectionService interface.
*/
registerListener: function(aClientId, aListener) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.registerListener(aListener);
get numItems() {
return this._providers.length;
},
unregisterListener: function(aClientId, aListener) {
let provider = this._providers[aClientId];
getItemByServiceId: function(aServiceId) {
let provider = this._providers[aServiceId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.unregisterListener(aListener);
},
getVoiceConnectionInfo: function(aClientId) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
return provider.voiceInfo;
},
getDataConnectionInfo: function(aClientId) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
return provider.dataInfo;
},
getIccId: function(aClientId) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
return provider.iccId;
},
getNetworkSelectionMode: function(aClientId) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
return provider.networkSelectMode;
},
getRadioState: function(aClientId) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
return provider.radioState;
},
getLastKnownNetwork: function(aClientId) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
return provider.lastKnownNetwork;
},
getLastKnownHomeNetwork: function(aClientId) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
return provider.lastKnownHomeNetwork;
},
getSupportedNetworkTypes: function(aClientId) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
return provider.supportedNetworkTypes;
},
getNetworks: function(aClientId, aCallback) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.getNetworks(aCallback);
},
selectNetwork: function(aClientId, aNetwork, aCallback) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.selectNetwork(aNetwork, aCallback);
},
selectNetworkAutomatically: function(aClientId, aCallback) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.selectNetworkAutomatically(aCallback);
},
setPreferredNetworkType: function(aClientId, aType, aCallback) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.setPreferredNetworkType(aType, aCallback);
},
getPreferredNetworkType: function(aClientId, aCallback) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.getPreferredNetworkType(aCallback);
},
setRoamingPreference: function(aClientId, aMode, aCallback) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.setRoamingPreference(aMode, aCallback);
},
getRoamingPreference: function(aClientId, aCallback) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.getRoamingPreference(aCallback);
},
setVoicePrivacyMode: function(aClientId, aEnabled, aCallback) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.setVoicePrivacyMode(aEnabled, aCallback);
},
getVoicePrivacyMode: function(aClientId, aCallback) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.getVoicePrivacyMode(aCallback);
},
sendMMI: function(aClientId, aMmi, aCallback) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.sendMMI(aMmi, aCallback);
},
cancelMMI: function(aClientId, aCallback) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.cancelMMI(aCallback);
},
setCallForwarding: function(aClientId, aOptions, aCallback) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.setCallForwarding(aOptions, aCallback);
},
getCallForwarding: function(aClientId, aReason, aCallback) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.getCallForwarding(aReason, aCallback);
},
setCallBarring: function(aClientId, aOptions, aCallback) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.setCallBarring(aOptions, aCallback);
},
getCallBarring: function(aClientId, aOptions, aCallback) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.getCallBarring(aOptions, aCallback);
},
changeCallBarringPassword: function(aClientId, aOptions, aCallback) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.changeCallBarringPassword(aOptions, aCallback);
},
setCallWaiting: function(aClientId, aEnabled, aCallback) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.setCallWaiting(aEnabled, aCallback);
},
getCallWaiting: function(aClientId, aCallback) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.getCallWaiting(aCallback);
},
setCallingLineIdRestriction: function(aClientId, aMode, aCallback) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.setCallingLineIdRestriction(aMode, aCallback);
},
getCallingLineIdRestriction: function(aClientId, aCallback) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.getCallingLineIdRestriction(aCallback);
},
exitEmergencyCbMode: function(aClientId, aCallback) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.exitEmergencyCbMode(aCallback);
},
setRadioEnabled: function(aClientId, aEnabled, aCallback) {
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.setRadioEnabled(aEnabled, aCallback);
return provider;
},
/**
* nsIMobileConnectionGonkService interface.
* nsIGonkMobileConnectionService interface.
*/
notifyVoiceInfoChanged: function(aClientId, aVoiceInfo) {
if (DEBUG) {
@ -1294,12 +1035,7 @@ MobileConnectionGonkService.prototype = {
JSON.stringify(aVoiceInfo));
}
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.updateVoiceInfo(aVoiceInfo);
this.getItemByServiceId(aClientId).updateVoiceInfo(aVoiceInfo);
},
notifyDataInfoChanged: function(aClientId, aDataInfo) {
@ -1308,12 +1044,7 @@ MobileConnectionGonkService.prototype = {
JSON.stringify(aDataInfo));
}
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.updateDataInfo(aDataInfo);
this.getItemByServiceId(aClientId).updateDataInfo(aDataInfo);
},
notifyUssdReceived: function(aClientId, aMessage, aSessionEnded) {
@ -1322,13 +1053,8 @@ MobileConnectionGonkService.prototype = {
aMessage + " (sessionEnded : " + aSessionEnded + ")");
}
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.deliverListenerEvent("notifyUssdReceived",
[aMessage, aSessionEnded]);
this.getItemByServiceId(aClientId)
.deliverListenerEvent("notifyUssdReceived", [aMessage, aSessionEnded]);
let info = {
message: aMessage,
@ -1344,12 +1070,8 @@ MobileConnectionGonkService.prototype = {
debug("notifyDataError for " + aClientId + ": " + aMessage);
}
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.deliverListenerEvent("notifyDataError", [aMessage]);
this.getItemByServiceId(aClientId)
.deliverListenerEvent("notifyDataError", [aMessage]);
},
notifyEmergencyCallbackModeChanged: function(aClientId, aActive, aTimeoutMs) {
@ -1358,13 +1080,9 @@ MobileConnectionGonkService.prototype = {
JSON.stringify({active: aActive, timeoutMs: aTimeoutMs}));
}
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.deliverListenerEvent("notifyEmergencyCbModeChanged",
[aActive, aTimeoutMs]);
this.getItemByServiceId(aClientId)
.deliverListenerEvent("notifyEmergencyCbModeChanged",
[aActive, aTimeoutMs]);
},
notifyOtaStatusChanged: function(aClientId, aStatus) {
@ -1372,12 +1090,8 @@ MobileConnectionGonkService.prototype = {
debug("notifyOtaStatusChanged for " + aClientId + ": " + aStatus);
}
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.deliverListenerEvent("notifyOtaStatusChanged", [aStatus]);
this.getItemByServiceId(aClientId)
.deliverListenerEvent("notifyOtaStatusChanged", [aStatus]);
},
notifyIccChanged: function(aClientId, aIccId) {
@ -1385,12 +1099,7 @@ MobileConnectionGonkService.prototype = {
debug("notifyIccChanged for " + aClientId + ": " + aIccId);
}
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.updateIccId(aIccId);
this.getItemByServiceId(aClientId).updateIccId(aIccId);
},
notifyRadioStateChanged: function(aClientId, aRadioState) {
@ -1398,12 +1107,7 @@ MobileConnectionGonkService.prototype = {
debug("notifyRadioStateChanged for " + aClientId + ": " + aRadioState);
}
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.updateRadioState(aRadioState);
this.getItemByServiceId(aClientId).updateRadioState(aRadioState);
},
notifyNetworkInfoChanged: function(aClientId, aNetworkInfo) {
@ -1412,10 +1116,7 @@ MobileConnectionGonkService.prototype = {
JSON.stringify(aNetworkInfo));
}
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
let provider = this.getItemByServiceId(aClientId);
let isVoiceUpdated = false;
let isDataUpdated = false;
@ -1461,12 +1162,7 @@ MobileConnectionGonkService.prototype = {
JSON.stringify(aSignal));
}
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.updateSignalInfo(aSignal);
this.getItemByServiceId(aClientId).updateSignalInfo(aSignal);
},
notifyOperatorChanged: function(aClientId, aOperator) {
@ -1475,12 +1171,7 @@ MobileConnectionGonkService.prototype = {
JSON.stringify(aOperator));
}
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
provider.updateOperatorInfo(aOperator);
this.getItemByServiceId(aClientId).updateOperatorInfo(aOperator);
},
notifyNetworkSelectModeChanged: function(aClientId, aMode) {
@ -1488,16 +1179,12 @@ MobileConnectionGonkService.prototype = {
debug("notifyNetworkSelectModeChanged for " + aClientId + ": " + aMode);
}
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
if (provider.networkSelectMode === aMode) {
let provider = this.getItemByServiceId(aClientId);
if (provider.networkSelectionMode === aMode) {
return;
}
provider.networkSelectMode = aMode;
provider.networkSelectionMode = aMode;
provider.deliverListenerEvent("notifyNetworkSelectionModeChanged");
},
@ -1506,10 +1193,7 @@ MobileConnectionGonkService.prototype = {
debug("notifySpnAvailable for " + aClientId);
}
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
let provider = this.getItemByServiceId(aClientId);
// Update voice roaming state
provider.updateVoiceInfo({});
@ -1523,11 +1207,7 @@ MobileConnectionGonkService.prototype = {
debug("notifyLastHomeNetworkChanged for " + aClientId + ": " + aNetwork);
}
let provider = this._providers[aClientId];
if (!provider) {
throw Cr.NS_ERROR_UNEXPECTED;
}
let provider = this.getItemByServiceId(aClientId);
if (provider.lastKnownHomeNetwork === aNetwork) {
return;
}
@ -1542,7 +1222,7 @@ MobileConnectionGonkService.prototype = {
observe: function(aSubject, aTopic, aData) {
switch (aTopic) {
case NS_NETWORK_ACTIVE_CHANGED_TOPIC_ID:
for (let i = 0; i < this._providers.length; i++) {
for (let i = 0; i < this.numItems; i++) {
let provider = this._providers[i];
// Update connected flag only.
provider.updateDataInfo({});
@ -1560,4 +1240,4 @@ MobileConnectionGonkService.prototype = {
}
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([MobileConnectionGonkService]);
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([MobileConnectionService]);

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

@ -0,0 +1,2 @@
component {0c9c1a96-2c72-4c55-9e27-0ca73eb16f63} MobileConnectionService.js
contract @mozilla.org/mobileconnection/gonkmobileconnectionservice;1 {0c9c1a96-2c72-4c55-9e27-0ca73eb16f63}

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

@ -5,12 +5,12 @@
#include "nsIMobileConnectionService.idl"
%{C++
#define NS_MOBILECONNECTION_GONK_SERVICE_CONTRACTID \
"@mozilla.org/mobileconnection/mobileconnectiongonkservice;1"
#define GONK_MOBILECONNECTION_SERVICE_CONTRACTID \
"@mozilla.org/mobileconnection/gonkmobileconnectionservice;1"
%}
[scriptable, uuid(c5baceda-247a-4018-855d-ad5b00f2e4e2)]
interface nsIMobileConnectionGonkService : nsIMobileConnectionService
[scriptable, uuid(e54fa0a4-d357-48ef-9a1e-ffc9705b44b1)]
interface nsIGonkMobileConnectionService : nsIMobileConnectionService
{
void notifyNetworkInfoChanged(in unsigned long clientId, in jsval networkInfo);

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

@ -1,21 +0,0 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.
XPIDL_SOURCES += [
'nsICellInfo.idl',
'nsIMobileCellInfo.idl',
'nsIMobileConnectionInfo.idl',
'nsIMobileConnectionService.idl',
'nsIMobileNetworkInfo.idl',
'nsINeighboringCellInfo.idl',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['MOZ_B2G_RIL']:
XPIDL_SOURCES += [
'nsIMobileConnectionGonkService.idl',
]
XPIDL_MODULE = 'dom_mobileconnection'

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

@ -4,6 +4,7 @@
#include "nsISupports.idl"
interface nsIMobileConnection;
interface nsIMobileConnectionInfo;
interface nsIMobileNetworkInfo;
interface nsIVariant;
@ -200,12 +201,23 @@ interface nsIMobileConnectionCallback : nsISupports
"@mozilla.org/mobileconnection/mobileconnectionservice;1"
%}
/**
* XPCOM component (in the content process) that provides the mobile
* network information.
*/
[scriptable, uuid(b50ad32d-f70e-4729-a947-e8cfdb6ba81f)]
[scriptable, uuid(eaba3c4a-0dd5-4919-b1a2-7812e49dbbcb)]
interface nsIMobileConnectionService : nsISupports
{
readonly attribute unsigned long numItems;
nsIMobileConnection getItemByServiceId(in unsigned long serviceId);
};
%{C++
template<typename T> struct already_AddRefed;
already_AddRefed<nsIMobileConnectionService>
NS_CreateMobileConnectionService();
%}
[scriptable, uuid(04db7331-54fe-4cf7-9347-b9481350f4c2)]
interface nsIMobileConnection : nsISupports
{
const long ICC_SERVICE_CLASS_VOICE = (1 << 0);
const long ICC_SERVICE_CLASS_DATA = (1 << 1);
@ -258,95 +270,66 @@ interface nsIMobileConnectionService : nsISupports
const long CLIR_INVOCATION = 1;
const long CLIR_SUPPRESSION = 2;
/**
* Called when a content process registers receiving unsolicited messages from
* RadioInterfaceLayer in the chrome process. Only a content process that has
* the 'mobileconnection' permission is allowed to register.
*/
void registerListener(in unsigned long clientId,
in nsIMobileConnectionListener listener);
void unregisterListener(in unsigned long clientId,
in nsIMobileConnectionListener listener);
readonly attribute unsigned long serviceId;
/**
* These two fields require the 'mobilenetwork' permission.
* Called when any one who is interested in receiving unsolicited messages
* from this nsIMobileConnection instance.
*/
DOMString getLastKnownNetwork(in unsigned long clientId);
DOMString getLastKnownHomeNetwork(in unsigned long clientId);
void registerListener(in nsIMobileConnectionListener listener);
void unregisterListener(in nsIMobileConnectionListener listener);
/**
* All fields below require the 'mobileconnection' permission.
* String of format '<mcc>-<mnc>'. When changed, listener method
* 'notifyLastKnownNetworkChanged' is called.
*/
readonly attribute DOMString lastKnownNetwork;
/**
* Get the connection information about the voice.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
*
* @return a nsIMobileConnectionInfo
* String of format '<mcc>-<mnc>[-<spn>]'. When changed, listener method
* 'notifyLastKnownHomeNetworkChanged' is called.
*/
nsIMobileConnectionInfo getVoiceConnectionInfo(in unsigned long clientId);
readonly attribute DOMString lastKnownHomeNetwork;
/**
* Get the connection information about the data.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
*
* @return a nsIMobileConnectionInfo
* Connection information about the voice.
*/
nsIMobileConnectionInfo getDataConnectionInfo(in unsigned long clientId);
readonly attribute nsIMobileConnectionInfo voice;
/**
* Get the integrated circuit card identifier of the SIM.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
*
* @return a DOMString indicates the iccId
* Connection information about the data.
*/
DOMString getIccId(in unsigned long clientId);
readonly attribute nsIMobileConnectionInfo data;
/**
* Get the selection mode of the voice and data networks.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
*
* @return a DOMString
* Possible values: 'automatic', 'manual', null (unknown).
* The integrated circuit card identifier of the SIM.
*/
DOMString getNetworkSelectionMode(in unsigned long clientId);
readonly attribute DOMString iccId;
/**
* Get the current radio state.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
*
* @return a DOMString
* Possible values: 'enabling', 'enabled', 'disabling', 'disabled',
* null (unknown).
* The selection mode of the voice and data networks. Possible values are
* 'automatic', 'manual', null (unknown).
*/
DOMString getRadioState(in unsigned long clientId);
readonly attribute DOMString networkSelectionMode;
/**
* Get the network types that are supported by this radio.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
* Current radio state. Possible values are 'enabling', 'enabled',
* 'disabling', 'disabled', null (unknown).
*/
readonly attribute DOMString radioState;
/**
* The network types supported by this radio.
*
* @return an array of DOMString
* Possible values: 'gsm', 'wcdma', 'cdma', 'evdo', 'lte'.
*/
nsIVariant getSupportedNetworkTypes(in unsigned long clientId);
void getSupportedNetworkTypes([array, size_is(length)] out wstring types,
[retval] out unsigned long length);
/**
* Search for available networks.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
* @param requestCallback
* Called when request is finished.
*
@ -357,15 +340,12 @@ interface nsIMobileConnectionService : nsISupports
* 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
* 'GenericFailure'.
*/
void getNetworks(in unsigned long clientId,
in nsIMobileConnectionCallback requestCallback);
void getNetworks(in nsIMobileConnectionCallback requestCallback);
/**
* Manually selects the passed in network, overriding the radio's current
* selection.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
* @param network
* The manually selecting network.
* @param requestCallback
@ -377,15 +357,12 @@ interface nsIMobileConnectionService : nsISupports
* 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
* 'GenericFailure'.
*/
void selectNetwork(in unsigned long clientId,
in nsIMobileNetworkInfo network,
void selectNetwork(in nsIMobileNetworkInfo network,
in nsIMobileConnectionCallback requestCallback);
/**
* Tell the radio to automatically select a network.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
* @param requestCallback
* Called when request is finished.
*
@ -395,14 +372,11 @@ interface nsIMobileConnectionService : nsISupports
* 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
* 'GenericFailure'.
*/
void selectNetworkAutomatically(in unsigned long clientId,
in nsIMobileConnectionCallback requestCallback);
void selectNetworkAutomatically(in nsIMobileConnectionCallback requestCallback);
/**
* Set preferred network type.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
* @param type
* DOMString indicates the desired preferred network type.
* Possible values: 'wcdma/gsm', 'gsm', 'wcdma', 'wcdma/gsm-auto',
@ -418,15 +392,12 @@ interface nsIMobileConnectionService : nsISupports
* 'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter',
* 'IllegalSIMorME', or 'GenericFailure'.
*/
void setPreferredNetworkType(in unsigned long clientId,
in DOMString type,
void setPreferredNetworkType(in DOMString type,
in nsIMobileConnectionCallback requestCallback);
/**
* Query current preferred network type.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
* @param requestCallback
* Called when request is finished.
*
@ -440,14 +411,11 @@ interface nsIMobileConnectionService : nsISupports
* 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
* 'GenericFailure'.
*/
void getPreferredNetworkType(in unsigned long clientId,
in nsIMobileConnectionCallback requestCallback);
void getPreferredNetworkType(in nsIMobileConnectionCallback requestCallback);
/**
* Set roaming preference.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
* @param mode
* DOMString indicates the desired roaming preference.
* Possible values: 'home', 'affiliated', or 'any'.
@ -460,15 +428,12 @@ interface nsIMobileConnectionService : nsISupports
* 'RadioNotAvailable', 'RequestNotSupported', InvalidParameter',
* 'IllegalSIMorME', or 'GenericFailure'.
*/
void setRoamingPreference(in unsigned long clientId,
in DOMString mode,
void setRoamingPreference(in DOMString mode,
in nsIMobileConnectionCallback requestCallback);
/**
* Query current roaming preference.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
* @param requestCallback
* Called when request is finished.
*
@ -480,14 +445,11 @@ interface nsIMobileConnectionService : nsISupports
* 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
* 'GenericFailure'.
*/
void getRoamingPreference(in unsigned long clientId,
in nsIMobileConnectionCallback requestCallback);
void getRoamingPreference(in nsIMobileConnectionCallback requestCallback);
/**
* Set voice privacy preference.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
* @param enabled
* Boolean indicates the preferred voice privacy mode used in voice
* scrambling in CDMA networks. 'True' means the enhanced voice security
@ -501,15 +463,12 @@ interface nsIMobileConnectionService : nsISupports
* 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
* 'GenericFailure'.
*/
void setVoicePrivacyMode(in unsigned long clientId,
in bool enabled,
void setVoicePrivacyMode(in bool enabled,
in nsIMobileConnectionCallback requestCallback);
/**
* Query current voice privacy mode.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
* @param requestCallback
* Called when request is finished.
*
@ -520,14 +479,11 @@ interface nsIMobileConnectionService : nsISupports
* 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
* 'GenericFailure'.
*/
void getVoicePrivacyMode(in unsigned long clientId,
in nsIMobileConnectionCallback requestCallback);
void getVoicePrivacyMode(in nsIMobileConnectionCallback requestCallback);
/**
* Send a MMI message.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
* @param mmi
* DOMString containing an MMI string that can be associated to a
* USSD request or other RIL functionality.
@ -539,15 +495,12 @@ interface nsIMobileConnectionService : nsISupports
*
* Otherwise, the notifyError() will be called.
*/
void sendMMI(in unsigned long clientId,
in DOMString mmi,
void sendMMI(in DOMString mmi,
in nsIMobileConnectionCallback requestCallback);
/**
* Cancel the current MMI request if one exists.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
* @param requestCallback
* Called when request is finished.
*
@ -556,14 +509,11 @@ interface nsIMobileConnectionService : nsISupports
*
* Otherwise, the notifyError() will be called.
*/
void cancelMMI(in unsigned long clientId,
in nsIMobileConnectionCallback requestCallback);
void cancelMMI(in nsIMobileConnectionCallback requestCallback);
/**
* Queries current call forwarding options.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
* @param reason
* Indicates the reason the call is being forwarded. It shall be one of
* the nsIMobileConnectionService.CALL_FORWARD_REASON_* values.
@ -578,15 +528,12 @@ interface nsIMobileConnectionService : nsISupports
* 'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter',
* 'IllegalSIMorME', or 'GenericFailure'.
*/
void getCallForwarding(in unsigned long clientId,
in unsigned short reason,
void getCallForwarding(in unsigned short reason,
in nsIMobileConnectionCallback requestCallback);
/**
* Configures call forwarding options.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
* @param options
* An object containing the call forward rule to set.
* @see MozCallForwardingOptions for the detail of options.
@ -599,15 +546,12 @@ interface nsIMobileConnectionService : nsISupports
* 'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter',
* 'IllegalSIMorME', or 'GenericFailure'.
*/
void setCallForwarding(in unsigned long clientId,
in jsval options,
void setCallForwarding(in jsval options,
in nsIMobileConnectionCallback requestCallback);
/**
* Queries current call barring status.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
* @param options
* An object containing the call barring rule to query. No need to
* specify 'enabled' property.
@ -623,15 +567,12 @@ interface nsIMobileConnectionService : nsISupports
* 'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter',
* 'IllegalSIMorME', or 'GenericFailure'.
*/
void getCallBarring(in unsigned long clientId,
in jsval options,
void getCallBarring(in jsval options,
in nsIMobileConnectionCallback requestCallback);
/**
* Configures call barring option.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
* @param options
* An object containing the call barring rule to set.
* @see MozCallBarringOptions for the detail of options.
@ -644,15 +585,12 @@ interface nsIMobileConnectionService : nsISupports
* 'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter',
* 'IllegalSIMorME', or 'GenericFailure'.
*/
void setCallBarring(in unsigned long clientId,
in jsval options,
void setCallBarring(in jsval options,
in nsIMobileConnectionCallback requestCallback);
/**
* Change call barring facility password.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
* @param options
* An object containing information about pin and newPin, and,
* this object must have both "pin" and "newPin" attributes
@ -667,15 +605,12 @@ interface nsIMobileConnectionService : nsISupports
* 'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter',
* 'IllegalSIMorME', or 'GenericFailure'.
*/
void changeCallBarringPassword(in unsigned long clientId,
in jsval options,
void changeCallBarringPassword(in jsval options,
in nsIMobileConnectionCallback requestCallback);
/**
* Configures call waiting options.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
* @param enabled
* Boolean indicates the desired call waiting status.
* @param requestCallback
@ -687,15 +622,12 @@ interface nsIMobileConnectionService : nsISupports
* 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
* 'GenericFailure'.
*/
void setCallWaiting(in unsigned long clientId,
in bool enabled,
void setCallWaiting(in bool enabled,
in nsIMobileConnectionCallback requestCallback);
/**
* Queries current call waiting options.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
* @param requestCallback
* Called when request is finished.
*
@ -706,15 +638,12 @@ interface nsIMobileConnectionService : nsISupports
* 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
* 'GenericFailure'.
*/
void getCallWaiting(in unsigned long clientId,
in nsIMobileConnectionCallback requestCallback);
void getCallWaiting(in nsIMobileConnectionCallback requestCallback);
/**
* Enables or disables the presentation of the calling line identity (CLI) to
* the called party when originating a call.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
* @param clirMode
* One of the nsIMobileConnectionService.CLIR_* values.
* @param requestCallback
@ -726,15 +655,12 @@ interface nsIMobileConnectionService : nsISupports
* 'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter',
* 'IllegalSIMorME', or 'GenericFailure'.
*/
void setCallingLineIdRestriction(in unsigned long clientId,
in unsigned short clirMode,
void setCallingLineIdRestriction(in unsigned short clirMode,
in nsIMobileConnectionCallback requestCallback);
/**
* Queries current CLIR status.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
* @param requestCallback
* Called when request is finished.
*
@ -746,14 +672,11 @@ interface nsIMobileConnectionService : nsISupports
* 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
* 'GenericFailure'.
*/
void getCallingLineIdRestriction(in unsigned long clientId,
in nsIMobileConnectionCallback requestCallback);
void getCallingLineIdRestriction(in nsIMobileConnectionCallback requestCallback);
/**
* Exit emergency callback mode.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
* @param requestCallback
* Called when request is finished.
*
@ -763,14 +686,11 @@ interface nsIMobileConnectionService : nsISupports
* 'RadioNotAvailable', 'RequestNotSupported', 'IllegalSIMorME', or
* 'GenericFailure'.
*/
void exitEmergencyCbMode(in unsigned long clientId,
in nsIMobileConnectionCallback requestCallback);
void exitEmergencyCbMode(in nsIMobileConnectionCallback requestCallback);
/**
* Set radio enabled/disabled.
*
* @param clientId
* Indicate the RIL client, 0 ~ (number of client - 1).
* @param enabled
* Boolean indicates the desired radio power. True to enable the radio.
* @param requestCallback
@ -786,7 +706,6 @@ interface nsIMobileConnectionService : nsISupports
* 'disabling'. Calling the function in above conditions will receive
* 'InvalidStateError' error.
*/
void setRadioEnabled(in unsigned long clientId,
in bool enabled,
void setRadioEnabled(in bool enabled,
in nsIMobileConnectionCallback requestCallback);
};

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

@ -2,7 +2,7 @@
* 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/. */
#include "MobileConnectionChild.h"
#include "mozilla/dom/mobileconnection/MobileConnectionChild.h"
#include "MobileConnectionCallback.h"
#include "mozilla/dom/MozMobileConnectionBinding.h"
@ -11,15 +11,23 @@
using namespace mozilla::dom;
using namespace mozilla::dom::mobileconnection;
NS_IMPL_ISUPPORTS(MobileConnectionChild, nsIMobileConnection)
MobileConnectionChild::MobileConnectionChild(uint32_t aServiceId)
: mServiceId(aServiceId)
, mLive(true)
{
MOZ_COUNT_CTOR(MobileConnectionChild);
}
void
MobileConnectionChild::Init()
{
nsIMobileConnectionInfo* rawVoice;
nsIMobileConnectionInfo* rawData;
nsTArray<nsString> types;
SendInit(&rawVoice, &rawData, &mLastNetwork, &mLastHomeNetwork, &mIccId,
&mNetworkSelectionMode, &mRadioState, &types);
&mNetworkSelectionMode, &mRadioState, &mSupportedNetworkTypes);
// Use dont_AddRef here because this instances is already AddRef-ed in
// MobileConnectionIPCSerializer.h
@ -32,35 +40,6 @@ MobileConnectionChild::Init()
nsCOMPtr<nsIMobileConnectionInfo> data = dont_AddRef(rawData);
mData = new MobileConnectionInfo(nullptr);
mData->Update(data);
// Initial SupportedNetworkTypes
nsresult rv;
mSupportedNetworkTypes = do_CreateInstance(NS_VARIANT_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
return;
}
uint32_t arrayLen = types.Length();
if (arrayLen == 0) {
mSupportedNetworkTypes->SetAsEmptyArray();
} else {
// Note: The resulting nsIVariant dupes both the array and its elements.
const char16_t** array = reinterpret_cast<const char16_t**>
(NS_Alloc(arrayLen * sizeof(const char16_t***)));
if (array) {
for (uint32_t i = 0; i < arrayLen; ++i) {
array[i] = types[i].get();
}
mSupportedNetworkTypes->SetAsArray(nsIDataType::VTYPE_WCHAR_STR,
nullptr,
arrayLen,
reinterpret_cast<void*>(array));
NS_Free(array);
}
}
}
void
@ -74,79 +53,309 @@ MobileConnectionChild::Shutdown()
mListeners.Clear();
mVoice = nullptr;
mData = nullptr;
mSupportedNetworkTypes = nullptr;
}
void
// nsIMobileConnection
NS_IMETHODIMP
MobileConnectionChild::GetServiceId(uint32_t* aServiceId)
{
*aServiceId = mServiceId;
return NS_OK;
}
NS_IMETHODIMP
MobileConnectionChild::RegisterListener(nsIMobileConnectionListener* aListener)
{
if (!mListeners.Contains(aListener)) {
mListeners.AppendObject(aListener);
}
NS_ENSURE_TRUE(!mListeners.Contains(aListener), NS_ERROR_UNEXPECTED);
mListeners.AppendObject(aListener);
return NS_OK;
}
void
NS_IMETHODIMP
MobileConnectionChild::UnregisterListener(nsIMobileConnectionListener* aListener)
{
NS_ENSURE_TRUE(mListeners.Contains(aListener), NS_ERROR_UNEXPECTED);
mListeners.RemoveObject(aListener);
return NS_OK;
}
MobileConnectionInfo*
MobileConnectionChild::GetVoiceInfo()
NS_IMETHODIMP
MobileConnectionChild::GetVoice(nsIMobileConnectionInfo** aVoice)
{
return mVoice;
nsRefPtr<nsIMobileConnectionInfo> voice(mVoice);
voice.forget(aVoice);
return NS_OK;
}
MobileConnectionInfo*
MobileConnectionChild::GetDataInfo()
NS_IMETHODIMP
MobileConnectionChild::GetData(nsIMobileConnectionInfo** aData)
{
return mData;
nsRefPtr<nsIMobileConnectionInfo> data(mData);
data.forget(aData);
return NS_OK;
}
void
NS_IMETHODIMP
MobileConnectionChild::GetIccId(nsAString& aIccId)
{
aIccId = mIccId;
return NS_OK;
}
void
NS_IMETHODIMP
MobileConnectionChild::GetRadioState(nsAString& aRadioState)
{
aRadioState = mRadioState;
return NS_OK;
}
nsIVariant*
MobileConnectionChild::GetSupportedNetworkTypes()
NS_IMETHODIMP
MobileConnectionChild::GetSupportedNetworkTypes(char16_t*** aTypes,
uint32_t* aLength)
{
return mSupportedNetworkTypes;
NS_ENSURE_ARG(aTypes);
NS_ENSURE_ARG(aLength);
*aLength = mSupportedNetworkTypes.Length();
*aTypes =
static_cast<char16_t**>(nsMemory::Alloc((*aLength) * sizeof(char16_t*)));
NS_ENSURE_TRUE(*aTypes, NS_ERROR_OUT_OF_MEMORY);
for (uint32_t i = 0; i < *aLength; i++) {
(*aTypes)[i] = ToNewUnicode(mSupportedNetworkTypes[i]);
}
return NS_OK;
}
void
MobileConnectionChild::GetLastNetwork(nsAString& aNetwork)
NS_IMETHODIMP
MobileConnectionChild::GetLastKnownNetwork(nsAString& aNetwork)
{
aNetwork = mLastNetwork;
return NS_OK;
}
void
MobileConnectionChild::GetLastHomeNetwork(nsAString& aNetwork)
NS_IMETHODIMP
MobileConnectionChild::GetLastKnownHomeNetwork(nsAString& aNetwork)
{
aNetwork = mLastHomeNetwork;
return NS_OK;
}
void
NS_IMETHODIMP
MobileConnectionChild::GetNetworkSelectionMode(nsAString& aMode)
{
aMode = mNetworkSelectionMode;
return NS_OK;
}
NS_IMETHODIMP
MobileConnectionChild::GetNetworks(nsIMobileConnectionCallback* aCallback)
{
return SendRequest(GetNetworksRequest(), aCallback) ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
MobileConnectionChild::SelectNetwork(nsIMobileNetworkInfo* aNetwork,
nsIMobileConnectionCallback* aCallback)
{
nsCOMPtr<nsIMobileNetworkInfo> network = aNetwork;
// We release the ref after serializing process is finished in
// MobileConnectionIPCSerializer.
return SendRequest(SelectNetworkRequest(network.forget().take()), aCallback)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
MobileConnectionChild::SelectNetworkAutomatically(nsIMobileConnectionCallback* aCallback)
{
return SendRequest(SelectNetworkAutoRequest(), aCallback)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
MobileConnectionChild::SetPreferredNetworkType(const nsAString& aType,
nsIMobileConnectionCallback* aCallback)
{
return SendRequest(SetPreferredNetworkTypeRequest(nsAutoString(aType)),
aCallback)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
MobileConnectionChild::GetPreferredNetworkType(nsIMobileConnectionCallback* aCallback)
{
return SendRequest(GetPreferredNetworkTypeRequest(), aCallback)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
MobileConnectionChild::SetRoamingPreference(const nsAString& aMode,
nsIMobileConnectionCallback* aCallback)
{
return SendRequest(SetRoamingPreferenceRequest(nsAutoString(aMode)),
aCallback)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
MobileConnectionChild::GetRoamingPreference(nsIMobileConnectionCallback* aCallback)
{
return SendRequest(GetRoamingPreferenceRequest(), aCallback)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
MobileConnectionChild::SetVoicePrivacyMode(bool aEnabled,
nsIMobileConnectionCallback* aCallback)
{
return SendRequest(SetVoicePrivacyModeRequest(aEnabled), aCallback)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
MobileConnectionChild::GetVoicePrivacyMode(nsIMobileConnectionCallback* aCallback)
{
return SendRequest(GetVoicePrivacyModeRequest(), aCallback)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
MobileConnectionChild::SendMMI(const nsAString& aMmi,
nsIMobileConnectionCallback* aCallback)
{
return SendRequest(SendMmiRequest(nsAutoString(aMmi)), aCallback)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
MobileConnectionChild::CancelMMI(nsIMobileConnectionCallback* aCallback)
{
return SendRequest(CancelMmiRequest(), aCallback) ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
MobileConnectionChild::SetCallForwarding(JS::Handle<JS::Value> aOptions,
nsIMobileConnectionCallback* aCallback)
{
AutoSafeJSContext cx;
IPC::MozCallForwardingOptions options;
if(!options.Init(cx, aOptions)) {
return NS_ERROR_TYPE_ERR;
}
return SendRequest(SetCallForwardingRequest(options), aCallback)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
MobileConnectionChild::GetCallForwarding(uint16_t aReason,
nsIMobileConnectionCallback* aCallback)
{
return SendRequest(GetCallForwardingRequest(aReason), aCallback)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
MobileConnectionChild::SetCallBarring(JS::Handle<JS::Value> aOptions,
nsIMobileConnectionCallback* aCallback)
{
AutoSafeJSContext cx;
IPC::MozCallBarringOptions options;
if(!options.Init(cx, aOptions)) {
return NS_ERROR_TYPE_ERR;
}
return SendRequest(SetCallBarringRequest(options), aCallback)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
MobileConnectionChild::GetCallBarring(JS::Handle<JS::Value> aOptions,
nsIMobileConnectionCallback* aCallback)
{
AutoSafeJSContext cx;
IPC::MozCallBarringOptions options;
if(!options.Init(cx, aOptions)) {
return NS_ERROR_TYPE_ERR;
}
return SendRequest(GetCallBarringRequest(options), aCallback)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
MobileConnectionChild::ChangeCallBarringPassword(JS::Handle<JS::Value> aOptions,
nsIMobileConnectionCallback* aCallback)
{
AutoSafeJSContext cx;
IPC::MozCallBarringOptions options;
if(!options.Init(cx, aOptions)) {
return NS_ERROR_TYPE_ERR;
}
return SendRequest(ChangeCallBarringPasswordRequest(options), aCallback)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
MobileConnectionChild::SetCallWaiting(bool aEnabled,
nsIMobileConnectionCallback* aCallback)
{
return SendRequest(SetCallWaitingRequest(aEnabled), aCallback)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
MobileConnectionChild::GetCallWaiting(nsIMobileConnectionCallback* aCallback)
{
return SendRequest(GetCallWaitingRequest(), aCallback)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
MobileConnectionChild::SetCallingLineIdRestriction(uint16_t aMode,
nsIMobileConnectionCallback* aCallback)
{
return SendRequest(SetCallingLineIdRestrictionRequest(aMode), aCallback)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
MobileConnectionChild::GetCallingLineIdRestriction(nsIMobileConnectionCallback* aCallback)
{
return SendRequest(GetCallingLineIdRestrictionRequest(), aCallback)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
MobileConnectionChild::ExitEmergencyCbMode(nsIMobileConnectionCallback* aCallback)
{
return SendRequest(ExitEmergencyCbModeRequest(), aCallback)
? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
MobileConnectionChild::SetRadioEnabled(bool aEnabled,
nsIMobileConnectionCallback* aCallback)
{
return SendRequest(SetRadioEnabledRequest(aEnabled), aCallback)
? NS_OK : NS_ERROR_FAILURE;
}
bool
MobileConnectionChild::SendRequest(MobileConnectionRequest aRequest,
nsIMobileConnectionCallback* aRequestCallback)
MobileConnectionChild::SendRequest(const MobileConnectionRequest& aRequest,
nsIMobileConnectionCallback* aCallback)
{
NS_ENSURE_TRUE(mLive, false);
// Deallocated in MobileConnectionChild::DeallocPMobileConnectionRequestChild().
MobileConnectionRequestChild* actor = new MobileConnectionRequestChild(aRequestCallback);
MobileConnectionRequestChild* actor =
new MobileConnectionRequestChild(aCallback);
SendPMobileConnectionRequestConstructor(actor, aRequest);
return true;

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

@ -5,15 +5,16 @@
#ifndef mozilla_dom_mobileconnection_MobileConnectionChild_h
#define mozilla_dom_mobileconnection_MobileConnectionChild_h
#include "mozilla/dom/MobileConnectionCallback.h"
#include "mozilla/dom/MobileConnectionInfo.h"
#include "mozilla/dom/PMobileConnectionChild.h"
#include "mozilla/dom/PMobileConnectionRequestChild.h"
#include "mozilla/dom/mobileconnection/PMobileConnectionChild.h"
#include "mozilla/dom/mobileconnection/PMobileConnectionRequestChild.h"
#include "nsCOMArray.h"
#include "nsCOMPtr.h"
#include "nsIMobileConnectionService.h"
#include "nsIVariant.h"
class nsIMobileConnectionCallback;
namespace mozilla {
namespace dom {
namespace mobileconnection {
@ -24,16 +25,14 @@ namespace mobileconnection {
* shutdown. For multi-sim device, more than one instance will
* be created and each instance represents a sim slot.
*/
class MobileConnectionChild : public PMobileConnectionChild
class MobileConnectionChild MOZ_FINAL : public PMobileConnectionChild
, public nsIMobileConnection
{
NS_INLINE_DECL_REFCOUNTING(MobileConnectionChild)
public:
MobileConnectionChild()
: mLive(true)
{
MOZ_COUNT_CTOR(MobileConnectionChild);
}
NS_DECL_ISUPPORTS
NS_DECL_NSIMOBILECONNECTION
MobileConnectionChild(uint32_t aServiceId);
void
Init();
@ -41,48 +40,20 @@ public:
void
Shutdown();
void
RegisterListener(nsIMobileConnectionListener* aListener);
private:
MobileConnectionChild() MOZ_DELETE;
void
UnregisterListener(nsIMobileConnectionListener* aListener);
MobileConnectionInfo*
GetVoiceInfo();
MobileConnectionInfo*
GetDataInfo();
void
GetIccId(nsAString& aIccId);
void
GetRadioState(nsAString& aRadioState);
nsIVariant*
GetSupportedNetworkTypes();
void
GetLastNetwork(nsAString& aNetwork);
void
GetLastHomeNetwork(nsAString& aNetwork);
void
GetNetworkSelectionMode(nsAString& aMode);
bool
SendRequest(MobileConnectionRequest aRequest,
nsIMobileConnectionCallback* aRequestCallback);
protected:
virtual
// MOZ_FINAL suppresses -Werror,-Wdelete-non-virtual-dtor
~MobileConnectionChild()
{
MOZ_COUNT_DTOR(MobileConnectionChild);
Shutdown();
}
protected:
bool
SendRequest(const MobileConnectionRequest& aRequest,
nsIMobileConnectionCallback* aCallback);
virtual void
ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
@ -136,9 +107,9 @@ protected:
RecvNotifyNetworkSelectionModeChanged(const nsString& aMode) MOZ_OVERRIDE;
private:
uint32_t mServiceId;
bool mLive;
nsCOMArray<nsIMobileConnectionListener> mListeners;
nsCOMPtr<nsIWritableVariant> mSupportedNetworkTypes;
nsRefPtr<MobileConnectionInfo> mVoice;
nsRefPtr<MobileConnectionInfo> mData;
nsString mIccId;
@ -146,6 +117,7 @@ private:
nsString mLastNetwork;
nsString mLastHomeNetwork;
nsString mNetworkSelectionMode;
nsTArray<nsString> mSupportedNetworkTypes;
};
/******************************************************************************

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

@ -2,14 +2,14 @@
* 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 dom_mobileconnection_src_ipc_MobileConnectionIPCSerialiser_h
#define dom_mobileconnection_src_ipc_MobileConnectionIPCSerialiser_h
#ifndef mozilla_dom_mobileconnection_MobileConnectionIPCSerialiser_h
#define mozilla_dom_mobileconnection_MobileConnectionIPCSerialiser_h
#include "ipc/IPCMessageUtils.h"
#include "mozilla/dom/MobileCellInfo.h"
#include "mozilla/dom/MobileConnectionInfo.h"
#include "mozilla/dom/MobileNetworkInfo.h"
#include "MozMobileConnectionBinding.h"
#include "mozilla/dom/MozMobileConnectionBinding.h"
using mozilla::AutoSafeJSContext;
using mozilla::dom::MobileNetworkInfo;
@ -746,4 +746,4 @@ struct ParamTraits<MozCallBarringOptions>
} // namespace IPC
#endif // dom_mobileconnection_src_ipc_MobileConnectionIPCSerialiser_h
#endif // mozilla_dom_mobileconnection_MobileConnectionIPCSerialiser_h

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

@ -14,381 +14,51 @@ using namespace mozilla::dom::mobileconnection;
NS_IMPL_ISUPPORTS(MobileConnectionIPCService, nsIMobileConnectionService)
StaticRefPtr<MobileConnectionIPCService> sService;
/* static */MobileConnectionIPCService*
MobileConnectionIPCService::GetSingleton()
{
MOZ_ASSERT(NS_IsMainThread());
if (sService) {
return sService;
}
sService = new MobileConnectionIPCService();
return sService;
}
MobileConnectionIPCService::MobileConnectionIPCService()
{
int32_t numRil = Preferences::GetInt("ril.numRadioInterfaces", 1);
for (int32_t i = 0; i < numRil; i++) {
// Deallocated in ContentChild::DeallocPMobileConnectionChild().
nsRefPtr<MobileConnectionChild> client = new MobileConnectionChild();
NS_ASSERTION(client, "This shouldn't fail!");
ContentChild::GetSingleton()->SendPMobileConnectionConstructor(client, i);
client->Init();
mClients.AppendElement(client);
}
mItems.SetLength(numRil);
}
MobileConnectionIPCService::~MobileConnectionIPCService()
{
uint32_t count = mClients.Length();
uint32_t count = mItems.Length();
for (uint32_t i = 0; i < count; i++) {
mClients[i]->Shutdown();
if (mItems[i]) {
mItems[i]->Shutdown();
}
}
mClients.Clear();
}
nsresult
MobileConnectionIPCService::SendRequest(uint32_t aClientId,
MobileConnectionRequest aRequest,
nsIMobileConnectionCallback* aRequestCallback)
{
if (aClientId >= mClients.Length()) {
return NS_ERROR_FAILURE;
}
mClients[aClientId]->SendRequest(aRequest, aRequestCallback);
return NS_OK;
}
// nsIMobileConnectionService
NS_IMETHODIMP
MobileConnectionIPCService::RegisterListener(uint32_t aClientId,
nsIMobileConnectionListener* aListener)
MobileConnectionIPCService::GetNumItems(uint32_t* aNumItems)
{
if (aClientId >= mClients.Length()) {
return NS_ERROR_FAILURE;
}
mClients[aClientId]->RegisterListener(aListener);
*aNumItems = mItems.Length();
return NS_OK;
}
NS_IMETHODIMP
MobileConnectionIPCService::UnregisterListener(uint32_t aClientId,
nsIMobileConnectionListener* aListener)
MobileConnectionIPCService::GetItemByServiceId(uint32_t aServiceId,
nsIMobileConnection** aItem)
{
if (aClientId >= mClients.Length()) {
return NS_ERROR_FAILURE;
NS_ENSURE_TRUE(aServiceId < mItems.Length(), NS_ERROR_INVALID_ARG);
if (!mItems[aServiceId]) {
nsRefPtr<MobileConnectionChild> child = new MobileConnectionChild(aServiceId);
// |SendPMobileConnectionConstructor| adds another reference to the child
// actor and removes in |DeallocPMobileConnectionChild|.
ContentChild::GetSingleton()->SendPMobileConnectionConstructor(child,
aServiceId);
child->Init();
mItems[aServiceId] = child;
}
mClients[aClientId]->UnregisterListener(aListener);
return NS_OK;
}
NS_IMETHODIMP
MobileConnectionIPCService::GetLastKnownNetwork(uint32_t aClientId,
nsAString& aLastNetwork)
{
if (aClientId >= mClients.Length()) {
return NS_ERROR_FAILURE;
}
mClients[aClientId]->GetLastNetwork(aLastNetwork);
return NS_OK;
}
NS_IMETHODIMP
MobileConnectionIPCService::GetLastKnownHomeNetwork(uint32_t aClientId,
nsAString& aLastNetwork)
{
if (aClientId >= mClients.Length()) {
return NS_ERROR_FAILURE;
}
mClients[aClientId]->GetLastHomeNetwork(aLastNetwork);
return NS_OK;
}
NS_IMETHODIMP
MobileConnectionIPCService::GetVoiceConnectionInfo(uint32_t aClientId,
nsIMobileConnectionInfo** aInfo)
{
if (aClientId >= mClients.Length()) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIMobileConnectionInfo> info = mClients[aClientId]->GetVoiceInfo();
info.forget(aInfo);
nsRefPtr<nsIMobileConnection> item(mItems[aServiceId]);
item.forget(aItem);
return NS_OK;
}
NS_IMETHODIMP
MobileConnectionIPCService::GetDataConnectionInfo(uint32_t aClientId,
nsIMobileConnectionInfo** aInfo)
{
if (aClientId >= mClients.Length()) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIMobileConnectionInfo> info = mClients[aClientId]->GetDataInfo();
info.forget(aInfo);
return NS_OK;
}
NS_IMETHODIMP
MobileConnectionIPCService::GetIccId(uint32_t aClientId, nsAString& aIccId)
{
if (aClientId >= mClients.Length()) {
return NS_ERROR_FAILURE;
}
mClients[aClientId]->GetIccId(aIccId);
return NS_OK;
}
NS_IMETHODIMP
MobileConnectionIPCService::GetNetworkSelectionMode(uint32_t aClientId,
nsAString& aNetworkSelectionMode)
{
if (aClientId >= mClients.Length()) {
return NS_ERROR_FAILURE;
}
mClients[aClientId]->GetNetworkSelectionMode(aNetworkSelectionMode);
return NS_OK;
}
NS_IMETHODIMP
MobileConnectionIPCService::GetRadioState(uint32_t aClientId,
nsAString& aRadioState)
{
if (aClientId >= mClients.Length()) {
return NS_ERROR_FAILURE;
}
mClients[aClientId]->GetRadioState(aRadioState);
return NS_OK;
}
NS_IMETHODIMP
MobileConnectionIPCService::GetSupportedNetworkTypes(uint32_t aClientId,
nsIVariant** aSupportedTypes)
{
if (aClientId >= mClients.Length()) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIVariant> supportedTypes = mClients[aClientId]->GetSupportedNetworkTypes();
supportedTypes.forget(aSupportedTypes);
return NS_OK;
}
NS_IMETHODIMP
MobileConnectionIPCService::GetNetworks(uint32_t aClientId,
nsIMobileConnectionCallback* aRequest)
{
return SendRequest(aClientId, GetNetworksRequest(), aRequest);
}
NS_IMETHODIMP
MobileConnectionIPCService::SelectNetwork(uint32_t aClientId,
nsIMobileNetworkInfo* aNetwork,
nsIMobileConnectionCallback* aRequest)
{
nsCOMPtr<nsIMobileNetworkInfo> network = aNetwork;
// We release the ref after serializing process is finished in
// MobileConnectionIPCSerializer.
return SendRequest(aClientId, SelectNetworkRequest(network.forget().take()), aRequest);
}
NS_IMETHODIMP
MobileConnectionIPCService::SelectNetworkAutomatically(uint32_t aClientId,
nsIMobileConnectionCallback* aRequest)
{
return SendRequest(aClientId, SelectNetworkAutoRequest(), aRequest);
}
NS_IMETHODIMP
MobileConnectionIPCService::SetPreferredNetworkType(uint32_t aClientId,
const nsAString& aType,
nsIMobileConnectionCallback* aRequest)
{
return SendRequest(aClientId,
SetPreferredNetworkTypeRequest(nsAutoString(aType)),
aRequest);
}
NS_IMETHODIMP
MobileConnectionIPCService::GetPreferredNetworkType(uint32_t aClientId,
nsIMobileConnectionCallback* aRequest)
{
return SendRequest(aClientId, GetPreferredNetworkTypeRequest(), aRequest);
}
NS_IMETHODIMP
MobileConnectionIPCService::SetRoamingPreference(uint32_t aClientId,
const nsAString& aMode,
nsIMobileConnectionCallback* aRequest)
{
return SendRequest(aClientId,
SetRoamingPreferenceRequest(nsAutoString(aMode)),
aRequest);
}
NS_IMETHODIMP
MobileConnectionIPCService::GetRoamingPreference(uint32_t aClientId,
nsIMobileConnectionCallback* aRequest)
{
return SendRequest(aClientId, GetRoamingPreferenceRequest(), aRequest);
}
NS_IMETHODIMP
MobileConnectionIPCService::SetVoicePrivacyMode(uint32_t aClientId,
bool aEnabled,
nsIMobileConnectionCallback* aRequest)
{
return SendRequest(aClientId, SetVoicePrivacyModeRequest(aEnabled), aRequest);
}
NS_IMETHODIMP
MobileConnectionIPCService::GetVoicePrivacyMode(uint32_t aClientId,
nsIMobileConnectionCallback* aRequest)
{
return SendRequest(aClientId, GetVoicePrivacyModeRequest(), aRequest);
}
NS_IMETHODIMP
MobileConnectionIPCService::SendMMI(uint32_t aClientId,
const nsAString& aMmi,
nsIMobileConnectionCallback* aRequest)
{
return SendRequest(aClientId, SendMmiRequest(nsAutoString(aMmi)), aRequest);
}
NS_IMETHODIMP
MobileConnectionIPCService::CancelMMI(uint32_t aClientId,
nsIMobileConnectionCallback* aRequest)
{
return SendRequest(aClientId, CancelMmiRequest(), aRequest);
}
NS_IMETHODIMP
MobileConnectionIPCService::SetCallForwarding(uint32_t aClientId,
JS::Handle<JS::Value> aOptions,
nsIMobileConnectionCallback* aRequest)
{
AutoSafeJSContext cx;
IPC::MozCallForwardingOptions options;
if(!options.Init(cx, aOptions)) {
return NS_ERROR_TYPE_ERR;
}
return SendRequest(aClientId, SetCallForwardingRequest(options), aRequest);
}
NS_IMETHODIMP
MobileConnectionIPCService::GetCallForwarding(uint32_t aClientId,
uint16_t aReason,
nsIMobileConnectionCallback* aRequest)
{
return SendRequest(aClientId, GetCallForwardingRequest(aReason), aRequest);
}
NS_IMETHODIMP
MobileConnectionIPCService::SetCallBarring(uint32_t aClientId,
JS::Handle<JS::Value> aOptions,
nsIMobileConnectionCallback* aRequest)
{
AutoSafeJSContext cx;
IPC::MozCallBarringOptions options;
if(!options.Init(cx, aOptions)) {
return NS_ERROR_TYPE_ERR;
}
return SendRequest(aClientId, SetCallBarringRequest(options), aRequest);
}
NS_IMETHODIMP
MobileConnectionIPCService::GetCallBarring(uint32_t aClientId,
JS::Handle<JS::Value> aOptions,
nsIMobileConnectionCallback* aRequest)
{
AutoSafeJSContext cx;
IPC::MozCallBarringOptions options;
if(!options.Init(cx, aOptions)) {
return NS_ERROR_TYPE_ERR;
}
return SendRequest(aClientId, GetCallBarringRequest(options), aRequest);
}
NS_IMETHODIMP
MobileConnectionIPCService::ChangeCallBarringPassword(uint32_t aClientId,
JS::Handle<JS::Value> aOptions,
nsIMobileConnectionCallback* aRequest)
{
AutoSafeJSContext cx;
IPC::MozCallBarringOptions options;
if(!options.Init(cx, aOptions)) {
return NS_ERROR_TYPE_ERR;
}
return SendRequest(aClientId, ChangeCallBarringPasswordRequest(options), aRequest);
}
NS_IMETHODIMP
MobileConnectionIPCService::SetCallWaiting(uint32_t aClientId,
bool aEnabled,
nsIMobileConnectionCallback* aRequest)
{
return SendRequest(aClientId, SetCallWaitingRequest(aEnabled), aRequest);
}
NS_IMETHODIMP
MobileConnectionIPCService::GetCallWaiting(uint32_t aClientId,
nsIMobileConnectionCallback* aRequest)
{
return SendRequest(aClientId, GetCallWaitingRequest(), aRequest);
}
NS_IMETHODIMP
MobileConnectionIPCService::SetCallingLineIdRestriction(uint32_t aClientId,
uint16_t aMode,
nsIMobileConnectionCallback* aRequest)
{
return SendRequest(aClientId, SetCallingLineIdRestrictionRequest(aMode), aRequest);
}
NS_IMETHODIMP
MobileConnectionIPCService::GetCallingLineIdRestriction(uint32_t aClientId,
nsIMobileConnectionCallback* aRequest)
{
return SendRequest(aClientId, GetCallingLineIdRestrictionRequest(), aRequest);
}
NS_IMETHODIMP
MobileConnectionIPCService::ExitEmergencyCbMode(uint32_t aClientId,
nsIMobileConnectionCallback* aRequest)
{
return SendRequest(aClientId, ExitEmergencyCbModeRequest(), aRequest);
}
NS_IMETHODIMP
MobileConnectionIPCService::SetRadioEnabled(uint32_t aClientId,
bool aEnabled,
nsIMobileConnectionCallback* aRequest)
{
return SendRequest(aClientId, SetRadioEnabledRequest(aEnabled), aRequest);
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше