Home | History | Annotate | Download | only in indexed_db
      1 // Copyright (c) 2013 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_BROWSER_INDEXED_DB_INDEXED_DB_METADATA_H_
      6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_METADATA_H_
      7 
      8 #include <map>
      9 
     10 #include "base/basictypes.h"
     11 #include "base/strings/string16.h"
     12 #include "content/common/indexed_db/indexed_db_key_path.h"
     13 
     14 namespace content {
     15 
     16 struct IndexedDBIndexMetadata {
     17   IndexedDBIndexMetadata() {}
     18   IndexedDBIndexMetadata(const base::string16& name,
     19                          int64 id,
     20                          const IndexedDBKeyPath& key_path,
     21                          bool unique,
     22                          bool multi_entry)
     23       : name(name),
     24         id(id),
     25         key_path(key_path),
     26         unique(unique),
     27         multi_entry(multi_entry) {}
     28   base::string16 name;
     29   int64 id;
     30   IndexedDBKeyPath key_path;
     31   bool unique;
     32   bool multi_entry;
     33 
     34   static const int64 kInvalidId = -1;
     35 };
     36 
     37 struct CONTENT_EXPORT IndexedDBObjectStoreMetadata {
     38   IndexedDBObjectStoreMetadata();
     39   IndexedDBObjectStoreMetadata(const base::string16& name,
     40                                int64 id,
     41                                const IndexedDBKeyPath& key_path,
     42                                bool auto_increment,
     43                                int64 max_index_id);
     44   ~IndexedDBObjectStoreMetadata();
     45   base::string16 name;
     46   int64 id;
     47   IndexedDBKeyPath key_path;
     48   bool auto_increment;
     49   int64 max_index_id;
     50 
     51   static const int64 kInvalidId = -1;
     52 
     53   typedef std::map<int64, IndexedDBIndexMetadata> IndexMap;
     54   IndexMap indexes;
     55 };
     56 
     57 struct CONTENT_EXPORT IndexedDBDatabaseMetadata {
     58   // TODO(jsbell): These can probably be collapsed into 0.
     59   enum {
     60     NO_INT_VERSION = -1,
     61     DEFAULT_INT_VERSION = 0
     62   };
     63 
     64   typedef std::map<int64, IndexedDBObjectStoreMetadata> ObjectStoreMap;
     65 
     66   IndexedDBDatabaseMetadata();
     67   IndexedDBDatabaseMetadata(const base::string16& name,
     68                             int64 id,
     69                             const base::string16& version,
     70                             int64 int_version,
     71                             int64 max_object_store_id);
     72   ~IndexedDBDatabaseMetadata();
     73 
     74   base::string16 name;
     75   int64 id;
     76   base::string16 version;
     77   int64 int_version;
     78   int64 max_object_store_id;
     79 
     80   ObjectStoreMap object_stores;
     81 };
     82 }
     83 
     84 #endif  // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_METADATA_H_
     85