summaryrefslogtreecommitdiffstats
path: root/content/browser/indexed_db/indexed_db_metadata.h
blob: 29f6a9f63f88a2e3fadb5d562ce73f44164f1301 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_METADATA_H_
#define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_METADATA_H_

#include <map>

#include "base/basictypes.h"
#include "base/string16.h"
#include "content/common/indexed_db/indexed_db_key_path.h"

namespace content {

struct IndexedDBIndexMetadata {
  IndexedDBIndexMetadata() {}
  IndexedDBIndexMetadata(const string16& name,
                         int64 id,
                         const IndexedDBKeyPath& key_path,
                         bool unique,
                         bool multi_entry)
      : name(name),
        id(id),
        key_path(key_path),
        unique(unique),
        multi_entry(multi_entry) {}
  string16 name;
  int64 id;
  IndexedDBKeyPath key_path;
  bool unique;
  bool multi_entry;

  static const int64 kInvalidId = -1;
};

struct CONTENT_EXPORT IndexedDBObjectStoreMetadata {
  IndexedDBObjectStoreMetadata();
  IndexedDBObjectStoreMetadata(const string16& name,
                               int64 id,
                               const IndexedDBKeyPath& key_path,
                               bool auto_increment,
                               int64 max_index_id);
  ~IndexedDBObjectStoreMetadata();
  string16 name;
  int64 id;
  IndexedDBKeyPath key_path;
  bool auto_increment;
  int64 max_index_id;

  static const int64 kInvalidId = -1;

  typedef std::map<int64, IndexedDBIndexMetadata> IndexMap;
  IndexMap indexes;
};

struct CONTENT_EXPORT IndexedDBDatabaseMetadata {
  // TODO(jsbell): These can probably be collapsed into 0.
  enum {
    NO_INT_VERSION = -1,
    DEFAULT_INT_VERSION = 0
  };

  typedef std::map<int64, IndexedDBObjectStoreMetadata> ObjectStoreMap;

  IndexedDBDatabaseMetadata();
  IndexedDBDatabaseMetadata(const string16& name,
                            int64 id,
                            const string16& version,
                            int64 int_version,
                            int64 max_object_store_id);
  ~IndexedDBDatabaseMetadata();

  string16 name;
  int64 id;
  string16 version;
  int64 int_version;
  int64 max_object_store_id;

  ObjectStoreMap object_stores;
};
}

#endif  // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_METADATA_H_