2012-07-28 00:21:34 +00: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 16:15:48 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-07-28 00:21:34 +00:00
|
|
|
#include "ArchiveReader.h"
|
|
|
|
#include "DOMRequest.h"
|
|
|
|
|
|
|
|
#include "FileCommon.h"
|
|
|
|
|
2014-03-18 04:48:19 +00:00
|
|
|
namespace mozilla {
|
|
|
|
class EventChainPreVisitor;
|
|
|
|
} // namespace mozilla
|
2012-07-28 00:21:34 +00:00
|
|
|
|
|
|
|
BEGIN_FILE_NAMESPACE
|
|
|
|
|
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:
|
2013-04-25 16:29:54 +00:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aScope) MOZ_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
|
2014-03-18 04:48:19 +00:00
|
|
|
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_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
|
|
|
|
|
|
|
nsresult ReaderReady(nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList,
|
|
|
|
nsresult aStatus);
|
|
|
|
|
|
|
|
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,
|
2012-07-28 00:21:34 +00:00
|
|
|
nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList);
|
|
|
|
nsresult GetFileResult(JSContext* aCx,
|
2013-10-12 05:02:39 +00:00
|
|
|
JS::MutableHandle<JS::Value> aValue,
|
2012-07-28 00:21:34 +00:00
|
|
|
nsTArray<nsCOMPtr<nsIDOMFile> >& 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,
|
2012-11-06 23:23:13 +00:00
|
|
|
nsTArray<nsCOMPtr<nsIDOMFile> >& 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;
|
|
|
|
};
|
|
|
|
|
|
|
|
END_FILE_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_file_domarchiverequest_h__
|