2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-09-21 08:16:37 +04:00
|
|
|
|
|
|
|
#ifndef dom_src_geolocation_IPC_serialiser
|
|
|
|
#define dom_src_geolocation_IPC_serialiser
|
|
|
|
|
2012-08-28 16:41:04 +04:00
|
|
|
#include "ipc/IPCMessageUtils.h"
|
2010-09-21 08:16:37 +04:00
|
|
|
#include "nsGeoPosition.h"
|
|
|
|
#include "nsIDOMGeoPosition.h"
|
|
|
|
|
|
|
|
namespace IPC {
|
|
|
|
|
|
|
|
template <>
|
Bug 1443954 - Part 3: Add support for RefCounted types to IPDL, r=bz,froydnj,baku
This patch was reviewed in parts, however the intermediate states would not build:
Bug 1443954 - Part 3A: Strip pointers from the argument to WriteParam and WriteIPDLParam before selecting the ParamTraits impl, r=froydnj
Bug 1443954 - Part 3B: Move nsIAlertNotification serialization to the refcounted system, r=bz
Bug 1443954 - Part 3C: Move geolocation serialization to the refcounted system, r=bz
Bug 1443954 - Part 3D: Move nsIInputStream serialization to the refcounted system, r=baku
Bug 1443954 - Part 3E: Move BlobImpl serialization to the refcounted system, r=baku
Bug 1443954 - Part 3F: Correctly implement ParamTraits for actors after the ParamTraits changes, r=froydnj
2018-03-07 04:14:59 +03:00
|
|
|
struct ParamTraits<nsIDOMGeoPositionCoords>
|
2010-09-21 08:16:37 +04:00
|
|
|
{
|
|
|
|
// Function to serialize a geoposition
|
Bug 1443954 - Part 3: Add support for RefCounted types to IPDL, r=bz,froydnj,baku
This patch was reviewed in parts, however the intermediate states would not build:
Bug 1443954 - Part 3A: Strip pointers from the argument to WriteParam and WriteIPDLParam before selecting the ParamTraits impl, r=froydnj
Bug 1443954 - Part 3B: Move nsIAlertNotification serialization to the refcounted system, r=bz
Bug 1443954 - Part 3C: Move geolocation serialization to the refcounted system, r=bz
Bug 1443954 - Part 3D: Move nsIInputStream serialization to the refcounted system, r=baku
Bug 1443954 - Part 3E: Move BlobImpl serialization to the refcounted system, r=baku
Bug 1443954 - Part 3F: Correctly implement ParamTraits for actors after the ParamTraits changes, r=froydnj
2018-03-07 04:14:59 +03:00
|
|
|
static void Write(Message *aMsg, nsIDOMGeoPositionCoords* aParam)
|
2010-09-21 08:16:37 +04:00
|
|
|
{
|
|
|
|
bool isNull = !aParam;
|
|
|
|
WriteParam(aMsg, isNull);
|
|
|
|
// If it is a null object, then we are done
|
|
|
|
if (isNull) return;
|
|
|
|
|
|
|
|
double coordData;
|
|
|
|
|
|
|
|
aParam->GetLatitude(&coordData);
|
|
|
|
WriteParam(aMsg, coordData);
|
|
|
|
|
|
|
|
aParam->GetLongitude(&coordData);
|
|
|
|
WriteParam(aMsg, coordData);
|
|
|
|
|
|
|
|
aParam->GetAltitude(&coordData);
|
|
|
|
WriteParam(aMsg, coordData);
|
|
|
|
|
|
|
|
aParam->GetAccuracy(&coordData);
|
|
|
|
WriteParam(aMsg, coordData);
|
|
|
|
|
|
|
|
aParam->GetAltitudeAccuracy(&coordData);
|
|
|
|
WriteParam(aMsg, coordData);
|
|
|
|
|
|
|
|
aParam->GetHeading(&coordData);
|
|
|
|
WriteParam(aMsg, coordData);
|
|
|
|
|
|
|
|
aParam->GetSpeed(&coordData);
|
|
|
|
WriteParam(aMsg, coordData);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Function to de-serialize a geoposition
|
Bug 1443954 - Part 3: Add support for RefCounted types to IPDL, r=bz,froydnj,baku
This patch was reviewed in parts, however the intermediate states would not build:
Bug 1443954 - Part 3A: Strip pointers from the argument to WriteParam and WriteIPDLParam before selecting the ParamTraits impl, r=froydnj
Bug 1443954 - Part 3B: Move nsIAlertNotification serialization to the refcounted system, r=bz
Bug 1443954 - Part 3C: Move geolocation serialization to the refcounted system, r=bz
Bug 1443954 - Part 3D: Move nsIInputStream serialization to the refcounted system, r=baku
Bug 1443954 - Part 3E: Move BlobImpl serialization to the refcounted system, r=baku
Bug 1443954 - Part 3F: Correctly implement ParamTraits for actors after the ParamTraits changes, r=froydnj
2018-03-07 04:14:59 +03:00
|
|
|
static bool Read(const Message* aMsg, PickleIterator* aIter,
|
|
|
|
RefPtr<nsIDOMGeoPositionCoords>* aResult)
|
2010-09-21 08:16:37 +04:00
|
|
|
{
|
|
|
|
// Check if it is the null pointer we have transfered
|
|
|
|
bool isNull;
|
|
|
|
if (!ReadParam(aMsg, aIter, &isNull)) return false;
|
|
|
|
|
|
|
|
if (isNull) {
|
Bug 1443954 - Part 3: Add support for RefCounted types to IPDL, r=bz,froydnj,baku
This patch was reviewed in parts, however the intermediate states would not build:
Bug 1443954 - Part 3A: Strip pointers from the argument to WriteParam and WriteIPDLParam before selecting the ParamTraits impl, r=froydnj
Bug 1443954 - Part 3B: Move nsIAlertNotification serialization to the refcounted system, r=bz
Bug 1443954 - Part 3C: Move geolocation serialization to the refcounted system, r=bz
Bug 1443954 - Part 3D: Move nsIInputStream serialization to the refcounted system, r=baku
Bug 1443954 - Part 3E: Move BlobImpl serialization to the refcounted system, r=baku
Bug 1443954 - Part 3F: Correctly implement ParamTraits for actors after the ParamTraits changes, r=froydnj
2018-03-07 04:14:59 +03:00
|
|
|
*aResult = nullptr;
|
2010-09-21 08:16:37 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
double latitude;
|
|
|
|
double longitude;
|
|
|
|
double altitude;
|
|
|
|
double accuracy;
|
|
|
|
double altitudeAccuracy;
|
|
|
|
double heading;
|
|
|
|
double speed;
|
|
|
|
|
|
|
|
// It's not important to us where it fails, but rather if it fails
|
|
|
|
if (!( ReadParam(aMsg, aIter, &latitude )
|
|
|
|
&& ReadParam(aMsg, aIter, &longitude )
|
|
|
|
&& ReadParam(aMsg, aIter, &altitude )
|
|
|
|
&& ReadParam(aMsg, aIter, &accuracy )
|
|
|
|
&& ReadParam(aMsg, aIter, &altitudeAccuracy )
|
|
|
|
&& ReadParam(aMsg, aIter, &heading )
|
|
|
|
&& ReadParam(aMsg, aIter, &speed ))) return false;
|
|
|
|
|
|
|
|
// We now have all the data
|
|
|
|
*aResult = new nsGeoPositionCoords(latitude, /* aLat */
|
|
|
|
longitude, /* aLong */
|
|
|
|
altitude, /* aAlt */
|
|
|
|
accuracy, /* aHError */
|
|
|
|
altitudeAccuracy, /* aVError */
|
|
|
|
heading, /* aHeading */
|
|
|
|
speed /* aSpeed */
|
|
|
|
);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
Bug 1443954 - Part 3: Add support for RefCounted types to IPDL, r=bz,froydnj,baku
This patch was reviewed in parts, however the intermediate states would not build:
Bug 1443954 - Part 3A: Strip pointers from the argument to WriteParam and WriteIPDLParam before selecting the ParamTraits impl, r=froydnj
Bug 1443954 - Part 3B: Move nsIAlertNotification serialization to the refcounted system, r=bz
Bug 1443954 - Part 3C: Move geolocation serialization to the refcounted system, r=bz
Bug 1443954 - Part 3D: Move nsIInputStream serialization to the refcounted system, r=baku
Bug 1443954 - Part 3E: Move BlobImpl serialization to the refcounted system, r=baku
Bug 1443954 - Part 3F: Correctly implement ParamTraits for actors after the ParamTraits changes, r=froydnj
2018-03-07 04:14:59 +03:00
|
|
|
struct ParamTraits<nsIDOMGeoPosition>
|
2010-09-21 08:16:37 +04:00
|
|
|
{
|
|
|
|
// Function to serialize a geoposition
|
Bug 1443954 - Part 3: Add support for RefCounted types to IPDL, r=bz,froydnj,baku
This patch was reviewed in parts, however the intermediate states would not build:
Bug 1443954 - Part 3A: Strip pointers from the argument to WriteParam and WriteIPDLParam before selecting the ParamTraits impl, r=froydnj
Bug 1443954 - Part 3B: Move nsIAlertNotification serialization to the refcounted system, r=bz
Bug 1443954 - Part 3C: Move geolocation serialization to the refcounted system, r=bz
Bug 1443954 - Part 3D: Move nsIInputStream serialization to the refcounted system, r=baku
Bug 1443954 - Part 3E: Move BlobImpl serialization to the refcounted system, r=baku
Bug 1443954 - Part 3F: Correctly implement ParamTraits for actors after the ParamTraits changes, r=froydnj
2018-03-07 04:14:59 +03:00
|
|
|
static void Write(Message *aMsg, nsIDOMGeoPosition* aParam)
|
2010-09-21 08:16:37 +04:00
|
|
|
{
|
|
|
|
bool isNull = !aParam;
|
|
|
|
WriteParam(aMsg, isNull);
|
|
|
|
// If it is a null object, then we are done
|
|
|
|
if (isNull) return;
|
|
|
|
|
|
|
|
DOMTimeStamp timeStamp;
|
|
|
|
aParam->GetTimestamp(&timeStamp);
|
|
|
|
WriteParam(aMsg, timeStamp);
|
|
|
|
|
2010-12-15 15:57:00 +03:00
|
|
|
nsCOMPtr<nsIDOMGeoPositionCoords> coords;
|
2010-09-21 08:16:37 +04:00
|
|
|
aParam->GetCoords(getter_AddRefs(coords));
|
Bug 1443954 - Part 3: Add support for RefCounted types to IPDL, r=bz,froydnj,baku
This patch was reviewed in parts, however the intermediate states would not build:
Bug 1443954 - Part 3A: Strip pointers from the argument to WriteParam and WriteIPDLParam before selecting the ParamTraits impl, r=froydnj
Bug 1443954 - Part 3B: Move nsIAlertNotification serialization to the refcounted system, r=bz
Bug 1443954 - Part 3C: Move geolocation serialization to the refcounted system, r=bz
Bug 1443954 - Part 3D: Move nsIInputStream serialization to the refcounted system, r=baku
Bug 1443954 - Part 3E: Move BlobImpl serialization to the refcounted system, r=baku
Bug 1443954 - Part 3F: Correctly implement ParamTraits for actors after the ParamTraits changes, r=froydnj
2018-03-07 04:14:59 +03:00
|
|
|
WriteParam(aMsg, coords);
|
2010-09-21 08:16:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Function to de-serialize a geoposition
|
Bug 1443954 - Part 3: Add support for RefCounted types to IPDL, r=bz,froydnj,baku
This patch was reviewed in parts, however the intermediate states would not build:
Bug 1443954 - Part 3A: Strip pointers from the argument to WriteParam and WriteIPDLParam before selecting the ParamTraits impl, r=froydnj
Bug 1443954 - Part 3B: Move nsIAlertNotification serialization to the refcounted system, r=bz
Bug 1443954 - Part 3C: Move geolocation serialization to the refcounted system, r=bz
Bug 1443954 - Part 3D: Move nsIInputStream serialization to the refcounted system, r=baku
Bug 1443954 - Part 3E: Move BlobImpl serialization to the refcounted system, r=baku
Bug 1443954 - Part 3F: Correctly implement ParamTraits for actors after the ParamTraits changes, r=froydnj
2018-03-07 04:14:59 +03:00
|
|
|
static bool Read(const Message* aMsg, PickleIterator* aIter,
|
|
|
|
RefPtr<nsIDOMGeoPosition>* aResult)
|
2010-09-21 08:16:37 +04:00
|
|
|
{
|
|
|
|
// Check if it is the null pointer we have transfered
|
|
|
|
bool isNull;
|
|
|
|
if (!ReadParam(aMsg, aIter, &isNull)) return false;
|
|
|
|
|
|
|
|
if (isNull) {
|
Bug 1443954 - Part 3: Add support for RefCounted types to IPDL, r=bz,froydnj,baku
This patch was reviewed in parts, however the intermediate states would not build:
Bug 1443954 - Part 3A: Strip pointers from the argument to WriteParam and WriteIPDLParam before selecting the ParamTraits impl, r=froydnj
Bug 1443954 - Part 3B: Move nsIAlertNotification serialization to the refcounted system, r=bz
Bug 1443954 - Part 3C: Move geolocation serialization to the refcounted system, r=bz
Bug 1443954 - Part 3D: Move nsIInputStream serialization to the refcounted system, r=baku
Bug 1443954 - Part 3E: Move BlobImpl serialization to the refcounted system, r=baku
Bug 1443954 - Part 3F: Correctly implement ParamTraits for actors after the ParamTraits changes, r=froydnj
2018-03-07 04:14:59 +03:00
|
|
|
*aResult = nullptr;
|
2010-09-21 08:16:37 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMTimeStamp timeStamp;
|
Bug 1443954 - Part 3: Add support for RefCounted types to IPDL, r=bz,froydnj,baku
This patch was reviewed in parts, however the intermediate states would not build:
Bug 1443954 - Part 3A: Strip pointers from the argument to WriteParam and WriteIPDLParam before selecting the ParamTraits impl, r=froydnj
Bug 1443954 - Part 3B: Move nsIAlertNotification serialization to the refcounted system, r=bz
Bug 1443954 - Part 3C: Move geolocation serialization to the refcounted system, r=bz
Bug 1443954 - Part 3D: Move nsIInputStream serialization to the refcounted system, r=baku
Bug 1443954 - Part 3E: Move BlobImpl serialization to the refcounted system, r=baku
Bug 1443954 - Part 3F: Correctly implement ParamTraits for actors after the ParamTraits changes, r=froydnj
2018-03-07 04:14:59 +03:00
|
|
|
RefPtr<nsIDOMGeoPositionCoords> coords;
|
2010-09-21 08:16:37 +04:00
|
|
|
|
|
|
|
// It's not important to us where it fails, but rather if it fails
|
2013-01-07 09:57:00 +04:00
|
|
|
if (!ReadParam(aMsg, aIter, &timeStamp) ||
|
|
|
|
!ReadParam(aMsg, aIter, &coords)) {
|
|
|
|
return false;
|
|
|
|
}
|
2010-09-21 08:16:37 +04:00
|
|
|
|
2012-03-09 10:16:25 +04:00
|
|
|
*aResult = new nsGeoPosition(coords, timeStamp);
|
2010-09-21 08:16:37 +04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace IPC
|
2010-09-21 08:16:37 +04:00
|
|
|
|
|
|
|
#endif
|