dom/file/ArchiveEvent.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/file/ArchiveEvent.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,82 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim: set ts=2 et sw=2 tw=80: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef mozilla_dom_file_domarchiveevent_h__
    1.11 +#define mozilla_dom_file_domarchiveevent_h__
    1.12 +
    1.13 +#include "ArchiveReader.h"
    1.14 +
    1.15 +#include "nsISeekableStream.h"
    1.16 +#include "nsIMIMEService.h"
    1.17 +#include "nsDOMFile.h"
    1.18 +
    1.19 +#include "FileCommon.h"
    1.20 +
    1.21 +BEGIN_FILE_NAMESPACE
    1.22 +
    1.23 +/**
    1.24 + * This class contains all the info needed for a single item
    1.25 + * It must contain the implementation of the File() method.
    1.26 + */
    1.27 +class ArchiveItem : public nsISupports
    1.28 +{
    1.29 +public:
    1.30 +  NS_DECL_THREADSAFE_ISUPPORTS
    1.31 +
    1.32 +  ArchiveItem();
    1.33 +  virtual ~ArchiveItem();
    1.34 +
    1.35 +  // Getter/Setter for the type
    1.36 +  nsCString GetType();
    1.37 +  void SetType(const nsCString& aType);
    1.38 +
    1.39 +  // Getter for the filename
    1.40 +  virtual nsresult GetFilename(nsString& aFilename) = 0;
    1.41 +
    1.42 +  // Generate a DOMFile
    1.43 +  virtual nsIDOMFile* File(ArchiveReader* aArchiveReader) = 0;
    1.44 +
    1.45 +protected:
    1.46 +  nsCString mType;
    1.47 +};
    1.48 +
    1.49 +/**
    1.50 + * This class must be extended by any archive format supported by ArchiveReader API
    1.51 + * This class runs in a different thread and it calls the 'exec()' method.
    1.52 + * The exec() must populate mFileList and mStatus then it must call RunShare();
    1.53 + */
    1.54 +class ArchiveReaderEvent : public nsRunnable
    1.55 +{
    1.56 +public:
    1.57 +  NS_DECL_NSIRUNNABLE
    1.58 +
    1.59 +  ArchiveReaderEvent(ArchiveReader* aArchiveReader);
    1.60 +
    1.61 +  virtual ~ArchiveReaderEvent();
    1.62 +
    1.63 +  // This must be implemented
    1.64 +  virtual nsresult Exec() = 0;
    1.65 +
    1.66 +protected:
    1.67 +  nsresult GetType(nsCString& aExt,
    1.68 +                   nsCString& aMimeType);
    1.69 +
    1.70 +  nsresult RunShare(nsresult aStatus);
    1.71 +  void ShareMainThread();
    1.72 +
    1.73 +protected: // data
    1.74 +  ArchiveReader* mArchiveReader;
    1.75 +
    1.76 +  nsCOMPtr<nsIMIMEService> mMimeService;
    1.77 +
    1.78 +  nsTArray<nsRefPtr<ArchiveItem> > mFileList; // this must be populated
    1.79 +  nsresult mStatus;
    1.80 +};
    1.81 +
    1.82 +END_FILE_NAMESPACE
    1.83 +
    1.84 +#endif // mozilla_dom_file_domarchiveevent_h__
    1.85 +

mercurial