| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_COMMON_INDEXED_DB_INDEXED_DB_KEY_H_ | 5 #ifndef CONTENT_COMMON_INDEXED_DB_INDEXED_DB_KEY_H_ |
| 6 #define CONTENT_COMMON_INDEXED_DB_INDEXED_DB_KEY_H_ | 6 #define CONTENT_COMMON_INDEXED_DB_INDEXED_DB_KEY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/logging.h" |
| 12 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 13 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 14 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 15 #include "third_party/WebKit/public/platform/WebIDBTypes.h" | 16 #include "third_party/WebKit/public/platform/WebIDBTypes.h" |
| 16 | 17 |
| 17 namespace blink { | 18 namespace blink { |
| 18 class WebIDBKey; | 19 class WebIDBKey; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace content { | 22 namespace content { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 34 IndexedDBKey(const IndexedDBKey& other); | 35 IndexedDBKey(const IndexedDBKey& other); |
| 35 ~IndexedDBKey(); | 36 ~IndexedDBKey(); |
| 36 IndexedDBKey& operator=(const IndexedDBKey& other); | 37 IndexedDBKey& operator=(const IndexedDBKey& other); |
| 37 | 38 |
| 38 bool IsValid() const; | 39 bool IsValid() const; |
| 39 | 40 |
| 40 bool IsLessThan(const IndexedDBKey& other) const; | 41 bool IsLessThan(const IndexedDBKey& other) const; |
| 41 bool Equals(const IndexedDBKey& other) const; | 42 bool Equals(const IndexedDBKey& other) const; |
| 42 | 43 |
| 43 blink::WebIDBKeyType type() const { return type_; } | 44 blink::WebIDBKeyType type() const { return type_; } |
| 44 const std::vector<IndexedDBKey>& array() const { return array_; } | 45 const std::vector<IndexedDBKey>& array() const { |
| 45 const std::string& binary() const { return binary_; } | 46 DCHECK_EQ(type_, blink::WebIDBKeyTypeArray); |
| 46 const base::string16& string() const { return string_; } | 47 return array_; |
| 47 double date() const { return date_; } | 48 } |
| 48 double number() const { return number_; } | 49 const std::string& binary() const { |
| 50 DCHECK_EQ(type_, blink::WebIDBKeyTypeBinary); |
| 51 return binary_; |
| 52 } |
| 53 const base::string16& string() const { |
| 54 DCHECK_EQ(type_, blink::WebIDBKeyTypeString); |
| 55 return string_; |
| 56 } |
| 57 double date() const { |
| 58 DCHECK_EQ(type_, blink::WebIDBKeyTypeDate); |
| 59 return number_; |
| 60 } |
| 61 double number() const { |
| 62 DCHECK_EQ(type_, blink::WebIDBKeyTypeNumber); |
| 63 return number_; |
| 64 } |
| 49 | 65 |
| 50 size_t size_estimate() const { return size_estimate_; } | 66 size_t size_estimate() const { return size_estimate_; } |
| 51 | 67 |
| 52 private: | 68 private: |
| 53 int CompareTo(const IndexedDBKey& other) const; | 69 int CompareTo(const IndexedDBKey& other) const; |
| 54 | 70 |
| 55 blink::WebIDBKeyType type_; | 71 blink::WebIDBKeyType type_; |
| 56 std::vector<IndexedDBKey> array_; | 72 std::vector<IndexedDBKey> array_; |
| 57 std::string binary_; | 73 std::string binary_; |
| 58 base::string16 string_; | 74 base::string16 string_; |
| 59 double date_; | 75 double number_ = 0; |
| 60 double number_; | |
| 61 | 76 |
| 62 size_t size_estimate_; | 77 size_t size_estimate_; |
| 63 }; | 78 }; |
| 64 | 79 |
| 65 } // namespace content | 80 } // namespace content |
| 66 | 81 |
| 67 #endif // CONTENT_COMMON_INDEXED_DB_INDEXED_DB_KEY_H_ | 82 #endif // CONTENT_COMMON_INDEXED_DB_INDEXED_DB_KEY_H_ |
| OLD | NEW |