2012-07-28 04:21:34 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=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_file_domarchiverequest_h__
|
|
|
|
#define mozilla_dom_file_domarchiverequest_h__
|
|
|
|
|
2013-06-05 20:15:48 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-07-28 04:21:34 +04:00
|
|
|
#include "ArchiveReader.h"
|
|
|
|
#include "DOMRequest.h"
|
|
|
|
|
|
|
|
#include "FileCommon.h"
|
|
|
|
|
2014-03-18 08:48:19 +04:00
|
|
|
namespace mozilla {
|
|
|
|
class EventChainPreVisitor;
|
|
|
|
} // namespace mozilla
|
2012-07-28 04:21:34 +04:00
|
|
|
|
|
|
|
BEGIN_FILE_NAMESPACE
|
|
|
|
|
2012-11-07 03:23:13 +04:00
|
|
|
/**
|
|
|
|
* This is the ArchiveRequest that handles any operation
|
|
|
|
* related to ArchiveReader
|
|
|
|
*/
|
2013-03-17 12:51:36 +04:00
|
|
|
class ArchiveRequest : public mozilla::dom::DOMRequest
|
2012-07-28 04:21:34 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-04-09 02:27:18 +04:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
2013-03-17 12:51:36 +04:00
|
|
|
|
|
|
|
ArchiveReader* Reader() const;
|
|
|
|
|
2012-11-07 03:23:13 +04:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2012-07-28 04:21:34 +04:00
|
|
|
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ArchiveRequest, DOMRequest)
|
|
|
|
|
2014-01-07 06:53:23 +04:00
|
|
|
ArchiveRequest(nsPIDOMWindow* aWindow,
|
2012-07-28 04:21:34 +04:00
|
|
|
ArchiveReader* aReader);
|
|
|
|
|
|
|
|
// nsIDOMEventTarget
|
2014-03-18 08:48:19 +04:00
|
|
|
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
|
2012-07-28 04:21:34 +04:00
|
|
|
|
|
|
|
public:
|
|
|
|
// This is called by the DOMArchiveRequestEvent
|
|
|
|
void Run();
|
|
|
|
|
|
|
|
// Set the types for this request
|
|
|
|
void OpGetFilenames();
|
|
|
|
void OpGetFile(const nsAString& aFilename);
|
2012-11-07 03:23:13 +04:00
|
|
|
void OpGetFiles();
|
2012-07-28 04:21:34 +04:00
|
|
|
|
|
|
|
nsresult ReaderReady(nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList,
|
|
|
|
nsresult aStatus);
|
|
|
|
|
|
|
|
public: // static
|
2014-01-07 06:53:23 +04:00
|
|
|
static already_AddRefed<ArchiveRequest> Create(nsPIDOMWindow* aOwner,
|
2012-07-28 04:21:34 +04:00
|
|
|
ArchiveReader* aReader);
|
|
|
|
|
|
|
|
private:
|
|
|
|
~ArchiveRequest();
|
|
|
|
|
|
|
|
nsresult GetFilenamesResult(JSContext* aCx,
|
2012-11-07 03:23:13 +04:00
|
|
|
JS::Value* aValue,
|
2012-07-28 04:21:34 +04:00
|
|
|
nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList);
|
|
|
|
nsresult GetFileResult(JSContext* aCx,
|
2013-10-12 09:02:39 +04:00
|
|
|
JS::MutableHandle<JS::Value> aValue,
|
2012-07-28 04:21:34 +04:00
|
|
|
nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList);
|
2012-11-07 03:23:13 +04:00
|
|
|
nsresult GetFilesResult(JSContext* aCx,
|
2013-10-12 09:02:39 +04:00
|
|
|
JS::MutableHandle<JS::Value> aValue,
|
2012-11-07 03:23:13 +04:00
|
|
|
nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList);
|
2012-07-28 04:21:34 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// The reader:
|
|
|
|
nsRefPtr<ArchiveReader> mArchiveReader;
|
|
|
|
|
|
|
|
// The operation:
|
|
|
|
enum {
|
|
|
|
GetFilenames,
|
2012-11-07 03:23:13 +04:00
|
|
|
GetFile,
|
|
|
|
GetFiles
|
2012-07-28 04:21:34 +04:00
|
|
|
} mOperation;
|
|
|
|
|
|
|
|
// The filename (needed by GetFile):
|
|
|
|
nsString mFilename;
|
|
|
|
};
|
|
|
|
|
|
|
|
END_FILE_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_file_domarchiverequest_h__
|