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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 95 |
96 File::File(const String& path, ContentTypeLookupPolicy policy, UserVisibility us
erVisibility) | 96 File::File(const String& path, ContentTypeLookupPolicy policy, UserVisibility us
erVisibility) |
97 : Blob(BlobDataHandle::create(createBlobDataForFile(path, policy), -1)) | 97 : Blob(BlobDataHandle::create(createBlobDataForFile(path, policy), -1)) |
98 , m_hasBackingFile(true) | 98 , m_hasBackingFile(true) |
99 , m_userVisibility(userVisibility) | 99 , m_userVisibility(userVisibility) |
100 , m_path(path) | 100 , m_path(path) |
101 , m_name(Platform::current()->fileUtilities()->baseName(path)) | 101 , m_name(Platform::current()->fileUtilities()->baseName(path)) |
102 , m_snapshotSize(-1) | 102 , m_snapshotSize(-1) |
103 , m_snapshotModificationTime(invalidFileTime()) | 103 , m_snapshotModificationTime(invalidFileTime()) |
104 { | 104 { |
105 ScriptWrappable::init(this); | |
106 } | 105 } |
107 | 106 |
108 File::File(const String& path, const String& name, ContentTypeLookupPolicy polic
y, UserVisibility userVisibility) | 107 File::File(const String& path, const String& name, ContentTypeLookupPolicy polic
y, UserVisibility userVisibility) |
109 : Blob(BlobDataHandle::create(createBlobDataForFileWithName(path, name, poli
cy), -1)) | 108 : Blob(BlobDataHandle::create(createBlobDataForFileWithName(path, name, poli
cy), -1)) |
110 , m_hasBackingFile(true) | 109 , m_hasBackingFile(true) |
111 , m_userVisibility(userVisibility) | 110 , m_userVisibility(userVisibility) |
112 , m_path(path) | 111 , m_path(path) |
113 , m_name(name) | 112 , m_name(name) |
114 , m_snapshotSize(-1) | 113 , m_snapshotSize(-1) |
115 , m_snapshotModificationTime(invalidFileTime()) | 114 , m_snapshotModificationTime(invalidFileTime()) |
116 { | 115 { |
117 ScriptWrappable::init(this); | |
118 } | 116 } |
119 | 117 |
120 File::File(const String& path, const String& name, const String& relativePath, U
serVisibility userVisibility, bool hasSnaphotData, uint64_t size, double lastMod
ified, PassRefPtr<BlobDataHandle> blobDataHandle) | 118 File::File(const String& path, const String& name, const String& relativePath, U
serVisibility userVisibility, bool hasSnaphotData, uint64_t size, double lastMod
ified, PassRefPtr<BlobDataHandle> blobDataHandle) |
121 : Blob(blobDataHandle) | 119 : Blob(blobDataHandle) |
122 , m_hasBackingFile(!path.isEmpty() || !relativePath.isEmpty()) | 120 , m_hasBackingFile(!path.isEmpty() || !relativePath.isEmpty()) |
123 , m_userVisibility(userVisibility) | 121 , m_userVisibility(userVisibility) |
124 , m_path(path) | 122 , m_path(path) |
125 , m_name(name) | 123 , m_name(name) |
126 , m_snapshotSize(hasSnaphotData ? static_cast<long long>(size) : -1) | 124 , m_snapshotSize(hasSnaphotData ? static_cast<long long>(size) : -1) |
127 , m_snapshotModificationTime(hasSnaphotData ? lastModified : invalidFileTime
()) | 125 , m_snapshotModificationTime(hasSnaphotData ? lastModified : invalidFileTime
()) |
128 , m_relativePath(relativePath) | 126 , m_relativePath(relativePath) |
129 { | 127 { |
130 ScriptWrappable::init(this); | |
131 } | 128 } |
132 | 129 |
133 File::File(const String& name, double modificationTime, PassRefPtr<BlobDataHandl
e> blobDataHandle) | 130 File::File(const String& name, double modificationTime, PassRefPtr<BlobDataHandl
e> blobDataHandle) |
134 : Blob(blobDataHandle) | 131 : Blob(blobDataHandle) |
135 , m_hasBackingFile(false) | 132 , m_hasBackingFile(false) |
136 , m_userVisibility(File::IsNotUserVisible) | 133 , m_userVisibility(File::IsNotUserVisible) |
137 , m_name(name) | 134 , m_name(name) |
138 , m_snapshotSize(Blob::size()) | 135 , m_snapshotSize(Blob::size()) |
139 , m_snapshotModificationTime(modificationTime) | 136 , m_snapshotModificationTime(modificationTime) |
140 { | 137 { |
141 ScriptWrappable::init(this); | |
142 } | 138 } |
143 | 139 |
144 File::File(const String& name, const FileMetadata& metadata) | 140 File::File(const String& name, const FileMetadata& metadata) |
145 : Blob(BlobDataHandle::create(createBlobDataForFileWithMetadata(name, metada
ta), metadata.length)) | 141 : Blob(BlobDataHandle::create(createBlobDataForFileWithMetadata(name, metada
ta), metadata.length)) |
146 , m_hasBackingFile(true) | 142 , m_hasBackingFile(true) |
147 , m_userVisibility(File::IsNotUserVisible) | 143 , m_userVisibility(File::IsNotUserVisible) |
148 , m_path(metadata.platformPath) | 144 , m_path(metadata.platformPath) |
149 , m_name(name) | 145 , m_name(name) |
150 , m_snapshotSize(metadata.length) | 146 , m_snapshotSize(metadata.length) |
151 , m_snapshotModificationTime(metadata.modificationTime) | 147 , m_snapshotModificationTime(metadata.modificationTime) |
152 { | 148 { |
153 ScriptWrappable::init(this); | |
154 } | 149 } |
155 | 150 |
156 File::File(const KURL& fileSystemURL, const FileMetadata& metadata) | 151 File::File(const KURL& fileSystemURL, const FileMetadata& metadata) |
157 : Blob(BlobDataHandle::create(createBlobDataForFileSystemURL(fileSystemURL,
metadata), metadata.length)) | 152 : Blob(BlobDataHandle::create(createBlobDataForFileSystemURL(fileSystemURL,
metadata), metadata.length)) |
158 , m_hasBackingFile(true) | 153 , m_hasBackingFile(true) |
159 , m_userVisibility(File::IsNotUserVisible) | 154 , m_userVisibility(File::IsNotUserVisible) |
160 , m_name(decodeURLEscapeSequences(fileSystemURL.lastPathComponent())) | 155 , m_name(decodeURLEscapeSequences(fileSystemURL.lastPathComponent())) |
161 , m_fileSystemURL(fileSystemURL) | 156 , m_fileSystemURL(fileSystemURL) |
162 , m_snapshotSize(metadata.length) | 157 , m_snapshotSize(metadata.length) |
163 , m_snapshotModificationTime(metadata.modificationTime) | 158 , m_snapshotModificationTime(metadata.modificationTime) |
164 { | 159 { |
165 ScriptWrappable::init(this); | |
166 } | 160 } |
167 | 161 |
168 double File::lastModifiedMS() const | 162 double File::lastModifiedMS() const |
169 { | 163 { |
170 if (hasValidSnapshotMetadata() && isValidFileTime(m_snapshotModificationTime
)) | 164 if (hasValidSnapshotMetadata() && isValidFileTime(m_snapshotModificationTime
)) |
171 return m_snapshotModificationTime * msPerSecond; | 165 return m_snapshotModificationTime * msPerSecond; |
172 | 166 |
173 time_t modificationTime; | 167 time_t modificationTime; |
174 if (hasBackingFile() && getFileModificationTime(m_path, modificationTime) &&
isValidFileTime(modificationTime)) | 168 if (hasBackingFile() && getFileModificationTime(m_path, modificationTime) &&
isValidFileTime(modificationTime)) |
175 return modificationTime * msPerSecond; | 169 return modificationTime * msPerSecond; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 captureSnapshot(size, modificationTime); | 290 captureSnapshot(size, modificationTime); |
297 if (!m_fileSystemURL.isEmpty()) { | 291 if (!m_fileSystemURL.isEmpty()) { |
298 blobData.appendFileSystemURL(m_fileSystemURL, 0, size, modificationTime)
; | 292 blobData.appendFileSystemURL(m_fileSystemURL, 0, size, modificationTime)
; |
299 return; | 293 return; |
300 } | 294 } |
301 ASSERT(!m_path.isEmpty()); | 295 ASSERT(!m_path.isEmpty()); |
302 blobData.appendFile(m_path, 0, size, modificationTime); | 296 blobData.appendFile(m_path, 0, size, modificationTime); |
303 } | 297 } |
304 | 298 |
305 } // namespace blink | 299 } // namespace blink |
OLD | NEW |