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 14 matching lines...) Expand all Loading... |
25 | 25 |
26 #ifndef File_h | 26 #ifndef File_h |
27 #define File_h | 27 #define File_h |
28 | 28 |
29 #include "core/fileapi/Blob.h" | 29 #include "core/fileapi/Blob.h" |
30 #include "wtf/PassRefPtr.h" | 30 #include "wtf/PassRefPtr.h" |
31 #include "wtf/text/WTFString.h" | 31 #include "wtf/text/WTFString.h" |
32 | 32 |
33 namespace WebCore { | 33 namespace WebCore { |
34 | 34 |
| 35 class ExceptionState; |
35 class ExecutionContext; | 36 class ExecutionContext; |
36 struct FileMetadata; | 37 struct FileMetadata; |
37 class KURL; | 38 class KURL; |
38 | 39 |
39 class File FINAL : public Blob { | 40 class File FINAL : public Blob { |
40 public: | 41 public: |
41 // AllContentTypes should only be used when the full path/name are trusted;
otherwise, it could | 42 // AllContentTypes should only be used when the full path/name are trusted;
otherwise, it could |
42 // allow arbitrary pages to determine what applications an user has installe
d. | 43 // allow arbitrary pages to determine what applications an user has installe
d. |
43 enum ContentTypeLookupPolicy { | 44 enum ContentTypeLookupPolicy { |
44 WellKnownContentTypes, | 45 WellKnownContentTypes, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 81 |
81 // 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. | 82 // 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. |
82 static PassRefPtr<File> createWithName(const String& path, const String& nam
e, ContentTypeLookupPolicy policy = WellKnownContentTypes) | 83 static PassRefPtr<File> createWithName(const String& path, const String& nam
e, ContentTypeLookupPolicy policy = WellKnownContentTypes) |
83 { | 84 { |
84 if (name.isEmpty()) | 85 if (name.isEmpty()) |
85 return adoptRef(new File(path, policy)); | 86 return adoptRef(new File(path, policy)); |
86 return adoptRef(new File(path, name, policy)); | 87 return adoptRef(new File(path, name, policy)); |
87 } | 88 } |
88 | 89 |
89 virtual unsigned long long size() const OVERRIDE; | 90 virtual unsigned long long size() const OVERRIDE; |
90 virtual PassRefPtr<Blob> slice(long long start = 0, long long end = std::num
eric_limits<long long>::max(), const String& contentType = String()) const OVERR
IDE; | 91 virtual PassRefPtr<Blob> slice(long long start, long long end, const String&
contentType, ExceptionState&) const OVERRIDE; |
91 virtual void close(ExecutionContext*) OVERRIDE; | 92 virtual void close(ExecutionContext*, ExceptionState&) OVERRIDE; |
92 | 93 |
93 virtual bool isFile() const OVERRIDE { return true; } | 94 virtual bool isFile() const OVERRIDE { return true; } |
94 virtual bool hasBackingFile() const OVERRIDE { return m_hasBackingFile; } | 95 virtual bool hasBackingFile() const OVERRIDE { return m_hasBackingFile; } |
95 | 96 |
96 virtual void appendTo(BlobData&) const OVERRIDE; | 97 virtual void appendTo(BlobData&) const OVERRIDE; |
97 | 98 |
98 const String& path() const { ASSERT(hasValidFilePath()); return m_path; } | 99 const String& path() const { ASSERT(hasValidFilePath()); return m_path; } |
99 const String name() const { return m_name; } | 100 const String name() const { return m_name; } |
100 | 101 |
101 // 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). | 102 // 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). |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 const double m_snapshotModificationTime; | 139 const double m_snapshotModificationTime; |
139 | 140 |
140 String m_relativePath; | 141 String m_relativePath; |
141 }; | 142 }; |
142 | 143 |
143 DEFINE_TYPE_CASTS(File, Blob, blob, blob->isFile(), blob.isFile()); | 144 DEFINE_TYPE_CASTS(File, Blob, blob, blob->isFile(), blob.isFile()); |
144 | 145 |
145 } // namespace WebCore | 146 } // namespace WebCore |
146 | 147 |
147 #endif // File_h | 148 #endif // File_h |
OLD | NEW |