Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(324)

Side by Side Diff: Source/WebCore/fileapi/File.cpp

Issue 13497009: Remove ENABLE(FILE_SYSTEM) compile-time flag. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: added CodeGeneratorInspector.py change Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/WebCore/fileapi/File.h ('k') | Source/WebCore/fileapi/FileError.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 static PassOwnPtr<BlobData> createBlobDataForFile(const String& path, File::Cont entTypeLookupPolicy policy) 61 static PassOwnPtr<BlobData> createBlobDataForFile(const String& path, File::Cont entTypeLookupPolicy policy)
62 { 62 {
63 return createBlobDataForFileWithType(path, getContentTypeFromFileName(path, policy)); 63 return createBlobDataForFileWithType(path, getContentTypeFromFileName(path, policy));
64 } 64 }
65 65
66 static PassOwnPtr<BlobData> createBlobDataForFileWithName(const String& path, co nst String& fileSystemName, File::ContentTypeLookupPolicy policy) 66 static PassOwnPtr<BlobData> createBlobDataForFileWithName(const String& path, co nst String& fileSystemName, File::ContentTypeLookupPolicy policy)
67 { 67 {
68 return createBlobDataForFileWithType(path, getContentTypeFromFileName(fileSy stemName, policy)); 68 return createBlobDataForFileWithType(path, getContentTypeFromFileName(fileSy stemName, policy));
69 } 69 }
70 70
71 #if ENABLE(FILE_SYSTEM)
72 static PassOwnPtr<BlobData> createBlobDataForFileWithMetadata(const String& file SystemName, const FileMetadata& metadata) 71 static PassOwnPtr<BlobData> createBlobDataForFileWithMetadata(const String& file SystemName, const FileMetadata& metadata)
73 { 72 {
74 OwnPtr<BlobData> blobData = BlobData::create(); 73 OwnPtr<BlobData> blobData = BlobData::create();
75 blobData->setContentType(getContentTypeFromFileName(fileSystemName, File::We llKnownContentTypes)); 74 blobData->setContentType(getContentTypeFromFileName(fileSystemName, File::We llKnownContentTypes));
76 blobData->appendFile(metadata.platformPath, 0, metadata.length, metadata.mod ificationTime); 75 blobData->appendFile(metadata.platformPath, 0, metadata.length, metadata.mod ificationTime);
77 return blobData.release(); 76 return blobData.release();
78 } 77 }
79 78
80 static PassOwnPtr<BlobData> createBlobDataForFileSystemURL(const KURL& fileSyste mURL, const FileMetadata& metadata) 79 static PassOwnPtr<BlobData> createBlobDataForFileSystemURL(const KURL& fileSyste mURL, const FileMetadata& metadata)
81 { 80 {
82 OwnPtr<BlobData> blobData = BlobData::create(); 81 OwnPtr<BlobData> blobData = BlobData::create();
83 blobData->setContentType(getContentTypeFromFileName(fileSystemURL.path(), Fi le::WellKnownContentTypes)); 82 blobData->setContentType(getContentTypeFromFileName(fileSystemURL.path(), Fi le::WellKnownContentTypes));
84 blobData->appendURL(fileSystemURL, 0, metadata.length, metadata.modification Time); 83 blobData->appendURL(fileSystemURL, 0, metadata.length, metadata.modification Time);
85 return blobData.release(); 84 return blobData.release();
86 } 85 }
87 #endif
88 86
89 #if ENABLE(DIRECTORY_UPLOAD) 87 #if ENABLE(DIRECTORY_UPLOAD)
90 PassRefPtr<File> File::createWithRelativePath(const String& path, const String& relativePath) 88 PassRefPtr<File> File::createWithRelativePath(const String& path, const String& relativePath)
91 { 89 {
92 RefPtr<File> file = adoptRef(new File(path, AllContentTypes)); 90 RefPtr<File> file = adoptRef(new File(path, AllContentTypes));
93 file->m_relativePath = relativePath; 91 file->m_relativePath = relativePath;
94 return file.release(); 92 return file.release();
95 } 93 }
96 #endif 94 #endif
97 95
98 File::File(const String& path, ContentTypeLookupPolicy policy) 96 File::File(const String& path, ContentTypeLookupPolicy policy)
99 : Blob(createBlobDataForFile(path, policy), -1) 97 : Blob(createBlobDataForFile(path, policy), -1)
100 , m_path(path) 98 , m_path(path)
101 , m_name(pathGetFileName(path)) 99 , m_name(pathGetFileName(path))
102 #if ENABLE(FILE_SYSTEM)
103 , m_snapshotSize(-1) 100 , m_snapshotSize(-1)
104 , m_snapshotModificationTime(invalidFileTime()) 101 , m_snapshotModificationTime(invalidFileTime())
105 #endif
106 { 102 {
107 } 103 }
108 104
109 File::File(const String& path, const KURL& url, const String& type) 105 File::File(const String& path, const KURL& url, const String& type)
110 : Blob(url, type, -1) 106 : Blob(url, type, -1)
111 , m_path(path) 107 , m_path(path)
112 #if ENABLE(FILE_SYSTEM)
113 , m_snapshotSize(-1) 108 , m_snapshotSize(-1)
114 , m_snapshotModificationTime(invalidFileTime()) 109 , m_snapshotModificationTime(invalidFileTime())
115 #endif
116 { 110 {
117 m_name = pathGetFileName(path); 111 m_name = pathGetFileName(path);
118 // FIXME: File object serialization/deserialization does not include 112 // FIXME: File object serialization/deserialization does not include
119 // newer file object data members: m_name and m_relativePath. 113 // newer file object data members: m_name and m_relativePath.
120 // See SerializedScriptValue.cpp for js and v8. 114 // See SerializedScriptValue.cpp for js and v8.
121 } 115 }
122 116
123 File::File(const String& path, const String& name, ContentTypeLookupPolicy polic y) 117 File::File(const String& path, const String& name, ContentTypeLookupPolicy polic y)
124 : Blob(createBlobDataForFileWithName(path, name, policy), -1) 118 : Blob(createBlobDataForFileWithName(path, name, policy), -1)
125 , m_path(path) 119 , m_path(path)
126 , m_name(name) 120 , m_name(name)
127 #if ENABLE(FILE_SYSTEM)
128 , m_snapshotSize(-1) 121 , m_snapshotSize(-1)
129 , m_snapshotModificationTime(invalidFileTime()) 122 , m_snapshotModificationTime(invalidFileTime())
130 #endif
131 { 123 {
132 } 124 }
133 125
134 #if ENABLE(FILE_SYSTEM)
135 File::File(const String& name, const FileMetadata& metadata) 126 File::File(const String& name, const FileMetadata& metadata)
136 : Blob(createBlobDataForFileWithMetadata(name, metadata), metadata.length) 127 : Blob(createBlobDataForFileWithMetadata(name, metadata), metadata.length)
137 , m_path(metadata.platformPath) 128 , m_path(metadata.platformPath)
138 , m_name(name) 129 , m_name(name)
139 , m_snapshotSize(metadata.length) 130 , m_snapshotSize(metadata.length)
140 , m_snapshotModificationTime(metadata.modificationTime) 131 , m_snapshotModificationTime(metadata.modificationTime)
141 { 132 {
142 } 133 }
143 134
144 File::File(const KURL& fileSystemURL, const FileMetadata& metadata) 135 File::File(const KURL& fileSystemURL, const FileMetadata& metadata)
145 : Blob(createBlobDataForFileSystemURL(fileSystemURL, metadata), metadata.len gth) 136 : Blob(createBlobDataForFileSystemURL(fileSystemURL, metadata), metadata.len gth)
146 , m_fileSystemURL(fileSystemURL) 137 , m_fileSystemURL(fileSystemURL)
147 , m_snapshotSize(metadata.length) 138 , m_snapshotSize(metadata.length)
148 , m_snapshotModificationTime(metadata.modificationTime) 139 , m_snapshotModificationTime(metadata.modificationTime)
149 { 140 {
150 } 141 }
151 #endif
152 142
153 double File::lastModifiedDate() const 143 double File::lastModifiedDate() const
154 { 144 {
155 #if ENABLE(FILE_SYSTEM)
156 if (hasValidSnapshotMetadata() && isValidFileTime(m_snapshotModificationTime )) 145 if (hasValidSnapshotMetadata() && isValidFileTime(m_snapshotModificationTime ))
157 return m_snapshotModificationTime * msPerSecond; 146 return m_snapshotModificationTime * msPerSecond;
158 #endif
159 147
160 time_t modificationTime; 148 time_t modificationTime;
161 if (getFileModificationTime(m_path, modificationTime) && isValidFileTime(mod ificationTime)) 149 if (getFileModificationTime(m_path, modificationTime) && isValidFileTime(mod ificationTime))
162 return modificationTime * msPerSecond; 150 return modificationTime * msPerSecond;
163 151
164 return currentTime() * msPerSecond; 152 return currentTime() * msPerSecond;
165 } 153 }
166 154
167 unsigned long long File::size() const 155 unsigned long long File::size() const
168 { 156 {
169 #if ENABLE(FILE_SYSTEM)
170 if (hasValidSnapshotMetadata()) 157 if (hasValidSnapshotMetadata())
171 return m_snapshotSize; 158 return m_snapshotSize;
172 #endif
173 159
174 // FIXME: JavaScript cannot represent sizes as large as unsigned long long, we need to 160 // FIXME: JavaScript cannot represent sizes as large as unsigned long long, we need to
175 // come up with an exception to throw if file size is not representable. 161 // come up with an exception to throw if file size is not representable.
176 long long size; 162 long long size;
177 if (!getFileSize(m_path, size)) 163 if (!getFileSize(m_path, size))
178 return 0; 164 return 0;
179 return static_cast<unsigned long long>(size); 165 return static_cast<unsigned long long>(size);
180 } 166 }
181 167
182 void File::captureSnapshot(long long& snapshotSize, double& snapshotModification Time) const 168 void File::captureSnapshot(long long& snapshotSize, double& snapshotModification Time) const
183 { 169 {
184 #if ENABLE(FILE_SYSTEM)
185 if (hasValidSnapshotMetadata()) { 170 if (hasValidSnapshotMetadata()) {
186 snapshotSize = m_snapshotSize; 171 snapshotSize = m_snapshotSize;
187 snapshotModificationTime = m_snapshotModificationTime; 172 snapshotModificationTime = m_snapshotModificationTime;
188 return; 173 return;
189 } 174 }
190 #endif
191 175
192 // Obtains a snapshot of the file by capturing its current size and modifica tion time. This is used when we slice a file for the first time. 176 // Obtains a snapshot of the file by capturing its current size and modifica tion time. This is used when we slice a file for the first time.
193 // If we fail to retrieve the size or modification time, probably due to tha t the file has been deleted, 0 size is returned. 177 // If we fail to retrieve the size or modification time, probably due to tha t the file has been deleted, 0 size is returned.
194 FileMetadata metadata; 178 FileMetadata metadata;
195 if (!getFileMetadata(m_path, metadata)) { 179 if (!getFileMetadata(m_path, metadata)) {
196 snapshotSize = 0; 180 snapshotSize = 0;
197 snapshotModificationTime = invalidFileTime(); 181 snapshotModificationTime = invalidFileTime();
198 return; 182 return;
199 } 183 }
200 184
201 snapshotSize = metadata.length; 185 snapshotSize = metadata.length;
202 snapshotModificationTime = metadata.modificationTime; 186 snapshotModificationTime = metadata.modificationTime;
203 } 187 }
204 188
205 } // namespace WebCore 189 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebCore/fileapi/File.h ('k') | Source/WebCore/fileapi/FileError.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698