Index: Source/platform/blob/BlobInfo.h |
diff --git a/Source/bindings/v8/V8GarbageCollected.h b/Source/platform/blob/BlobInfo.h |
similarity index 51% |
copy from Source/bindings/v8/V8GarbageCollected.h |
copy to Source/platform/blob/BlobInfo.h |
index 0645b6ba7193221c847e1a33ec3bdd2a672fd986..dd006d3cee06fb6e9a88a303e44fb0724a56e3ef 100644 |
--- a/Source/bindings/v8/V8GarbageCollected.h |
+++ b/Source/platform/blob/BlobInfo.h |
@@ -28,59 +28,67 @@ |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
-#ifndef V8GarbageCollected_h |
-#define V8GarbageCollected_h |
+#ifndef BlobInfo_h |
+#define BlobInfo_h |
-#include <v8.h> |
+#include "wtf/text/WTFString.h" |
namespace WebCore { |
-template<typename T> |
-class V8GarbageCollected { |
- WTF_MAKE_NONCOPYABLE(V8GarbageCollected); |
+class BlobInfo { |
public: |
- static T* Cast(v8::Handle<v8::Value> value) |
+ BlobInfo() |
+ : m_isFile(false) |
+ , m_size(-1) |
cmumford
2014/03/20 18:22:32
Should initialize m_lastModified.
ericu
2014/03/25 00:00:26
Done.
|
{ |
- ASSERT(value->IsExternal()); |
- T* result = static_cast<T*>(value.As<v8::External>()->Value()); |
- RELEASE_ASSERT(result->m_handle == value); |
- return result; |
} |
- |
-protected: |
- V8GarbageCollected(v8::Isolate* isolate) |
- : m_isolate(isolate) |
- , m_handle(isolate, v8::External::New(isolate, static_cast<T*>(this))) |
+ BlobInfo(const String& uuid, const String& type, long long size) |
+ : m_isFile(false) |
+ , m_uuid(uuid) |
+ , m_type(type) |
+ , m_size(size) |
+ , m_lastModified(0) |
{ |
} |
- |
- v8::Handle<v8::External> releaseToV8GarbageCollector() |
+ BlobInfo(const String& uuid, const String& filePath, const String& fileName, const String& type, double lastModified, long long size) |
+ : m_isFile(true) |
+ , m_uuid(uuid) |
+ , m_type(type) |
+ , m_size(size) |
+ , m_filePath(filePath) |
+ , m_fileName(fileName) |
+ , m_lastModified(lastModified) |
{ |
- ASSERT(!m_handle.isWeak()); // Call this exactly once. |
- v8::Handle<v8::External> result = m_handle.newLocal(m_isolate); |
- m_handle.setWeak(static_cast<T*>(this), &weakCallback); |
- return result; |
} |
- |
- ~V8GarbageCollected() |
+ BlobInfo(const String& uuid, const String& filePath, const String& fileName, const String& type) |
+ : m_isFile(true) |
+ , m_uuid(uuid) |
+ , m_type(type) |
+ , m_size(-1) |
jsbell
2014/03/20 16:00:46
Is there any consistency checking we should do whe
ericu
2014/03/25 00:00:26
It's used to indicate that it's a File, but that w
|
+ , m_filePath(filePath) |
+ , m_fileName(fileName) |
+ , m_lastModified(0) |
{ |
- ASSERT(m_handle.isEmpty()); |
} |
- v8::Isolate* isolate() { return m_isolate; } |
+ bool isFile() const { return m_isFile; } |
+ const String& uuid() const { return m_uuid; } |
+ const String& type() const { return m_type; } |
+ long long size() const { return m_size; } |
+ const String& filePath() const { return m_filePath; } |
+ const String& fileName() const { return m_fileName; } |
+ double lastModified() const { return m_lastModified; } |
private: |
- static void weakCallback(const v8::WeakCallbackData<v8::External, T>& data) |
- { |
- T* self = data.GetParameter(); |
- self->m_handle.clear(); |
- delete self; |
- } |
- |
- v8::Isolate* m_isolate; |
- ScopedPersistent<v8::External> m_handle; |
+ bool m_isFile; |
+ String m_uuid; |
+ String m_type; // mime type |
jsbell
2014/03/20 16:00:46
Nit: Capitalize
cmumford
2014/03/20 18:22:32
Why not call this m_MimeType instead of m_Type?
jsbell
2014/03/20 18:30:29
Sorry, I meant: capitalize the comment (here and b
cmumford
2014/03/24 23:17:46
Well being more naive than you I'd prefer the more
ericu
2014/03/25 00:00:26
Done.
I left it as type for consistency with Blob
|
+ long long m_size; |
+ String m_filePath; // only for File |
jsbell
2014/03/20 16:00:46
Nit: ditto
ericu
2014/03/25 00:00:26
Done.
|
+ String m_fileName; // only for File |
+ double m_lastModified; // only for File |
}; |
} // namespace WebCore |
-#endif // V8GarbageCollected_h |
+#endif // BlobInfo_h |