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