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/. */
|
2011-08-16 07:40:38 +04:00
|
|
|
|
2016-03-16 21:51:11 +03:00
|
|
|
#ifndef mozilla_dom_filereadersync_h__
|
|
|
|
#define mozilla_dom_filereadersync_h__
|
2011-08-16 07:40:38 +04:00
|
|
|
|
2018-01-31 10:25:30 +03:00
|
|
|
#include "mozilla/dom/WorkerCommon.h"
|
2020-11-23 19:21:38 +03:00
|
|
|
#include "nsISupports.h"
|
2011-08-16 07:40:38 +04:00
|
|
|
|
2012-09-21 06:47:47 +04:00
|
|
|
class nsIInputStream;
|
2011-08-16 07:40:38 +04:00
|
|
|
|
2013-09-06 10:43:26 +04:00
|
|
|
namespace mozilla {
|
|
|
|
class ErrorResult;
|
|
|
|
|
|
|
|
namespace dom {
|
2015-05-12 15:09:51 +03:00
|
|
|
class Blob;
|
2013-09-06 10:43:26 +04:00
|
|
|
class GlobalObject;
|
|
|
|
template <typename>
|
|
|
|
class Optional;
|
2011-08-16 07:40:38 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class FileReaderSync final {
|
2013-12-17 14:47:25 +04:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(FileReaderSync)
|
|
|
|
|
2014-04-02 20:21:03 +04:00
|
|
|
private:
|
|
|
|
// Private destructor, to discourage deletion outside of Release():
|
2020-02-20 19:11:24 +03:00
|
|
|
~FileReaderSync() = default;
|
2014-04-02 20:21:03 +04:00
|
|
|
|
2012-09-21 06:47:47 +04:00
|
|
|
nsresult ConvertStream(nsIInputStream* aStream, const char* aCharset,
|
|
|
|
nsAString& aResult);
|
|
|
|
|
2017-09-08 12:23:02 +03:00
|
|
|
nsresult ConvertAsyncToSyncStream(
|
2017-10-19 12:39:30 +03:00
|
|
|
uint64_t aStreamSize, already_AddRefed<nsIInputStream> aAsyncStream,
|
2017-05-09 12:04:07 +03:00
|
|
|
nsIInputStream** aSyncStream);
|
|
|
|
|
2017-05-09 12:03:40 +03:00
|
|
|
nsresult SyncRead(nsIInputStream* aStream, char* aBuffer,
|
2020-03-18 12:46:38 +03:00
|
|
|
uint32_t aBufferSize, uint32_t* aTotalBytesRead);
|
2017-04-25 23:23:46 +03:00
|
|
|
|
2012-09-21 06:47:47 +04:00
|
|
|
public:
|
2013-09-30 08:15:37 +04:00
|
|
|
static already_AddRefed<FileReaderSync> Constructor(
|
2019-09-12 14:01:17 +03:00
|
|
|
const GlobalObject& aGlobal);
|
2012-09-21 06:47:47 +04:00
|
|
|
|
Bug 1117172 part 2. Change the non-wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, Codegen.py, and
StructuredClone.cpp. The rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/WrapObject\((JSContext *\* *(?:aCx|cx)),(\s*)(JS::MutableHandle<JSObject\*> aReflector)/WrapObject(\1,\2JS::Handle<JSObject*> aGivenProto,\2\3/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx)), this, aReflector/\1, this, aGivenProto, aReflector/'
2015-03-19 17:13:32 +03:00
|
|
|
bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto,
|
|
|
|
JS::MutableHandle<JSObject*> aReflector);
|
2012-09-21 06:47:47 +04:00
|
|
|
|
2014-06-12 00:26:52 +04:00
|
|
|
void ReadAsArrayBuffer(JSContext* aCx, JS::Handle<JSObject*> aScopeObj,
|
2015-05-12 15:09:51 +03:00
|
|
|
Blob& aBlob, JS::MutableHandle<JSObject*> aRetval,
|
2014-06-12 00:26:52 +04:00
|
|
|
ErrorResult& aRv);
|
2015-05-12 15:09:51 +03:00
|
|
|
void ReadAsBinaryString(Blob& aBlob, nsAString& aResult, ErrorResult& aRv);
|
|
|
|
void ReadAsText(Blob& aBlob, const Optional<nsAString>& aEncoding,
|
2012-09-21 06:47:47 +04:00
|
|
|
nsAString& aResult, ErrorResult& aRv);
|
2015-05-12 15:09:51 +03:00
|
|
|
void ReadAsDataURL(Blob& aBlob, nsAString& aResult, ErrorResult& aRv);
|
2012-09-21 06:47:47 +04:00
|
|
|
};
|
2011-08-16 07:40:38 +04:00
|
|
|
|
2016-03-16 21:51:11 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2011-08-16 07:40:38 +04:00
|
|
|
|
2016-03-16 21:51:11 +03:00
|
|
|
#endif // mozilla_dom_filereadersync_h__
|