Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google 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 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 #include "modules/indexeddb/IDBKey.h" | 30 #include "modules/indexeddb/IDBKey.h" |
| 31 #include "modules/indexeddb/IDBKeyPath.h" | 31 #include "modules/indexeddb/IDBKeyPath.h" |
| 32 #include "platform/SharedBuffer.h" | 32 #include "platform/SharedBuffer.h" |
| 33 #include "wtf/PassRefPtr.h" | 33 #include "wtf/PassRefPtr.h" |
| 34 #include "wtf/RefCounted.h" | 34 #include "wtf/RefCounted.h" |
| 35 #include "wtf/RefPtr.h" | 35 #include "wtf/RefPtr.h" |
| 36 #include "wtf/text/WTFString.h" | 36 #include "wtf/text/WTFString.h" |
| 37 | 37 |
| 38 namespace WebCore { | 38 namespace WebCore { |
| 39 | 39 |
| 40 class BlobInfo; | |
| 40 class DOMStringList; | 41 class DOMStringList; |
| 41 class IDBCursor; | 42 class IDBCursor; |
| 42 class IDBCursorWithValue; | 43 class IDBCursorWithValue; |
| 43 class IDBDatabase; | 44 class IDBDatabase; |
| 44 class IDBFactory; | 45 class IDBFactory; |
| 45 class IDBIndex; | 46 class IDBIndex; |
| 46 class IDBKeyPath; | 47 class IDBKeyPath; |
| 47 class IDBObjectStore; | 48 class IDBObjectStore; |
| 48 class IDBTransaction; | 49 class IDBTransaction; |
| 49 | 50 |
| 50 class IDBAny : public RefCounted<IDBAny> { | 51 class IDBAny : public RefCounted<IDBAny> { |
| 51 public: | 52 public: |
| 52 static PassRefPtr<IDBAny> createUndefined(); | 53 static PassRefPtr<IDBAny> createUndefined(); |
| 53 static PassRefPtr<IDBAny> createNull(); | 54 static PassRefPtr<IDBAny> createNull(); |
| 54 static PassRefPtr<IDBAny> createString(const String&); | 55 static PassRefPtr<IDBAny> createString(const String&); |
| 55 template<typename T> | 56 template<typename T> |
| 56 static PassRefPtr<IDBAny> create(T* idbObject) | 57 static PassRefPtr<IDBAny> create(T* idbObject) |
| 57 { | 58 { |
| 58 return adoptRef(new IDBAny(idbObject)); | 59 return adoptRef(new IDBAny(idbObject)); |
| 59 } | 60 } |
| 60 template<typename T> | 61 template<typename T> |
| 61 static PassRefPtr<IDBAny> create(const T& idbObject) | 62 static PassRefPtr<IDBAny> create(const T& idbObject) |
| 62 { | 63 { |
| 63 return adoptRef(new IDBAny(idbObject)); | 64 return adoptRef(new IDBAny(idbObject)); |
| 64 } | 65 } |
| 66 static PassRefPtr<IDBAny> create(PassRefPtr<SharedBuffer> value, const Vecto r<BlobInfo>* blobInfo) | |
| 67 { | |
| 68 return adoptRef(new IDBAny(value, blobInfo)); | |
| 69 } | |
| 65 template<typename T> | 70 template<typename T> |
| 66 static PassRefPtr<IDBAny> create(PassRefPtr<T> idbObject) | 71 static PassRefPtr<IDBAny> create(PassRefPtr<T> idbObject) |
| 67 { | 72 { |
| 68 return adoptRef(new IDBAny(idbObject)); | 73 return adoptRef(new IDBAny(idbObject)); |
| 69 } | 74 } |
| 70 static PassRefPtr<IDBAny> create(int64_t value) | 75 static PassRefPtr<IDBAny> create(int64_t value) |
| 71 { | 76 { |
| 72 return adoptRef(new IDBAny(value)); | 77 return adoptRef(new IDBAny(value)); |
| 73 } | 78 } |
| 74 static PassRefPtr<IDBAny> create(PassRefPtr<SharedBuffer> value, PassRefPtr< IDBKey> key, const IDBKeyPath& keyPath) | 79 static PassRefPtr<IDBAny> create(PassRefPtr<SharedBuffer> value, const Vecto r<BlobInfo>* blobInfo, PassRefPtr<IDBKey> key, const IDBKeyPath& keyPath) |
| 75 { | 80 { |
| 76 return adoptRef(new IDBAny(value, key, keyPath)); | 81 return adoptRef(new IDBAny(value, blobInfo, key, keyPath)); |
| 77 } | 82 } |
| 78 ~IDBAny(); | 83 ~IDBAny(); |
| 79 | 84 |
| 80 enum Type { | 85 enum Type { |
| 81 UndefinedType = 0, | 86 UndefinedType = 0, |
| 82 NullType, | 87 NullType, |
| 83 DOMStringListType, | 88 DOMStringListType, |
| 84 IDBCursorType, | 89 IDBCursorType, |
| 85 IDBCursorWithValueType, | 90 IDBCursorWithValueType, |
| 86 IDBDatabaseType, | 91 IDBDatabaseType, |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 100 // Use type() to figure out which one of these you're allowed to call. | 105 // Use type() to figure out which one of these you're allowed to call. |
| 101 DOMStringList* domStringList(); | 106 DOMStringList* domStringList(); |
| 102 IDBCursor* idbCursor(); | 107 IDBCursor* idbCursor(); |
| 103 IDBCursorWithValue* idbCursorWithValue(); | 108 IDBCursorWithValue* idbCursorWithValue(); |
| 104 IDBDatabase* idbDatabase(); | 109 IDBDatabase* idbDatabase(); |
| 105 IDBFactory* idbFactory(); | 110 IDBFactory* idbFactory(); |
| 106 IDBIndex* idbIndex(); | 111 IDBIndex* idbIndex(); |
| 107 IDBObjectStore* idbObjectStore(); | 112 IDBObjectStore* idbObjectStore(); |
| 108 IDBTransaction* idbTransaction(); | 113 IDBTransaction* idbTransaction(); |
| 109 SharedBuffer* buffer(); | 114 SharedBuffer* buffer(); |
| 115 const Vector<BlobInfo>* blobInfo() const; | |
| 110 int64_t integer(); | 116 int64_t integer(); |
| 111 const String& string(); | 117 const String& string(); |
| 112 IDBKey* key(); | 118 IDBKey* key(); |
| 113 const IDBKeyPath& keyPath() const; | 119 const IDBKeyPath& keyPath() const; |
| 114 | 120 |
| 115 private: | 121 private: |
| 116 explicit IDBAny(Type); | 122 explicit IDBAny(Type); |
| 117 explicit IDBAny(PassRefPtr<DOMStringList>); | 123 explicit IDBAny(PassRefPtr<DOMStringList>); |
| 118 explicit IDBAny(PassRefPtr<IDBCursor>); | 124 explicit IDBAny(PassRefPtr<IDBCursor>); |
| 119 explicit IDBAny(PassRefPtr<IDBDatabase>); | 125 explicit IDBAny(PassRefPtr<IDBDatabase>); |
| 120 explicit IDBAny(PassRefPtr<IDBFactory>); | 126 explicit IDBAny(PassRefPtr<IDBFactory>); |
| 121 explicit IDBAny(PassRefPtr<IDBIndex>); | 127 explicit IDBAny(PassRefPtr<IDBIndex>); |
| 122 explicit IDBAny(PassRefPtr<IDBObjectStore>); | 128 explicit IDBAny(PassRefPtr<IDBObjectStore>); |
| 123 explicit IDBAny(PassRefPtr<IDBTransaction>); | 129 explicit IDBAny(PassRefPtr<IDBTransaction>); |
| 124 explicit IDBAny(PassRefPtr<IDBKey>); | 130 explicit IDBAny(PassRefPtr<IDBKey>); |
| 125 explicit IDBAny(const IDBKeyPath&); | 131 explicit IDBAny(const IDBKeyPath&); |
| 126 explicit IDBAny(const String&); | 132 explicit IDBAny(const String&); |
| 127 explicit IDBAny(PassRefPtr<SharedBuffer>); | 133 explicit IDBAny(PassRefPtr<SharedBuffer>, const Vector<BlobInfo>*); |
|
jsbell
2013/12/20 19:13:54
Nit: Don't need explicit on multi-parameter constr
ericu
2014/02/12 19:12:55
Done.
| |
| 128 explicit IDBAny(PassRefPtr<SharedBuffer>, PassRefPtr<IDBKey>, const IDBKeyPa th&); | 134 explicit IDBAny(PassRefPtr<SharedBuffer>, const Vector<BlobInfo>*, PassRefPt r<IDBKey>, const IDBKeyPath&); |
| 129 explicit IDBAny(int64_t); | 135 explicit IDBAny(int64_t); |
| 130 | 136 |
| 131 const Type m_type; | 137 const Type m_type; |
| 132 | 138 |
| 133 // Only one of the following should ever be in use at any given time. | 139 // Only one of the following should ever be in use at any given time, except that BufferType uses two and BufferKeyAndKeyPathType uses four. |
|
jsbell
2013/12/20 19:13:54
Thanks for the comment update.
| |
| 134 const RefPtr<DOMStringList> m_domStringList; | 140 const RefPtr<DOMStringList> m_domStringList; |
| 135 const RefPtr<IDBCursor> m_idbCursor; | 141 const RefPtr<IDBCursor> m_idbCursor; |
| 136 const RefPtr<IDBDatabase> m_idbDatabase; | 142 const RefPtr<IDBDatabase> m_idbDatabase; |
| 137 const RefPtr<IDBFactory> m_idbFactory; | 143 const RefPtr<IDBFactory> m_idbFactory; |
| 138 const RefPtr<IDBIndex> m_idbIndex; | 144 const RefPtr<IDBIndex> m_idbIndex; |
| 139 const RefPtr<IDBObjectStore> m_idbObjectStore; | 145 const RefPtr<IDBObjectStore> m_idbObjectStore; |
| 140 const RefPtr<IDBTransaction> m_idbTransaction; | 146 const RefPtr<IDBTransaction> m_idbTransaction; |
| 141 const RefPtr<IDBKey> m_idbKey; | 147 const RefPtr<IDBKey> m_idbKey; |
| 142 const IDBKeyPath m_idbKeyPath; | 148 const IDBKeyPath m_idbKeyPath; |
| 143 const RefPtr<SharedBuffer> m_buffer; | 149 const RefPtr<SharedBuffer> m_buffer; |
| 150 const Vector<BlobInfo>* m_blobInfo; | |
| 144 const String m_string; | 151 const String m_string; |
| 145 const int64_t m_integer; | 152 const int64_t m_integer; |
| 146 }; | 153 }; |
| 147 | 154 |
| 148 } // namespace WebCore | 155 } // namespace WebCore |
| 149 | 156 |
| 150 #endif // IDBAny_h | 157 #endif // IDBAny_h |
| OLD | NEW |