Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / common / indexed_db / indexed_db_key.h
blob60878a3b6998a23ada08c217ccc221bbe21a022b
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.
5 #ifndef CONTENT_COMMON_INDEXED_DB_INDEXED_DB_KEY_H_
6 #define CONTENT_COMMON_INDEXED_DB_INDEXED_DB_KEY_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_vector.h"
13 #include "base/strings/string16.h"
14 #include "content/common/content_export.h"
15 #include "third_party/WebKit/public/platform/WebIDBTypes.h"
17 namespace blink {
18 class WebIDBKey;
21 namespace content {
23 class CONTENT_EXPORT IndexedDBKey {
24 public:
25 typedef std::vector<IndexedDBKey> KeyArray;
27 IndexedDBKey(); // Defaults to blink::WebIDBKeyTypeInvalid.
28 explicit IndexedDBKey(blink::WebIDBKeyType); // must be Null or Invalid
29 explicit IndexedDBKey(const KeyArray& array);
30 explicit IndexedDBKey(const std::string& binary);
31 explicit IndexedDBKey(const base::string16& string);
32 IndexedDBKey(double number,
33 blink::WebIDBKeyType type); // must be date or number
34 IndexedDBKey(const IndexedDBKey& other);
35 ~IndexedDBKey();
37 IndexedDBKey& operator=(const IndexedDBKey& other);
39 bool IsValid() const;
41 bool IsLessThan(const IndexedDBKey& other) const;
42 bool Equals(const IndexedDBKey& other) const;
44 blink::WebIDBKeyType type() const { return type_; }
45 const std::vector<IndexedDBKey>& array() const { return array_; }
46 const std::string& binary() const { return binary_; }
47 const base::string16& string() const { return string_; }
48 double date() const { return date_; }
49 double number() const { return number_; }
51 size_t size_estimate() const { return size_estimate_; }
53 private:
54 int CompareTo(const IndexedDBKey& other) const;
56 blink::WebIDBKeyType type_;
57 std::vector<IndexedDBKey> array_;
58 std::string binary_;
59 base::string16 string_;
60 double date_;
61 double number_;
63 size_t size_estimate_;
66 } // namespace content
68 #endif // CONTENT_COMMON_INDEXED_DB_INDEXED_DB_KEY_H_