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

Side by Side Diff: WebCore/fileapi/File.cpp

Issue 11192017: ********** WebCore blob hacking (Closed) Base URL: http://svn.webkit.org/repository/webkit/trunk/Source/
Patch Set: Created 7 years, 11 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 | « WebCore/fileapi/File.h ('k') | WebCore/fileapi/FileReader.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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 OwnPtr<BlobData> blobData = BlobData::create(); 73 OwnPtr<BlobData> blobData = BlobData::create();
74 blobData->setContentType(getContentTypeFromFileName(fileSystemName, File::We llKnownContentTypes)); 74 blobData->setContentType(getContentTypeFromFileName(fileSystemName, File::We llKnownContentTypes));
75 blobData->appendFile(metadata.platformPath, 0, metadata.length, metadata.mod ificationTime); 75 blobData->appendFile(metadata.platformPath, 0, metadata.length, metadata.mod ificationTime);
76 return blobData.release(); 76 return blobData.release();
77 } 77 }
78 78
79 static PassOwnPtr<BlobData> createBlobDataForFileSystemURL(const KURL& fileSyste mURL, const FileMetadata& metadata) 79 static PassOwnPtr<BlobData> createBlobDataForFileSystemURL(const KURL& fileSyste mURL, const FileMetadata& metadata)
80 { 80 {
81 OwnPtr<BlobData> blobData = BlobData::create(); 81 OwnPtr<BlobData> blobData = BlobData::create();
82 blobData->setContentType(getContentTypeFromFileName(fileSystemURL.path(), Fi le::WellKnownContentTypes)); 82 blobData->setContentType(getContentTypeFromFileName(fileSystemURL.path(), Fi le::WellKnownContentTypes));
83 blobData->appendURL(fileSystemURL, 0, metadata.length, metadata.modification Time); 83 blobData->appendFileSystemURL(fileSystemURL, 0, metadata.length, metadata.mo dificationTime);
84 return blobData.release(); 84 return blobData.release();
85 } 85 }
86 #endif 86 #endif
87 87
88 #if ENABLE(DIRECTORY_UPLOAD) 88 #if ENABLE(DIRECTORY_UPLOAD)
89 PassRefPtr<File> File::createWithRelativePath(const String& path, const String& relativePath) 89 PassRefPtr<File> File::createWithRelativePath(const String& path, const String& relativePath)
90 { 90 {
91 RefPtr<File> file = adoptRef(new File(path, AllContentTypes)); 91 RefPtr<File> file = adoptRef(new File(path, AllContentTypes));
92 file->m_relativePath = relativePath; 92 file->m_relativePath = relativePath;
93 return file.release(); 93 return file.release();
94 } 94 }
95 #endif 95 #endif
96 96
97 File::File(const String& path, ContentTypeLookupPolicy policy) 97 File::File(const String& path, ContentTypeLookupPolicy policy)
98 : Blob(createBlobDataForFile(path, policy), -1) 98 : Blob(BlobDataHandle::create(createBlobDataForFile(path, policy), -1))
99 , m_path(path) 99 , m_path(path)
100 , m_name(pathGetFileName(path)) 100 , m_name(pathGetFileName(path))
101 #if ENABLE(FILE_SYSTEM) 101 #if ENABLE(FILE_SYSTEM)
102 , m_snapshotSize(-1) 102 , m_snapshotSize(-1)
103 , m_snapshotModificationTime(invalidFileTime()) 103 , m_snapshotModificationTime(invalidFileTime())
104 #endif 104 #endif
105 { 105 {
106 } 106 }
107 107
108 File::File(const String& path, const KURL& url, const String& type) 108 File::File(const String& path, const String& uuid, const String& type)
109 : Blob(url, type, -1) 109 : Blob(BlobDataHandle::create(uuid, type, -1))
110 , m_path(path) 110 , m_path(path)
111 #if ENABLE(FILE_SYSTEM) 111 #if ENABLE(FILE_SYSTEM)
112 , m_snapshotSize(-1) 112 , m_snapshotSize(-1)
113 , m_snapshotModificationTime(invalidFileTime()) 113 , m_snapshotModificationTime(invalidFileTime())
114 #endif 114 #endif
115 { 115 {
116 m_name = pathGetFileName(path); 116 m_name = pathGetFileName(path);
117 // FIXME: File object serialization/deserialization does not include 117 // FIXME: File object serialization/deserialization does not include
118 // newer file object data members: m_name and m_relativePath. 118 // newer file object data members: m_name and m_relativePath.
119 // See SerializedScriptValue.cpp for js and v8. 119 // See SerializedScriptValue.cpp for js and v8.
120 } 120 }
121 121
122 File::File(const String& path, const String& name, ContentTypeLookupPolicy polic y) 122 File::File(const String& path, const String& name, ContentTypeLookupPolicy polic y)
123 : Blob(createBlobDataForFileWithName(path, name, policy), -1) 123 : Blob(BlobDataHandle::create(createBlobDataForFileWithName(path, name, poli cy), -1))
124 , m_path(path) 124 , m_path(path)
125 , m_name(name) 125 , m_name(name)
126 #if ENABLE(FILE_SYSTEM) 126 #if ENABLE(FILE_SYSTEM)
127 , m_snapshotSize(-1) 127 , m_snapshotSize(-1)
128 , m_snapshotModificationTime(invalidFileTime()) 128 , m_snapshotModificationTime(invalidFileTime())
129 #endif 129 #endif
130 { 130 {
131 } 131 }
132 132
133 File::File(const String& path, PassRefPtr<BlobDataHandle> blobDataHandle)
134 : Blob(blobDataHandle)
135 , m_path(path)
136 #if ENABLE(FILE_SYSTEM)
137 , m_snapshotSize(-1)
138 , m_snapshotModificationTime(invalidFileTime())
139 #endif
140 {
141 m_name = pathGetFileName(path);
142 // FIXME: File object serialization/deserialization does not include
143 // newer file object data members: m_name and m_relativePath.
144 // See SerializedScriptValue.cpp for js and v8.
145 }
146
133 #if ENABLE(FILE_SYSTEM) 147 #if ENABLE(FILE_SYSTEM)
134 File::File(const String& name, const FileMetadata& metadata) 148 File::File(const String& name, const FileMetadata& metadata)
135 : Blob(createBlobDataForFileWithMetadata(name, metadata), metadata.length) 149 : Blob(BlobDataHandle::create(createBlobDataForFileWithMetadata(name, metada ta), metadata.length))
136 , m_path(metadata.platformPath) 150 , m_path(metadata.platformPath)
137 , m_name(name) 151 , m_name(name)
138 , m_snapshotSize(metadata.length) 152 , m_snapshotSize(metadata.length)
139 , m_snapshotModificationTime(metadata.modificationTime) 153 , m_snapshotModificationTime(metadata.modificationTime)
140 { 154 {
141 } 155 }
142 156
143 File::File(const KURL& fileSystemURL, const FileMetadata& metadata) 157 File::File(const KURL& fileSystemURL, const FileMetadata& metadata)
144 : Blob(createBlobDataForFileSystemURL(fileSystemURL, metadata), metadata.len gth) 158 : Blob(BlobDataHandle::create(createBlobDataForFileSystemURL(fileSystemURL, metadata), metadata.length))
145 , m_fileSystemURL(fileSystemURL) 159 , m_fileSystemURL(fileSystemURL)
146 , m_snapshotSize(metadata.length) 160 , m_snapshotSize(metadata.length)
147 , m_snapshotModificationTime(metadata.modificationTime) 161 , m_snapshotModificationTime(metadata.modificationTime)
148 { 162 {
149 } 163 }
150 #endif 164 #endif
151 165
152 double File::lastModifiedDate() const 166 double File::lastModifiedDate() const
153 { 167 {
154 #if ENABLE(FILE_SYSTEM) 168 #if ENABLE(FILE_SYSTEM)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 snapshotSize = 0; 210 snapshotSize = 0;
197 snapshotModificationTime = invalidFileTime(); 211 snapshotModificationTime = invalidFileTime();
198 return; 212 return;
199 } 213 }
200 214
201 snapshotSize = metadata.length; 215 snapshotSize = metadata.length;
202 snapshotModificationTime = metadata.modificationTime; 216 snapshotModificationTime = metadata.modificationTime;
203 } 217 }
204 218
205 } // namespace WebCore 219 } // namespace WebCore
OLDNEW
« no previous file with comments | « WebCore/fileapi/File.h ('k') | WebCore/fileapi/FileReader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698