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

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

Issue 100023005: Make cloning of File objects more useful. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Reupload Created 7 years 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 | « Source/bindings/v8/SerializedScriptValue.cpp ('k') | Source/core/fileapi/File.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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 { 48 {
49 return adoptRef(new File(path, policy)); 49 return adoptRef(new File(path, policy));
50 } 50 }
51 51
52 static PassRefPtr<File> create(const String& name, double modificationTime, PassRefPtr<BlobDataHandle> blobDataHandle) 52 static PassRefPtr<File> create(const String& name, double modificationTime, PassRefPtr<BlobDataHandle> blobDataHandle)
53 { 53 {
54 return adoptRef(new File(name, modificationTime, blobDataHandle)); 54 return adoptRef(new File(name, modificationTime, blobDataHandle));
55 } 55 }
56 56
57 // For deserialization. 57 // For deserialization.
58 static PassRefPtr<File> create(const String& path, PassRefPtr<BlobDataHandle > blobDataHandle) 58 static PassRefPtr<File> create(const String& path, const String& name, const String& relativePath, bool hasSnaphotData, uint64_t size, double lastModified, PassRefPtr<BlobDataHandle> blobDataHandle)
59 { 59 {
60 return adoptRef(new File(path, blobDataHandle)); 60 return adoptRef(new File(path, name, relativePath, hasSnaphotData, size, lastModified, blobDataHandle));
61 } 61 }
62 62
63 static PassRefPtr<File> createWithRelativePath(const String& path, const Str ing& relativePath); 63 static PassRefPtr<File> createWithRelativePath(const String& path, const Str ing& relativePath);
64 64
65 // 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 // 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.
66 // 66 //
67 // Otherwise calling size(), lastModifiedTime() and slice() will synchronous ly query the file metadata. 67 // Otherwise calling size(), lastModifiedTime() and slice() will synchronous ly query the file metadata.
68 static PassRefPtr<File> createForFileSystemFile(const String& name, const Fi leMetadata& metadata) 68 static PassRefPtr<File> createForFileSystemFile(const String& name, const Fi leMetadata& metadata)
69 { 69 {
70 return adoptRef(new File(name, metadata)); 70 return adoptRef(new File(name, metadata));
(...skipping 23 matching lines...) Expand all
94 94
95 // This returns the current date and time if the file's last modifiecation d ate is not known (per spec: http://www.w3.org/TR/FileAPI/#dfn-lastModifiedDate). 95 // This returns the current date and time if the file's last modifiecation d ate is not known (per spec: http://www.w3.org/TR/FileAPI/#dfn-lastModifiedDate).
96 double lastModifiedDate() const; 96 double lastModifiedDate() const;
97 97
98 // Returns the relative path of this file in the context of a directory sele ction. 98 // Returns the relative path of this file in the context of a directory sele ction.
99 const String& webkitRelativePath() const { return m_relativePath; } 99 const String& webkitRelativePath() const { return m_relativePath; }
100 100
101 // Note that this involves synchronous file operation. Think twice before ca lling this function. 101 // Note that this involves synchronous file operation. Think twice before ca lling this function.
102 void captureSnapshot(long long& snapshotSize, double& snapshotModificationTi me) const; 102 void captureSnapshot(long long& snapshotSize, double& snapshotModificationTi me) const;
103 103
104 // Returns true if this has a valid snapshot metadata (i.e. m_snapshotSize > = 0).
105 bool hasValidSnapshotMetadata() const { return m_snapshotSize >= 0; }
106
104 private: 107 private:
105 File(const String& path, ContentTypeLookupPolicy); 108 File(const String& path, ContentTypeLookupPolicy);
106 File(const String& path, const String& name, ContentTypeLookupPolicy); 109 File(const String& path, const String& name, ContentTypeLookupPolicy);
107 File(const String& path, PassRefPtr<BlobDataHandle>); 110 File(const String& path, const String& name, const String& relativePath, boo l hasSnaphotData, uint64_t size, double lastModified, PassRefPtr<BlobDataHandle> );
108 File(const String& name, double modificationTime, PassRefPtr<BlobDataHandle> ); 111 File(const String& name, double modificationTime, PassRefPtr<BlobDataHandle> );
109 File(const String& name, const FileMetadata&); 112 File(const String& name, const FileMetadata&);
110 File(const KURL& fileSystemURL, const FileMetadata&); 113 File(const KURL& fileSystemURL, const FileMetadata&);
111 114
112 // Returns true if this has a valid snapshot metadata (i.e. m_snapshotSize > = 0).
113 bool hasValidSnapshotMetadata() const { return m_snapshotSize >= 0; }
114
115 bool m_hasBackingFile; 115 bool m_hasBackingFile;
116 String m_path; 116 String m_path;
117 String m_name; 117 String m_name;
118 118
119 KURL m_fileSystemURL; 119 KURL m_fileSystemURL;
120 120
121 // 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(). 121 // 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().
122 // Otherwise, the snapshot metadata are used directly in those methods. 122 // Otherwise, the snapshot metadata are used directly in those methods.
123 const long long m_snapshotSize; 123 const long long m_snapshotSize;
124 const double m_snapshotModificationTime; 124 const double m_snapshotModificationTime;
125 125
126 String m_relativePath; 126 String m_relativePath;
127 }; 127 };
128 128
129 DEFINE_TYPE_CASTS(File, Blob, blob, blob->isFile(), blob.isFile()); 129 DEFINE_TYPE_CASTS(File, Blob, blob, blob->isFile(), blob.isFile());
130 130
131 } // namespace WebCore 131 } // namespace WebCore
132 132
133 #endif // File_h 133 #endif // File_h
OLDNEW
« no previous file with comments | « Source/bindings/v8/SerializedScriptValue.cpp ('k') | Source/core/fileapi/File.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698