mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
9a431a3c46
- Bug 1054759 - Part 2: ES6 Symbol.unscopables. r=shu. (203f6a1c7a) - Bug 887016 - Part 6: Add RegExpPrototypeOptimizable. r=nbp (651d54bd7e) - Bug 887016 - Part 7: Add RegExpInstanceOptimizable. r=nbp (82701b3637) - Bug 887016 - Part 8: Add ObjectHasPrototype. r=nbp (8a9da8f9b8) - Bug 887016 - Part 9: Implement RegExp.prototype[@@match] and call it from String.prototype.match. r=till (9092676327) - Bug 887016 - Part 10: Implement RegExp.prototype[@@search] and call it from String.prototype.search. r=till (dcbd8beecb) - Bug 887016 - Part 11: Implement RegExp.prototype[@@replace] and call it from String.prototype.replace. r=h4writer,till (af2639291b) - Bug 887016 - Part 12: Implement RegExp[@@species] getter. r=evilpie,bholley (f512f802d9) - Bug 887016 - Part 13: Implement RegExp.prototype[@@split] and call it from String.prototype.split. r=h4writer,till (1fd28b046d) - Bug 887016 - Part 14: Add RegExpSearcher. r=h4writer (e5a02d6c03) - Bug 887016 - Part 15: Use RegExpSearcher in RegExp.prototype[@@replace] optimized path. r=till (4e04250fcc) - Bug 887016 - Part 16: Use RegExpSearcher in RegExp.prototype[@@searchâ] optimized path. r=till (742a1038f4) - Bug 887016 - Part 17: Mark sunspider/check-string-unpack-code.js timeout on cgc jittest. r=till (f80f8d69d5) - Bug 1251502 - Add a generic duplex resampler and a duplex WASAPI implementation. r=kinetik (5524ce1700) - Bug 1251502 - cubeb does not use cubeb-stdint.h anymore, remove it from moz.build. r=kinetik (76155cf9ee) - Bug 1259290: Part 1 - Remove unnecessary JS_ReportError calls. r=bz (1620f29a73) - Bug 1259290: Part 2 - Remove the cx from [Add|Remove]ChildWorker. r=bz (be70bd421e) - Bug 1259290: Part 3 - Remove JS_ReportError and cx handling from RegisterWorker and friends. r=bz,jandem (c646e0c7f3) - Bug 1259290: Part 4 - Remove JS_ReportError for a situation that can never happen. r=bz (ee012c8011) - Bug 1259290: Part 5 - Remove the cx from WorkerFeature::Notify. r=bz (79aff7ecb1) - Bug 1263490 - Part 1: Do not search for dollar if the length of replaceValue is 0 or 1. r=till (c88d75ff60) - Bug 1263341 - Check lastIndex in non-global replace. r=till (86d5e60a02) - Bug 1263851 - Check lastIndex after loop in RegExp.prototype[@@split]. r=till (70dc91fcf9) - Bug 1251529: In object metadata world, rename "object metadata" to "allocation metadata" and "callback" to "builder". r=fitzgen (fc8047d86d) - No bug - Add guards to tests that use TypedObject. r=me, a=bustage (87bda8c856) - Bug 1251922 - Do not create metadata objects for temporary parse globals; r=fitzgen (5b354f3cc4) - Bug 1251529: Replace allocation metadata callback with a builder class. r=fitzgen (520fb736fe) - Bug 1251529: Pass AutoEnterOOMUnsafeRegion to allocation metadata builder methods. r=fitzgen (6a2e6b05ac) - Bug 1251529: Provide default constructor for js::AllocationMetadataBuilder, js::SavedStacks::MetadataBuilder. r=shu (2300b6739c) - Bug 1251529: Provide default constructor for ShellAllocationMetadataBuilder. r=orange (24168aa011) - Bug 1259877 - Change js::DirectEval to take v/vp rather than a CallArgs to operate on directly. r=efaust (af03a24bde) - Bug 1259877 - Eliminate Invoke(JSContext*, const CallArgs&, MaybeConstruct = NO_CONSTRUCT) by 1) renaming it to a more-internal name, 2) adding an Invoke overload for existing InvokeArgs providers only, and 3) adding an InternalInvoke function to temporarily mark non-InvokeArgs places using the existing signature that will later be changed not to. r=efaust (7e4efa9129) - Bug 1259877 - Rename Invoke[GS]etter to Call[GS]etter, more in line with the spec's calling nomenclature. r=jorendorff (0b00a38913) - Bug 1259877 - Add CallFromStack for certain internal users, js::Call for general use, and mark js::Invoke as deprecated. r=efaust (56186b13fd) - Bug 1259877 - Add a bunch of Call overloads for 0/1/2 arguments with this as (HandleValue | JSObject*). r=jorendorff (ce764cca3a) - Bug 1259877 - Update Debugger code to use js::Call rather than Invoke. r=jorendorff (45f219d2f0) - Bug 1259877 - Update various miscellaneous function-calling code to js::Call. r=jandem (973c3c4171)
201 lines
4.8 KiB
C++
201 lines
4.8 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* 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/. */
|
|
|
|
#ifndef mozilla_dom_FileReader_h
|
|
#define mozilla_dom_FileReader_h
|
|
|
|
#include "mozilla/Attributes.h"
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
|
|
|
#include "nsIAsyncInputStream.h"
|
|
#include "nsIInterfaceRequestor.h"
|
|
#include "nsCOMPtr.h"
|
|
#include "nsString.h"
|
|
#include "nsWeakReference.h"
|
|
#include "WorkerFeature.h"
|
|
|
|
#define NS_PROGRESS_EVENT_INTERVAL 50
|
|
|
|
class nsITimer;
|
|
class nsIEventTarget;
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
class Blob;
|
|
class DOMError;
|
|
|
|
namespace workers {
|
|
class WorkerPrivate;
|
|
}
|
|
|
|
extern const uint64_t kUnknownSize;
|
|
|
|
class FileReaderDecreaseBusyCounter;
|
|
|
|
class FileReader final : public DOMEventTargetHelper,
|
|
public nsIInterfaceRequestor,
|
|
public nsSupportsWeakReference,
|
|
public nsIInputStreamCallback,
|
|
public nsITimerCallback,
|
|
public workers::WorkerFeature
|
|
{
|
|
friend class FileReaderDecreaseBusyCounter;
|
|
|
|
public:
|
|
FileReader(nsIGlobalObject* aGlobal,
|
|
workers::WorkerPrivate* aWorkerPrivate);
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_NSITIMERCALLBACK
|
|
NS_DECL_NSIINPUTSTREAMCALLBACK
|
|
NS_DECL_NSIINTERFACEREQUESTOR
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(FileReader,
|
|
DOMEventTargetHelper)
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
// WebIDL
|
|
static already_AddRefed<FileReader>
|
|
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
|
|
void ReadAsArrayBuffer(JSContext* aCx, Blob& aBlob, ErrorResult& aRv)
|
|
{
|
|
ReadFileContent(aBlob, EmptyString(), FILE_AS_ARRAYBUFFER, aRv);
|
|
}
|
|
|
|
void ReadAsText(Blob& aBlob, const nsAString& aLabel, ErrorResult& aRv)
|
|
{
|
|
ReadFileContent(aBlob, aLabel, FILE_AS_TEXT, aRv);
|
|
}
|
|
|
|
void ReadAsDataURL(Blob& aBlob, ErrorResult& aRv)
|
|
{
|
|
ReadFileContent(aBlob, EmptyString(), FILE_AS_DATAURL, aRv);
|
|
}
|
|
|
|
void Abort(ErrorResult& aRv);
|
|
|
|
uint16_t ReadyState() const
|
|
{
|
|
return static_cast<uint16_t>(mReadyState);
|
|
}
|
|
|
|
DOMError* GetError() const
|
|
{
|
|
return mError;
|
|
}
|
|
|
|
void GetResult(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
|
|
ErrorResult& aRv);
|
|
|
|
IMPL_EVENT_HANDLER(loadstart)
|
|
IMPL_EVENT_HANDLER(progress)
|
|
IMPL_EVENT_HANDLER(load)
|
|
IMPL_EVENT_HANDLER(abort)
|
|
IMPL_EVENT_HANDLER(error)
|
|
IMPL_EVENT_HANDLER(loadend)
|
|
|
|
void ReadAsBinaryString(Blob& aBlob, ErrorResult& aRv)
|
|
{
|
|
ReadFileContent(aBlob, EmptyString(), FILE_AS_BINARY, aRv);
|
|
}
|
|
|
|
// WorkerFeature
|
|
bool Notify(workers::Status) override;
|
|
|
|
private:
|
|
virtual ~FileReader();
|
|
|
|
// This must be in sync with dom/webidl/FileReader.webidl
|
|
enum eReadyState {
|
|
EMPTY = 0,
|
|
LOADING = 1,
|
|
DONE = 2
|
|
};
|
|
|
|
enum eDataFormat {
|
|
FILE_AS_ARRAYBUFFER,
|
|
FILE_AS_BINARY,
|
|
FILE_AS_TEXT,
|
|
FILE_AS_DATAURL
|
|
};
|
|
|
|
void RootResultArrayBuffer();
|
|
|
|
void ReadFileContent(Blob& aBlob,
|
|
const nsAString &aCharset, eDataFormat aDataFormat,
|
|
ErrorResult& aRv);
|
|
nsresult GetAsText(Blob *aBlob, const nsACString &aCharset,
|
|
const char *aFileData, uint32_t aDataLen,
|
|
nsAString &aResult);
|
|
nsresult GetAsDataURL(Blob *aBlob, const char *aFileData,
|
|
uint32_t aDataLen, nsAString &aResult);
|
|
|
|
nsresult OnLoadEnd(nsresult aStatus);
|
|
|
|
void StartProgressEventTimer();
|
|
void ClearProgressEventTimer();
|
|
void DispatchError(nsresult rv, nsAString& finalEvent);
|
|
nsresult DispatchProgressEvent(const nsAString& aType);
|
|
|
|
nsresult DoAsyncWait();
|
|
nsresult DoReadData(uint64_t aCount);
|
|
|
|
nsresult DoOnLoadEnd(nsresult aStatus, nsAString& aSuccessEvent,
|
|
nsAString& aTerminationEvent);
|
|
|
|
void FreeFileData()
|
|
{
|
|
moz_free(mFileData);
|
|
mFileData = nullptr;
|
|
mDataLen = 0;
|
|
}
|
|
|
|
nsresult IncreaseBusyCounter();
|
|
void DecreaseBusyCounter();
|
|
|
|
void Shutdown();
|
|
|
|
char *mFileData;
|
|
RefPtr<Blob> mBlob;
|
|
nsCString mCharset;
|
|
uint32_t mDataLen;
|
|
|
|
eDataFormat mDataFormat;
|
|
|
|
nsString mResult;
|
|
|
|
JS::Heap<JSObject*> mResultArrayBuffer;
|
|
|
|
nsCOMPtr<nsITimer> mProgressNotifier;
|
|
bool mProgressEventWasDelayed;
|
|
bool mTimerIsActive;
|
|
|
|
nsCOMPtr<nsIAsyncInputStream> mAsyncStream;
|
|
|
|
RefPtr<DOMError> mError;
|
|
|
|
eReadyState mReadyState;
|
|
|
|
uint64_t mTotal;
|
|
uint64_t mTransferred;
|
|
|
|
nsCOMPtr<nsIEventTarget> mTarget;
|
|
|
|
uint64_t mBusyCount;
|
|
|
|
// Kept alive with a WorkerFeature.
|
|
workers::WorkerPrivate* mWorkerPrivate;
|
|
};
|
|
|
|
} // dom namespace
|
|
} // mozilla namespace
|
|
|
|
#endif // mozilla_dom_FileReader_h
|