1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CONTENT_COMMON_INDEXED_DB_INDEXED_DB_KEY_H_ 6 #define CONTENT_COMMON_INDEXED_DB_INDEXED_DB_KEY_H_ 7 8 #include <vector> 9 10 #include "base/basictypes.h" 11 #include "base/memory/scoped_vector.h" 12 #include "base/strings/string16.h" 13 #include "content/common/content_export.h" 14 #include "third_party/WebKit/public/platform/WebIDBTypes.h" 15 16 namespace blink { 17 class WebIDBKey; 18 } 19 20 namespace content { 21 22 class CONTENT_EXPORT IndexedDBKey { 23 public: 24 typedef std::vector<IndexedDBKey> KeyArray; 25 26 IndexedDBKey(); // Defaults to blink::WebIDBKeyTypeInvalid. 27 IndexedDBKey(blink::WebIDBKeyType); // must be Null or Invalid 28 explicit IndexedDBKey(const KeyArray& array); 29 explicit IndexedDBKey(const std::string& binary); 30 explicit IndexedDBKey(const base::string16& str); 31 IndexedDBKey(double number, 32 blink::WebIDBKeyType type); // must be date or number 33 ~IndexedDBKey(); 34 35 bool IsValid() const; 36 37 int Compare(const IndexedDBKey& other) const; 38 bool IsLessThan(const IndexedDBKey& other) const; 39 bool IsEqual(const IndexedDBKey& other) const; 40 41 blink::WebIDBKeyType type() const { return type_; } 42 const std::vector<IndexedDBKey>& array() const { return array_; } 43 const std::string& binary() const { return binary_; } 44 const base::string16& string() const { return string_; } 45 double date() const { return date_; } 46 double number() const { return number_; } 47 48 size_t size_estimate() const { return size_estimate_; } 49 50 private: 51 blink::WebIDBKeyType type_; 52 std::vector<IndexedDBKey> array_; 53 std::string binary_; 54 base::string16 string_; 55 double date_; 56 double number_; 57 58 size_t size_estimate_; 59 }; 60 61 } // namespace content 62 63 #endif // CONTENT_COMMON_INDEXED_DB_INDEXED_DB_KEY_H_ 64