[Android WebView] Fix webview perf bot switchover to use org.chromium.webview_shell...
[chromium-blink-merge.git] / content / common / indexed_db / indexed_db_key.h
blob47fc947a943ff74098076761e0968e835cf9d10d
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/logging.h"
13 #include "base/memory/scoped_vector.h"
14 #include "base/strings/string16.h"
15 #include "content/common/content_export.h"
16 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h"
18 namespace blink {
19 class WebIDBKey;
22 namespace content {
24 class CONTENT_EXPORT IndexedDBKey {
25 public:
26 typedef std::vector<IndexedDBKey> KeyArray;
28 IndexedDBKey(); // Defaults to blink::WebIDBKeyTypeInvalid.
29 explicit IndexedDBKey(blink::WebIDBKeyType); // must be Null or Invalid
30 explicit IndexedDBKey(const KeyArray& array);
31 explicit IndexedDBKey(const std::string& binary);
32 explicit IndexedDBKey(const base::string16& string);
33 IndexedDBKey(double number,
34 blink::WebIDBKeyType type); // must be date or number
35 IndexedDBKey(const IndexedDBKey& other);
36 ~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 {
46 DCHECK_EQ(type_, blink::WebIDBKeyTypeArray);
47 return array_;
49 const std::string& binary() const {
50 DCHECK_EQ(type_, blink::WebIDBKeyTypeBinary);
51 return binary_;
53 const base::string16& string() const {
54 DCHECK_EQ(type_, blink::WebIDBKeyTypeString);
55 return string_;
57 double date() const {
58 DCHECK_EQ(type_, blink::WebIDBKeyTypeDate);
59 return number_;
61 double number() const {
62 DCHECK_EQ(type_, blink::WebIDBKeyTypeNumber);
63 return number_;
66 size_t size_estimate() const { return size_estimate_; }
68 private:
69 int CompareTo(const IndexedDBKey& other) const;
71 blink::WebIDBKeyType type_;
72 std::vector<IndexedDBKey> array_;
73 std::string binary_;
74 base::string16 string_;
75 double number_ = 0;
77 size_t size_estimate_;
80 } // namespace content
82 #endif // CONTENT_COMMON_INDEXED_DB_INDEXED_DB_KEY_H_