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

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

Issue 23992003: blob hacking webcore style (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 2 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
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 OwnPtr<BlobData> blobData = BlobData::create(); 75 OwnPtr<BlobData> blobData = BlobData::create();
76 blobData->setContentType(getContentTypeFromFileName(fileSystemName, File::We llKnownContentTypes)); 76 blobData->setContentType(getContentTypeFromFileName(fileSystemName, File::We llKnownContentTypes));
77 blobData->appendFile(metadata.platformPath, 0, metadata.length, metadata.mod ificationTime); 77 blobData->appendFile(metadata.platformPath, 0, metadata.length, metadata.mod ificationTime);
78 return blobData.release(); 78 return blobData.release();
79 } 79 }
80 80
81 static PassOwnPtr<BlobData> createBlobDataForFileSystemURL(const KURL& fileSyste mURL, const FileMetadata& metadata) 81 static PassOwnPtr<BlobData> createBlobDataForFileSystemURL(const KURL& fileSyste mURL, const FileMetadata& metadata)
82 { 82 {
83 OwnPtr<BlobData> blobData = BlobData::create(); 83 OwnPtr<BlobData> blobData = BlobData::create();
84 blobData->setContentType(getContentTypeFromFileName(fileSystemURL.path(), Fi le::WellKnownContentTypes)); 84 blobData->setContentType(getContentTypeFromFileName(fileSystemURL.path(), Fi le::WellKnownContentTypes));
85 blobData->appendURL(fileSystemURL, 0, metadata.length, metadata.modification Time); 85 blobData->appendFileSystemURL(fileSystemURL, 0, metadata.length, metadata.mo dificationTime);
86 return blobData.release(); 86 return blobData.release();
87 } 87 }
88 88
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 95
96 File::File(const String& path, ContentTypeLookupPolicy policy) 96 File::File(const String& path, ContentTypeLookupPolicy policy)
97 : Blob(createBlobDataForFile(path, policy), -1) 97 : Blob(BlobDataHandle::create(createBlobDataForFile(path, policy), -1))
98 , m_path(path) 98 , m_path(path)
99 , m_name(WebKit::Platform::current()->fileUtilities()->baseName(path)) 99 , m_name(WebKit::Platform::current()->fileUtilities()->baseName(path))
100 , m_snapshotSize(-1) 100 , m_snapshotSize(-1)
101 , m_snapshotModificationTime(invalidFileTime()) 101 , m_snapshotModificationTime(invalidFileTime())
102 { 102 {
103 ScriptWrappable::init(this); 103 ScriptWrappable::init(this);
104 } 104 }
105 105
106 File::File(const String& path, const KURL& url, const String& type)
107 : Blob(url, type, -1)
108 , m_path(path)
109 , m_snapshotSize(-1)
110 , m_snapshotModificationTime(invalidFileTime())
111 {
112 ScriptWrappable::init(this);
113 m_name = WebKit::Platform::current()->fileUtilities()->baseName(path);
114 // FIXME: File object serialization/deserialization does not include
115 // newer file object data members: m_name and m_relativePath.
116 // See SerializedScriptValue.cpp for js and v8.
117 }
118
119 File::File(const String& path, const String& name, ContentTypeLookupPolicy polic y) 106 File::File(const String& path, const String& name, ContentTypeLookupPolicy polic y)
120 : Blob(createBlobDataForFileWithName(path, name, policy), -1) 107 : Blob(BlobDataHandle::create(createBlobDataForFileWithName(path, name, poli cy), -1))
121 , m_path(path) 108 , m_path(path)
122 , m_name(name) 109 , m_name(name)
123 , m_snapshotSize(-1) 110 , m_snapshotSize(-1)
124 , m_snapshotModificationTime(invalidFileTime()) 111 , m_snapshotModificationTime(invalidFileTime())
125 { 112 {
126 ScriptWrappable::init(this); 113 ScriptWrappable::init(this);
127 } 114 }
128 115
116 File::File(const String& path, PassRefPtr<BlobDataHandle> blobDataHandle)
117 : Blob(blobDataHandle)
118 , m_path(path)
119 , m_name(WebKit::Platform::current()->fileUtilities()->baseName(path))
120 , m_snapshotSize(-1)
121 , m_snapshotModificationTime(invalidFileTime())
122 {
123 ScriptWrappable::init(this);
124 // FIXME: File object serialization/deserialization does not include
125 // newer file object data members: m_name and m_relativePath.
126 // See SerializedScriptValue.cpp.
127 }
128
129
129 File::File(const String& name, const FileMetadata& metadata) 130 File::File(const String& name, const FileMetadata& metadata)
130 : Blob(createBlobDataForFileWithMetadata(name, metadata), metadata.length) 131 : Blob(BlobDataHandle::create(createBlobDataForFileWithMetadata(name, metada ta), metadata.length))
131 , m_path(metadata.platformPath) 132 , m_path(metadata.platformPath)
132 , m_name(name) 133 , m_name(name)
133 , m_snapshotSize(metadata.length) 134 , m_snapshotSize(metadata.length)
134 , m_snapshotModificationTime(metadata.modificationTime) 135 , m_snapshotModificationTime(metadata.modificationTime)
135 { 136 {
136 ScriptWrappable::init(this); 137 ScriptWrappable::init(this);
137 } 138 }
138 139
139 File::File(const KURL& fileSystemURL, const FileMetadata& metadata) 140 File::File(const KURL& fileSystemURL, const FileMetadata& metadata)
140 : Blob(createBlobDataForFileSystemURL(fileSystemURL, metadata), metadata.len gth) 141 : Blob(BlobDataHandle::create(createBlobDataForFileSystemURL(fileSystemURL, metadata), metadata.length))
141 , m_fileSystemURL(fileSystemURL) 142 , m_fileSystemURL(fileSystemURL)
142 , m_snapshotSize(metadata.length) 143 , m_snapshotSize(metadata.length)
143 , m_snapshotModificationTime(metadata.modificationTime) 144 , m_snapshotModificationTime(metadata.modificationTime)
144 { 145 {
145 ScriptWrappable::init(this); 146 ScriptWrappable::init(this);
146 } 147 }
147 148
148 double File::lastModifiedDate() const 149 double File::lastModifiedDate() const
149 { 150 {
150 if (hasValidSnapshotMetadata() && isValidFileTime(m_snapshotModificationTime )) 151 if (hasValidSnapshotMetadata() && isValidFileTime(m_snapshotModificationTime ))
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 snapshotSize = 0; 186 snapshotSize = 0;
186 snapshotModificationTime = invalidFileTime(); 187 snapshotModificationTime = invalidFileTime();
187 return; 188 return;
188 } 189 }
189 190
190 snapshotSize = metadata.length; 191 snapshotSize = metadata.length;
191 snapshotModificationTime = metadata.modificationTime; 192 snapshotModificationTime = metadata.modificationTime;
192 } 193 }
193 194
194 } // namespace WebCore 195 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698