2012-07-27 17:21:34 -07: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 09:15:48 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-07-27 17:21:34 -07:00
|
|
|
#include "ArchiveReader.h"
|
|
|
|
#include "DOMRequest.h"
|
|
|
|
|
|
|
|
#include "FileCommon.h"
|
|
|
|
|
2014-03-17 21:48:19 -07:00
|
|
|
namespace mozilla {
|
|
|
|
class EventChainPreVisitor;
|
|
|
|
} // namespace mozilla
|
2012-07-27 17:21:34 -07:00
|
|
|
|
|
|
|
BEGIN_FILE_NAMESPACE
|
|
|
|
|
2012-11-06 15:23:13 -08:00
|
|
|
/**
|
|
|
|
* This is the ArchiveRequest that handles any operation
|
|
|
|
* related to ArchiveReader
|
|
|
|
*/
|
2013-03-17 01:51:36 -07:00
|
|
|
class ArchiveRequest : public mozilla::dom::DOMRequest
|
2012-07-27 17:21:34 -07:00
|
|
|
{
|
|
|
|
public:
|
2013-04-25 09:29:54 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
2013-03-17 01:51:36 -07:00
|
|
|
|
|
|
|
ArchiveReader* Reader() const;
|
|
|
|
|
2012-11-06 15:23:13 -08:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2012-07-27 17:21:34 -07:00
|
|
|
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ArchiveRequest, DOMRequest)
|
|
|
|
|
2014-01-06 18:53:23 -08:00
|
|
|
ArchiveRequest(nsPIDOMWindow* aWindow,
|
2012-07-27 17:21:34 -07:00
|
|
|
ArchiveReader* aReader);
|
|
|
|
|
|
|
|
// nsIDOMEventTarget
|
2014-03-17 21:48:19 -07:00
|
|
|
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
|
2012-07-27 17:21:34 -07: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 15:23:13 -08:00
|
|
|
void OpGetFiles();
|
2012-07-27 17:21:34 -07:00
|
|
|
|
|
|
|
nsresult ReaderReady(nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList,
|
|
|
|
nsresult aStatus);
|
|
|
|
|
|
|
|
public: // static
|
2014-01-06 18:53:23 -08:00
|
|
|
static already_AddRefed<ArchiveRequest> Create(nsPIDOMWindow* aOwner,
|
2012-07-27 17:21:34 -07:00
|
|
|
ArchiveReader* aReader);
|
|
|
|
|
|
|
|
private:
|
|
|
|
~ArchiveRequest();
|
|
|
|
|
|
|
|
nsresult GetFilenamesResult(JSContext* aCx,
|
2012-11-06 15:23:13 -08:00
|
|
|
JS::Value* aValue,
|
2012-07-27 17:21:34 -07:00
|
|
|
nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList);
|
|
|
|
nsresult GetFileResult(JSContext* aCx,
|
2013-10-11 22:02:39 -07:00
|
|
|
JS::MutableHandle<JS::Value> aValue,
|
2012-07-27 17:21:34 -07:00
|
|
|
nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList);
|
2012-11-06 15:23:13 -08:00
|
|
|
nsresult GetFilesResult(JSContext* aCx,
|
2013-10-11 22:02:39 -07:00
|
|
|
JS::MutableHandle<JS::Value> aValue,
|
2012-11-06 15:23:13 -08:00
|
|
|
nsTArray<nsCOMPtr<nsIDOMFile> >& aFileList);
|
2012-07-27 17:21:34 -07:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// The reader:
|
|
|
|
nsRefPtr<ArchiveReader> mArchiveReader;
|
|
|
|
|
|
|
|
// The operation:
|
|
|
|
enum {
|
|
|
|
GetFilenames,
|
2012-11-06 15:23:13 -08:00
|
|
|
GetFile,
|
|
|
|
GetFiles
|
2012-07-27 17:21:34 -07:00
|
|
|
} mOperation;
|
|
|
|
|
|
|
|
// The filename (needed by GetFile):
|
|
|
|
nsString mFilename;
|
|
|
|
};
|
|
|
|
|
|
|
|
END_FILE_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_file_domarchiverequest_h__
|