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

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

Issue 882343002: Upgrade Blink to milliseconds-based last modified filetimes, part 5. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@sof-fileinfo-modtime-in-ms-3
Patch Set: rebased Created 5 years, 10 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
« no previous file with comments | « no previous file | Source/core/html/forms/FileInputTypeTest.cpp » ('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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 static PassOwnPtr<BlobData> createBlobDataForFileWithName(const String& path, co nst String& fileSystemName, File::ContentTypeLookupPolicy policy) 68 static PassOwnPtr<BlobData> createBlobDataForFileWithName(const String& path, co nst String& fileSystemName, File::ContentTypeLookupPolicy policy)
69 { 69 {
70 return createBlobDataForFileWithType(path, getContentTypeFromFileName(fileSy stemName, policy)); 70 return createBlobDataForFileWithType(path, getContentTypeFromFileName(fileSy stemName, policy));
71 } 71 }
72 72
73 static PassOwnPtr<BlobData> createBlobDataForFileWithMetadata(const String& file SystemName, const FileMetadata& metadata) 73 static PassOwnPtr<BlobData> createBlobDataForFileWithMetadata(const String& file SystemName, const FileMetadata& metadata)
74 { 74 {
75 OwnPtr<BlobData> blobData = BlobData::create(); 75 OwnPtr<BlobData> blobData = BlobData::create();
76 blobData->setContentType(getContentTypeFromFileName(fileSystemName, File::We llKnownContentTypes)); 76 blobData->setContentType(getContentTypeFromFileName(fileSystemName, File::We llKnownContentTypes));
77 blobData->appendFile(metadata.platformPath, 0, metadata.length, metadata.mod ificationTimeMS / msPerSecond); 77 blobData->appendFile(metadata.platformPath, 0, metadata.length, metadata.mod ificationTime / msPerSecond);
78 return blobData.release(); 78 return blobData.release();
79 } 79 }
80 80
81 static PassOwnPtr<BlobData> createBlobDataForFileSystemURL(const KURL& fileSyste mURL, const FileMetadata& metadata) 81 static PassOwnPtr<BlobData> createBlobDataForFileSystemURL(const KURL& fileSyste mURL, const FileMetadata& metadata)
82 { 82 {
83 OwnPtr<BlobData> blobData = BlobData::create(); 83 OwnPtr<BlobData> blobData = BlobData::create();
84 blobData->setContentType(getContentTypeFromFileName(fileSystemURL.path(), Fi le::WellKnownContentTypes)); 84 blobData->setContentType(getContentTypeFromFileName(fileSystemURL.path(), Fi le::WellKnownContentTypes));
85 blobData->appendFileSystemURL(fileSystemURL, 0, metadata.length, metadata.mo dificationTimeMS / msPerSecond); 85 blobData->appendFileSystemURL(fileSystemURL, 0, metadata.length, metadata.mo dificationTime / msPerSecond);
86 return blobData.release(); 86 return blobData.release();
87 } 87 }
88 88
89 File* File::createWithRelativePath(const String& path, const String& relativePat h) 89 File* File::createWithRelativePath(const String& path, const String& relativePat h)
90 { 90 {
91 File* file = new File(path, File::AllContentTypes, File::IsUserVisible); 91 File* file = new File(path, File::AllContentTypes, File::IsUserVisible);
92 file->m_relativePath = relativePath; 92 file->m_relativePath = relativePath;
93 return file; 93 return file;
94 } 94 }
95 95
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 { 137 {
138 } 138 }
139 139
140 File::File(const String& name, const FileMetadata& metadata, UserVisibility user Visibility) 140 File::File(const String& name, const FileMetadata& metadata, UserVisibility user Visibility)
141 : Blob(BlobDataHandle::create(createBlobDataForFileWithMetadata(name, metada ta), metadata.length)) 141 : Blob(BlobDataHandle::create(createBlobDataForFileWithMetadata(name, metada ta), metadata.length))
142 , m_hasBackingFile(true) 142 , m_hasBackingFile(true)
143 , m_userVisibility(userVisibility) 143 , m_userVisibility(userVisibility)
144 , m_path(metadata.platformPath) 144 , m_path(metadata.platformPath)
145 , m_name(name) 145 , m_name(name)
146 , m_snapshotSize(metadata.length) 146 , m_snapshotSize(metadata.length)
147 , m_snapshotModificationTimeMS(metadata.modificationTimeMS) 147 , m_snapshotModificationTimeMS(metadata.modificationTime)
148 { 148 {
149 } 149 }
150 150
151 File::File(const KURL& fileSystemURL, const FileMetadata& metadata, UserVisibili ty userVisibility) 151 File::File(const KURL& fileSystemURL, const FileMetadata& metadata, UserVisibili ty userVisibility)
152 : Blob(BlobDataHandle::create(createBlobDataForFileSystemURL(fileSystemURL, metadata), metadata.length)) 152 : Blob(BlobDataHandle::create(createBlobDataForFileSystemURL(fileSystemURL, metadata), metadata.length))
153 , m_hasBackingFile(false) 153 , m_hasBackingFile(false)
154 , m_userVisibility(userVisibility) 154 , m_userVisibility(userVisibility)
155 , m_name(decodeURLEscapeSequences(fileSystemURL.lastPathComponent())) 155 , m_name(decodeURLEscapeSequences(fileSystemURL.lastPathComponent()))
156 , m_fileSystemURL(fileSystemURL) 156 , m_fileSystemURL(fileSystemURL)
157 , m_snapshotSize(metadata.length) 157 , m_snapshotSize(metadata.length)
158 , m_snapshotModificationTimeMS(metadata.modificationTimeMS) 158 , m_snapshotModificationTimeMS(metadata.modificationTime)
159 { 159 {
160 } 160 }
161 161
162 File::File(const File& other) 162 File::File(const File& other)
163 : Blob(other.blobDataHandle()) 163 : Blob(other.blobDataHandle())
164 , m_hasBackingFile(other.m_hasBackingFile) 164 , m_hasBackingFile(other.m_hasBackingFile)
165 , m_userVisibility(other.m_userVisibility) 165 , m_userVisibility(other.m_userVisibility)
166 , m_path(other.m_path) 166 , m_path(other.m_path)
167 , m_name(other.m_name) 167 , m_name(other.m_name)
168 , m_fileSystemURL(other.m_fileSystemURL) 168 , m_fileSystemURL(other.m_fileSystemURL)
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 // 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. 270 // 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.
271 // If we fail to retrieve the size or modification time, probably due to tha t the file has been deleted, 0 size is returned. 271 // If we fail to retrieve the size or modification time, probably due to tha t the file has been deleted, 0 size is returned.
272 FileMetadata metadata; 272 FileMetadata metadata;
273 if (!hasBackingFile() || !getFileMetadata(m_path, metadata)) { 273 if (!hasBackingFile() || !getFileMetadata(m_path, metadata)) {
274 snapshotSize = 0; 274 snapshotSize = 0;
275 snapshotModificationTimeMS = invalidFileTime(); 275 snapshotModificationTimeMS = invalidFileTime();
276 return; 276 return;
277 } 277 }
278 278
279 snapshotSize = metadata.length; 279 snapshotSize = metadata.length;
280 snapshotModificationTimeMS = metadata.modificationTimeMS; 280 snapshotModificationTimeMS = metadata.modificationTime;
281 } 281 }
282 282
283 void File::close(ExecutionContext* executionContext, ExceptionState& exceptionSt ate) 283 void File::close(ExecutionContext* executionContext, ExceptionState& exceptionSt ate)
284 { 284 {
285 if (hasBeenClosed()) { 285 if (hasBeenClosed()) {
286 exceptionState.throwDOMException(InvalidStateError, "Blob has been close d."); 286 exceptionState.throwDOMException(InvalidStateError, "Blob has been close d.");
287 return; 287 return;
288 } 288 }
289 289
290 // Reset the File to its closed representation, an empty 290 // Reset the File to its closed representation, an empty
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 if (m_fileSystemURL.isEmpty() != other.m_fileSystemURL.isEmpty()) 328 if (m_fileSystemURL.isEmpty() != other.m_fileSystemURL.isEmpty())
329 return false; 329 return false;
330 330
331 if (!m_fileSystemURL.isEmpty()) 331 if (!m_fileSystemURL.isEmpty())
332 return m_fileSystemURL == other.m_fileSystemURL; 332 return m_fileSystemURL == other.m_fileSystemURL;
333 333
334 return uuid() == other.uuid(); 334 return uuid() == other.uuid();
335 } 335 }
336 336
337 } // namespace blink 337 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/core/html/forms/FileInputTypeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698