| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // For deserialization. | 53 // For deserialization. |
| 54 static PassRefPtr<File> create(const String& path, const KURL& srcURL, const
String& type) | 54 static PassRefPtr<File> create(const String& path, const KURL& srcURL, const
String& type) |
| 55 { | 55 { |
| 56 return adoptRef(new File(path, srcURL, type)); | 56 return adoptRef(new File(path, srcURL, type)); |
| 57 } | 57 } |
| 58 | 58 |
| 59 #if ENABLE(DIRECTORY_UPLOAD) | 59 #if ENABLE(DIRECTORY_UPLOAD) |
| 60 static PassRefPtr<File> createWithRelativePath(const String& path, const Str
ing& relativePath); | 60 static PassRefPtr<File> createWithRelativePath(const String& path, const Str
ing& relativePath); |
| 61 #endif | 61 #endif |
| 62 | 62 |
| 63 #if ENABLE(FILE_SYSTEM) | |
| 64 // If filesystem files live in the remote filesystem, the port might pass th
e valid metadata (whose length field is non-negative) and cache in the File obje
ct. | 63 // If filesystem files live in the remote filesystem, the port might pass th
e valid metadata (whose length field is non-negative) and cache in the File obje
ct. |
| 65 // | 64 // |
| 66 // Otherwise calling size(), lastModifiedTime() and slice() will synchronous
ly query the file metadata. | 65 // Otherwise calling size(), lastModifiedTime() and slice() will synchronous
ly query the file metadata. |
| 67 static PassRefPtr<File> createForFileSystemFile(const String& name, const Fi
leMetadata& metadata) | 66 static PassRefPtr<File> createForFileSystemFile(const String& name, const Fi
leMetadata& metadata) |
| 68 { | 67 { |
| 69 return adoptRef(new File(name, metadata)); | 68 return adoptRef(new File(name, metadata)); |
| 70 } | 69 } |
| 71 | 70 |
| 72 static PassRefPtr<File> createForFileSystemFile(const KURL& url, const FileM
etadata& metadata) | 71 static PassRefPtr<File> createForFileSystemFile(const KURL& url, const FileM
etadata& metadata) |
| 73 { | 72 { |
| 74 return adoptRef(new File(url, metadata)); | 73 return adoptRef(new File(url, metadata)); |
| 75 } | 74 } |
| 76 | 75 |
| 77 KURL fileSystemURL() const { return m_fileSystemURL; } | 76 KURL fileSystemURL() const { return m_fileSystemURL; } |
| 78 #endif | |
| 79 | 77 |
| 80 // Create a file with a name exposed to the author (via File.name and associ
ated DOM properties) that differs from the one provided in the path. | 78 // Create a file with a name exposed to the author (via File.name and associ
ated DOM properties) that differs from the one provided in the path. |
| 81 static PassRefPtr<File> createWithName(const String& path, const String& nam
e, ContentTypeLookupPolicy policy = WellKnownContentTypes) | 79 static PassRefPtr<File> createWithName(const String& path, const String& nam
e, ContentTypeLookupPolicy policy = WellKnownContentTypes) |
| 82 { | 80 { |
| 83 if (name.isEmpty()) | 81 if (name.isEmpty()) |
| 84 return adoptRef(new File(path, policy)); | 82 return adoptRef(new File(path, policy)); |
| 85 return adoptRef(new File(path, name, policy)); | 83 return adoptRef(new File(path, name, policy)); |
| 86 } | 84 } |
| 87 | 85 |
| 88 virtual unsigned long long size() const; | 86 virtual unsigned long long size() const; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 101 | 99 |
| 102 // Note that this involves synchronous file operation. Think twice before ca
lling this function. | 100 // Note that this involves synchronous file operation. Think twice before ca
lling this function. |
| 103 void captureSnapshot(long long& snapshotSize, double& snapshotModificationTi
me) const; | 101 void captureSnapshot(long long& snapshotSize, double& snapshotModificationTi
me) const; |
| 104 | 102 |
| 105 private: | 103 private: |
| 106 File(const String& path, ContentTypeLookupPolicy); | 104 File(const String& path, ContentTypeLookupPolicy); |
| 107 | 105 |
| 108 // For deserialization. | 106 // For deserialization. |
| 109 File(const String& path, const KURL& srcURL, const String& type); | 107 File(const String& path, const KURL& srcURL, const String& type); |
| 110 File(const String& path, const String& name, ContentTypeLookupPolicy); | 108 File(const String& path, const String& name, ContentTypeLookupPolicy); |
| 111 | |
| 112 # if ENABLE(FILE_SYSTEM) | |
| 113 File(const String& name, const FileMetadata&); | 109 File(const String& name, const FileMetadata&); |
| 114 File(const KURL& fileSystemURL, const FileMetadata&); | 110 File(const KURL& fileSystemURL, const FileMetadata&); |
| 115 | 111 |
| 116 // Returns true if this has a valid snapshot metadata (i.e. m_snapshotSize >
= 0). | 112 // Returns true if this has a valid snapshot metadata (i.e. m_snapshotSize >
= 0). |
| 117 bool hasValidSnapshotMetadata() const { return m_snapshotSize >= 0; } | 113 bool hasValidSnapshotMetadata() const { return m_snapshotSize >= 0; } |
| 118 #endif | |
| 119 | 114 |
| 120 String m_path; | 115 String m_path; |
| 121 String m_name; | 116 String m_name; |
| 122 | 117 |
| 123 #if ENABLE(FILE_SYSTEM) | |
| 124 KURL m_fileSystemURL; | 118 KURL m_fileSystemURL; |
| 125 | 119 |
| 126 // 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(). | 120 // 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(). |
| 127 // Otherwise, the snapshot metadata are used directly in those methods. | 121 // Otherwise, the snapshot metadata are used directly in those methods. |
| 128 const long long m_snapshotSize; | 122 const long long m_snapshotSize; |
| 129 const double m_snapshotModificationTime; | 123 const double m_snapshotModificationTime; |
| 130 #endif | |
| 131 | 124 |
| 132 #if ENABLE(DIRECTORY_UPLOAD) | 125 #if ENABLE(DIRECTORY_UPLOAD) |
| 133 String m_relativePath; | 126 String m_relativePath; |
| 134 #endif | 127 #endif |
| 135 }; | 128 }; |
| 136 | 129 |
| 137 inline File* toFile(Blob* blob) | 130 inline File* toFile(Blob* blob) |
| 138 { | 131 { |
| 139 ASSERT_WITH_SECURITY_IMPLICATION(!blob || blob->isFile()); | 132 ASSERT_WITH_SECURITY_IMPLICATION(!blob || blob->isFile()); |
| 140 return static_cast<File*>(blob); | 133 return static_cast<File*>(blob); |
| 141 } | 134 } |
| 142 | 135 |
| 143 inline const File* toFile(const Blob* blob) | 136 inline const File* toFile(const Blob* blob) |
| 144 { | 137 { |
| 145 ASSERT_WITH_SECURITY_IMPLICATION(!blob || blob->isFile()); | 138 ASSERT_WITH_SECURITY_IMPLICATION(!blob || blob->isFile()); |
| 146 return static_cast<const File*>(blob); | 139 return static_cast<const File*>(blob); |
| 147 } | 140 } |
| 148 | 141 |
| 149 } // namespace WebCore | 142 } // namespace WebCore |
| 150 | 143 |
| 151 #endif // File_h | 144 #endif // File_h |
| OLD | NEW |