2012-09-20 19:47:47 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2011-08-15 20:40:38 -07:00
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
2012-05-21 04:12:37 -07: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-15 20:40:38 -07:00
|
|
|
|
|
|
|
#ifndef mozilla_dom_workers_filereadersync_h__
|
|
|
|
#define mozilla_dom_workers_filereadersync_h__
|
|
|
|
|
|
|
|
#include "Workers.h"
|
2012-09-20 19:47:47 -07:00
|
|
|
#include "mozilla/dom/workers/bindings/DOMBindingBase.h"
|
2011-08-15 20:40:38 -07:00
|
|
|
|
2012-09-20 19:47:47 -07:00
|
|
|
#include "nsICharsetDetectionObserver.h"
|
|
|
|
#include "nsStringGlue.h"
|
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "mozilla/dom/BindingUtils.h"
|
|
|
|
|
|
|
|
class nsIInputStream;
|
|
|
|
class nsIDOMBlob;
|
2011-08-15 20:40:38 -07:00
|
|
|
|
|
|
|
BEGIN_WORKERS_NAMESPACE
|
|
|
|
|
2012-09-20 19:47:47 -07:00
|
|
|
class FileReaderSync MOZ_FINAL : public DOMBindingBase,
|
|
|
|
public nsICharsetDetectionObserver
|
|
|
|
{
|
|
|
|
nsCString mCharset;
|
|
|
|
nsresult ConvertStream(nsIInputStream *aStream, const char *aCharset,
|
|
|
|
nsAString &aResult);
|
|
|
|
nsresult GuessCharset(nsIInputStream *aStream, nsACString &aCharset);
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual void
|
|
|
|
_trace(JSTracer* aTrc) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
_finalize(JSFreeOp* aFop) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
static FileReaderSync*
|
2013-08-22 22:17:08 -07:00
|
|
|
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
|
2012-09-20 19:47:47 -07:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
FileReaderSync(JSContext* aCx);
|
2011-08-15 20:40:38 -07:00
|
|
|
|
2013-05-16 09:36:55 -07:00
|
|
|
JSObject* ReadAsArrayBuffer(JSContext* aCx, JS::Handle<JSObject*> aBlob,
|
2012-09-20 19:47:47 -07:00
|
|
|
ErrorResult& aRv);
|
2013-05-16 09:36:55 -07:00
|
|
|
void ReadAsBinaryString(JS::Handle<JSObject*> aBlob, nsAString& aResult,
|
2012-09-20 19:47:47 -07:00
|
|
|
ErrorResult& aRv);
|
2013-05-16 09:36:55 -07:00
|
|
|
void ReadAsText(JS::Handle<JSObject*> aBlob,
|
|
|
|
const Optional<nsAString>& aEncoding,
|
2012-09-20 19:47:47 -07:00
|
|
|
nsAString& aResult, ErrorResult& aRv);
|
2013-05-16 09:36:55 -07:00
|
|
|
void ReadAsDataURL(JS::Handle<JSObject*> aBlob, nsAString& aResult,
|
|
|
|
ErrorResult& aRv);
|
2011-08-15 20:40:38 -07:00
|
|
|
|
2012-09-20 19:47:47 -07:00
|
|
|
// From nsICharsetDetectionObserver
|
2013-06-05 09:15:48 -07:00
|
|
|
NS_IMETHOD Notify(const char *aCharset, nsDetectionConfident aConf) MOZ_OVERRIDE;
|
2012-09-20 19:47:47 -07:00
|
|
|
};
|
2011-08-15 20:40:38 -07:00
|
|
|
|
|
|
|
END_WORKERS_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_workers_filereadersync_h__
|