OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 virtual void close(ExecutionContext*, ExceptionState&) OVERRIDE; | 108 virtual void close(ExecutionContext*, ExceptionState&) OVERRIDE; |
109 | 109 |
110 virtual bool isFile() const OVERRIDE { return true; } | 110 virtual bool isFile() const OVERRIDE { return true; } |
111 virtual bool hasBackingFile() const OVERRIDE { return m_hasBackingFile; } | 111 virtual bool hasBackingFile() const OVERRIDE { return m_hasBackingFile; } |
112 | 112 |
113 virtual void appendTo(BlobData&) const OVERRIDE; | 113 virtual void appendTo(BlobData&) const OVERRIDE; |
114 | 114 |
115 const String& path() const { ASSERT(hasValidFilePath()); return m_path; } | 115 const String& path() const { ASSERT(hasValidFilePath()); return m_path; } |
116 const String name() const { return m_name; } | 116 const String name() const { return m_name; } |
117 | 117 |
118 // This returns the current date and time if the file's last modification da
te is not known (per spec: http://www.w3.org/TR/FileAPI/#dfn-lastModifiedDate). | 118 // Getter for the lastModified IDL attribute, |
| 119 // http://dev.w3.org/2006/webapi/FileAPI/#file-attrs |
| 120 long long lastModified() const; |
| 121 |
| 122 // Getter for the lastModifiedDate IDL attribute, |
| 123 // http://www.w3.org/TR/FileAPI/#dfn-lastModifiedDate |
119 double lastModifiedDate() const; | 124 double lastModifiedDate() const; |
120 | 125 |
121 UserVisibility userVisibility() const { return m_userVisibility; } | 126 UserVisibility userVisibility() const { return m_userVisibility; } |
122 | 127 |
123 // Returns the relative path of this file in the context of a directory sele
ction. | 128 // Returns the relative path of this file in the context of a directory sele
ction. |
124 const String& webkitRelativePath() const { return m_relativePath; } | 129 const String& webkitRelativePath() const { return m_relativePath; } |
125 | 130 |
126 // Note that this involves synchronous file operation. Think twice before ca
lling this function. | 131 // Note that this involves synchronous file operation. Think twice before ca
lling this function. |
127 void captureSnapshot(long long& snapshotSize, double& snapshotModificationTi
me) const; | 132 void captureSnapshot(long long& snapshotSize, double& snapshotModificationTi
me) const; |
128 | 133 |
129 // Returns true if this has a valid snapshot metadata (i.e. m_snapshotSize >
= 0). | 134 // Returns true if this has a valid snapshot metadata (i.e. m_snapshotSize >
= 0). |
130 bool hasValidSnapshotMetadata() const { return m_snapshotSize >= 0; } | 135 bool hasValidSnapshotMetadata() const { return m_snapshotSize >= 0; } |
131 | 136 |
132 private: | 137 private: |
133 File(const String& path, ContentTypeLookupPolicy, UserVisibility); | 138 File(const String& path, ContentTypeLookupPolicy, UserVisibility); |
134 File(const String& path, const String& name, ContentTypeLookupPolicy, UserVi
sibility); | 139 File(const String& path, const String& name, ContentTypeLookupPolicy, UserVi
sibility); |
135 File(const String& path, const String& name, const String& relativePath, Use
rVisibility, bool hasSnaphotData, uint64_t size, double lastModified, PassRefPtr
<BlobDataHandle>); | 140 File(const String& path, const String& name, const String& relativePath, Use
rVisibility, bool hasSnaphotData, uint64_t size, double lastModified, PassRefPtr
<BlobDataHandle>); |
136 File(const String& name, double modificationTime, PassRefPtr<BlobDataHandle>
); | 141 File(const String& name, double modificationTime, PassRefPtr<BlobDataHandle>
); |
137 File(const String& name, const FileMetadata&); | 142 File(const String& name, const FileMetadata&); |
138 File(const KURL& fileSystemURL, const FileMetadata&); | 143 File(const KURL& fileSystemURL, const FileMetadata&); |
139 | 144 |
140 void invalidateSnapshotMetadata() { m_snapshotSize = -1; } | 145 void invalidateSnapshotMetadata() { m_snapshotSize = -1; } |
141 | 146 |
| 147 // Returns File's last modified time (in MS since Epoch.) |
| 148 // If the modification time isn't known, the current time is returned. |
| 149 double lastModifiedMS() const; |
| 150 |
142 #if ENABLE(ASSERT) | 151 #if ENABLE(ASSERT) |
143 bool hasValidFileSystemURL() const { return hasBackingFile(); } | 152 bool hasValidFileSystemURL() const { return hasBackingFile(); } |
144 // Instances not backed by a file must have an empty path set. | 153 // Instances not backed by a file must have an empty path set. |
145 bool hasValidFilePath() const { return hasBackingFile() || m_path.isEmpty();
} | 154 bool hasValidFilePath() const { return hasBackingFile() || m_path.isEmpty();
} |
146 #endif | 155 #endif |
147 | 156 |
148 bool m_hasBackingFile; | 157 bool m_hasBackingFile; |
149 UserVisibility m_userVisibility; | 158 UserVisibility m_userVisibility; |
150 String m_path; | 159 String m_path; |
151 String m_name; | 160 String m_name; |
152 | 161 |
153 KURL m_fileSystemURL; | 162 KURL m_fileSystemURL; |
154 | 163 |
155 // If m_snapshotSize is negative (initialized to -1 by default), the snapsho
t metadata is invalid and we retrieve the latest metadata synchronously in size(
), lastModifiedTime() and slice(). | 164 // If m_snapshotSize is negative (initialized to -1 by default), the snapsho
t metadata is invalid and we retrieve the latest metadata synchronously in size(
), lastModifiedTime() and slice(). |
156 // Otherwise, the snapshot metadata are used directly in those methods. | 165 // Otherwise, the snapshot metadata are used directly in those methods. |
157 long long m_snapshotSize; | 166 long long m_snapshotSize; |
158 const double m_snapshotModificationTime; | 167 const double m_snapshotModificationTime; |
159 | 168 |
160 String m_relativePath; | 169 String m_relativePath; |
161 }; | 170 }; |
162 | 171 |
163 DEFINE_TYPE_CASTS(File, Blob, blob, blob->isFile(), blob.isFile()); | 172 DEFINE_TYPE_CASTS(File, Blob, blob, blob->isFile(), blob.isFile()); |
164 | 173 |
165 } // namespace blink | 174 } // namespace blink |
166 | 175 |
167 #endif // File_h | 176 #endif // File_h |
OLD | NEW |