Home | History | Annotate | Download | only in indexed_db
      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 WebKit {
     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 WebKit::WebIDBKeyTypeInvalid.
     27   IndexedDBKey(WebKit::WebIDBKeyType);  // must be Null or Invalid
     28   explicit IndexedDBKey(const KeyArray& array);
     29   explicit IndexedDBKey(const string16& str);
     30   IndexedDBKey(double number,
     31                WebKit::WebIDBKeyType type);  // must be date or number
     32   ~IndexedDBKey();
     33 
     34   bool IsValid() const;
     35 
     36   int Compare(const IndexedDBKey& other) const;
     37   bool IsLessThan(const IndexedDBKey& other) const;
     38   bool IsEqual(const IndexedDBKey& other) const;
     39 
     40   WebKit::WebIDBKeyType type() const { return type_; }
     41   const std::vector<IndexedDBKey>& array() const { return array_; }
     42   const string16& string() const { return string_; }
     43   double date() const { return date_; }
     44   double number() const { return number_; }
     45 
     46   size_t size_estimate() const { return size_estimate_; }
     47 
     48  private:
     49   WebKit::WebIDBKeyType type_;
     50   std::vector<IndexedDBKey> array_;
     51   string16 string_;
     52   double date_;
     53   double number_;
     54 
     55   size_t size_estimate_;
     56 };
     57 
     58 }  // namespace content
     59 
     60 #endif  // CONTENT_COMMON_INDEXED_DB_INDEXED_DB_KEY_H_
     61