dom/ipc/StructuredCloneUtils.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/ipc/StructuredCloneUtils.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,58 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* vim: set sw=4 ts=8 et tw=80 : */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef mozilla_dom_StructuredCloneUtils_h
    1.11 +#define mozilla_dom_StructuredCloneUtils_h
    1.12 +
    1.13 +#include "nsCOMPtr.h"
    1.14 +#include "nsTArray.h"
    1.15 +#include "nsIDOMFile.h"
    1.16 +
    1.17 +#include "js/StructuredClone.h"
    1.18 +
    1.19 +namespace mozilla {
    1.20 +
    1.21 +struct SerializedStructuredCloneBuffer;
    1.22 +
    1.23 +namespace dom {
    1.24 +
    1.25 +struct
    1.26 +StructuredCloneClosure
    1.27 +{
    1.28 +  nsTArray<nsCOMPtr<nsIDOMBlob> > mBlobs;
    1.29 +};
    1.30 +
    1.31 +struct
    1.32 +StructuredCloneData
    1.33 +{
    1.34 +  StructuredCloneData() : mData(nullptr), mDataLength(0) {}
    1.35 +  uint64_t* mData;
    1.36 +  size_t mDataLength;
    1.37 +  StructuredCloneClosure mClosure;
    1.38 +};
    1.39 +
    1.40 +bool
    1.41 +ReadStructuredClone(JSContext* aCx, uint64_t* aData, size_t aDataLength,
    1.42 +                    const StructuredCloneClosure& aClosure,
    1.43 +                    JS::MutableHandle<JS::Value> aClone);
    1.44 +
    1.45 +inline bool
    1.46 +ReadStructuredClone(JSContext* aCx, const StructuredCloneData& aData,
    1.47 +                    JS::MutableHandle<JS::Value> aClone)
    1.48 +{
    1.49 +  return ReadStructuredClone(aCx, aData.mData, aData.mDataLength,
    1.50 +                             aData.mClosure, aClone);
    1.51 +}
    1.52 +
    1.53 +bool
    1.54 +WriteStructuredClone(JSContext* aCx, JS::Handle<JS::Value> aSource,
    1.55 +                     JSAutoStructuredCloneBuffer& aBuffer,
    1.56 +                     StructuredCloneClosure& aClosure);
    1.57 +
    1.58 +} // namespace dom
    1.59 +} // namespace mozilla
    1.60 +
    1.61 +#endif // mozilla_dom_StructuredCloneUtils_h

mercurial