2012-07-28 00:21:34 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-05-03 19:32:37 +00:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-07-28 00:21:34 +00: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/. */
|
|
|
|
|
2014-05-07 14:32:12 +00:00
|
|
|
#ifndef mozilla_dom_archivereader_domarchiverequest_h__
|
|
|
|
#define mozilla_dom_archivereader_domarchiverequest_h__
|
2012-07-28 00:21:34 +00:00
|
|
|
|
2013-06-05 16:15:48 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-07-28 00:21:34 +00:00
|
|
|
#include "ArchiveReader.h"
|
|
|
|
#include "DOMRequest.h"
|
|
|
|
|
2014-05-07 14:32:12 +00:00
|
|
|
#include "ArchiveReaderCommon.h"
|
2012-07-28 00:21:34 +00:00
|
|
|
|
2014-03-18 04:48:19 +00:00
|
|
|
namespace mozilla {
|
|
|
|
class EventChainPreVisitor;
|
|
|
|
} // namespace mozilla
|
2012-07-28 00:21:34 +00:00
|
|
|
|
2014-05-07 14:32:12 +00:00
|
|
|
BEGIN_ARCHIVEREADER_NAMESPACE
|
2012-07-28 00:21:34 +00:00
|
|
|
|
2012-11-06 23:23:13 +00:00
|
|
|
/**
|
|
|
|
* This is the ArchiveRequest that handles any operation
|
|
|
|
* related to ArchiveReader
|
|
|
|
*/
|
2013-03-17 08:51:36 +00:00
|
|
|
class ArchiveRequest : public mozilla::dom::DOMRequest
|
2012-07-28 00:21:34 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-03-17 08:51:36 +00:00
|
|
|
|
|
|
|
ArchiveReader* Reader() const;
|
|
|
|
|
2012-11-06 23:23:13 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2012-07-28 00:21:34 +00:00
|
|
|
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ArchiveRequest, DOMRequest)
|
|
|
|
|
2014-01-07 02:53:23 +00:00
|
|
|
ArchiveRequest(nsPIDOMWindow* aWindow,
|
2012-07-28 00:21:34 +00:00
|
|
|
ArchiveReader* aReader);
|
|
|
|
|
|
|
|
// nsIDOMEventTarget
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) override;
|
2012-07-28 00:21:34 +00: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-06 23:23:13 +00:00
|
|
|
void OpGetFiles();
|
2012-07-28 00:21:34 +00:00
|
|
|
|
2015-05-12 12:09:51 +00:00
|
|
|
nsresult ReaderReady(nsTArray<nsRefPtr<File>>& aFileList, nsresult aStatus);
|
2012-07-28 00:21:34 +00:00
|
|
|
|
|
|
|
public: // static
|
2014-01-07 02:53:23 +00:00
|
|
|
static already_AddRefed<ArchiveRequest> Create(nsPIDOMWindow* aOwner,
|
2012-07-28 00:21:34 +00:00
|
|
|
ArchiveReader* aReader);
|
|
|
|
|
|
|
|
private:
|
|
|
|
~ArchiveRequest();
|
|
|
|
|
|
|
|
nsresult GetFilenamesResult(JSContext* aCx,
|
2012-11-06 23:23:13 +00:00
|
|
|
JS::Value* aValue,
|
2015-05-12 12:09:51 +00:00
|
|
|
nsTArray<nsRefPtr<File>>& aFileList);
|
2012-07-28 00:21:34 +00:00
|
|
|
nsresult GetFileResult(JSContext* aCx,
|
2013-10-12 05:02:39 +00:00
|
|
|
JS::MutableHandle<JS::Value> aValue,
|
2015-05-12 12:09:51 +00:00
|
|
|
nsTArray<nsRefPtr<File>>& aFileList);
|
2012-11-06 23:23:13 +00:00
|
|
|
nsresult GetFilesResult(JSContext* aCx,
|
2013-10-12 05:02:39 +00:00
|
|
|
JS::MutableHandle<JS::Value> aValue,
|
2015-05-12 12:09:51 +00:00
|
|
|
nsTArray<nsRefPtr<File>>& aFileList);
|
2012-07-28 00:21:34 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// The reader:
|
|
|
|
nsRefPtr<ArchiveReader> mArchiveReader;
|
|
|
|
|
|
|
|
// The operation:
|
|
|
|
enum {
|
|
|
|
GetFilenames,
|
2012-11-06 23:23:13 +00:00
|
|
|
GetFile,
|
|
|
|
GetFiles
|
2012-07-28 00:21:34 +00:00
|
|
|
} mOperation;
|
|
|
|
|
|
|
|
// The filename (needed by GetFile):
|
|
|
|
nsString mFilename;
|
|
|
|
};
|
|
|
|
|
2014-05-07 14:32:12 +00:00
|
|
|
END_ARCHIVEREADER_NAMESPACE
|
2012-07-28 00:21:34 +00:00
|
|
|
|
2014-05-07 14:32:12 +00:00
|
|
|
#endif // mozilla_dom_archivereader_domarchiverequest_h__
|