Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 5 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef mozilla_dom_file_metadatahelper_h__ |
michael@0 | 8 | #define mozilla_dom_file_metadatahelper_h__ |
michael@0 | 9 | |
michael@0 | 10 | #include "mozilla/Attributes.h" |
michael@0 | 11 | #include "FileCommon.h" |
michael@0 | 12 | |
michael@0 | 13 | #include "nsIFileStreams.h" |
michael@0 | 14 | |
michael@0 | 15 | #include "AsyncHelper.h" |
michael@0 | 16 | #include "FileHelper.h" |
michael@0 | 17 | |
michael@0 | 18 | class nsIFileStream; |
michael@0 | 19 | |
michael@0 | 20 | BEGIN_FILE_NAMESPACE |
michael@0 | 21 | |
michael@0 | 22 | class MetadataHelper; |
michael@0 | 23 | |
michael@0 | 24 | class MetadataParameters MOZ_FINAL |
michael@0 | 25 | { |
michael@0 | 26 | friend class MetadataHelper; |
michael@0 | 27 | |
michael@0 | 28 | public: |
michael@0 | 29 | NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MetadataParameters) |
michael@0 | 30 | |
michael@0 | 31 | MetadataParameters(bool aSizeRequested, bool aLastModifiedRequested) |
michael@0 | 32 | : mSizeRequested(aSizeRequested) |
michael@0 | 33 | , mLastModifiedRequested(aLastModifiedRequested) |
michael@0 | 34 | { |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | bool |
michael@0 | 38 | IsConfigured() const |
michael@0 | 39 | { |
michael@0 | 40 | return mSizeRequested || mLastModifiedRequested; |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | bool |
michael@0 | 44 | SizeRequested() const |
michael@0 | 45 | { |
michael@0 | 46 | return mSizeRequested; |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | bool |
michael@0 | 50 | LastModifiedRequested() const |
michael@0 | 51 | { |
michael@0 | 52 | return mLastModifiedRequested; |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | uint64_t |
michael@0 | 56 | Size() const |
michael@0 | 57 | { |
michael@0 | 58 | return mSize; |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | int64_t |
michael@0 | 62 | LastModified() const |
michael@0 | 63 | { |
michael@0 | 64 | return mLastModified; |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | private: |
michael@0 | 68 | // Private destructor, to discourage deletion outside of Release(): |
michael@0 | 69 | ~MetadataParameters() |
michael@0 | 70 | { |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | uint64_t mSize; |
michael@0 | 74 | int64_t mLastModified; |
michael@0 | 75 | bool mSizeRequested; |
michael@0 | 76 | bool mLastModifiedRequested; |
michael@0 | 77 | }; |
michael@0 | 78 | |
michael@0 | 79 | class MetadataHelper : public FileHelper |
michael@0 | 80 | { |
michael@0 | 81 | public: |
michael@0 | 82 | MetadataHelper(LockedFile* aLockedFile, |
michael@0 | 83 | FileRequest* aFileRequest, |
michael@0 | 84 | MetadataParameters* aParams) |
michael@0 | 85 | : FileHelper(aLockedFile, aFileRequest), |
michael@0 | 86 | mParams(aParams) |
michael@0 | 87 | { } |
michael@0 | 88 | |
michael@0 | 89 | nsresult |
michael@0 | 90 | DoAsyncRun(nsISupports* aStream) MOZ_OVERRIDE; |
michael@0 | 91 | |
michael@0 | 92 | nsresult |
michael@0 | 93 | GetSuccessResult(JSContext* aCx, |
michael@0 | 94 | JS::MutableHandle<JS::Value> aVal) MOZ_OVERRIDE; |
michael@0 | 95 | |
michael@0 | 96 | protected: |
michael@0 | 97 | class AsyncMetadataGetter : public AsyncHelper |
michael@0 | 98 | { |
michael@0 | 99 | public: |
michael@0 | 100 | AsyncMetadataGetter(nsISupports* aStream, MetadataParameters* aParams, |
michael@0 | 101 | bool aReadWrite) |
michael@0 | 102 | : AsyncHelper(aStream), |
michael@0 | 103 | mParams(aParams), mReadWrite(aReadWrite) |
michael@0 | 104 | { } |
michael@0 | 105 | |
michael@0 | 106 | protected: |
michael@0 | 107 | nsresult |
michael@0 | 108 | DoStreamWork(nsISupports* aStream) MOZ_OVERRIDE; |
michael@0 | 109 | |
michael@0 | 110 | private: |
michael@0 | 111 | nsRefPtr<MetadataParameters> mParams; |
michael@0 | 112 | bool mReadWrite; |
michael@0 | 113 | }; |
michael@0 | 114 | |
michael@0 | 115 | nsRefPtr<MetadataParameters> mParams; |
michael@0 | 116 | }; |
michael@0 | 117 | |
michael@0 | 118 | END_FILE_NAMESPACE |
michael@0 | 119 | |
michael@0 | 120 | #endif // mozilla_dom_file_metadatahelper_h__ |