summaryrefslogtreecommitdiffstats
path: root/content/browser/indexed_db/indexed_db_value.h
blob: d313038dd697cac56c496e73194f35ff38c0ec4e (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
// Copyright 2014 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_VALUE_H_
#define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_VALUE_H_

#include <algorithm>
#include <string>
#include <vector>

#include "content/browser/indexed_db/indexed_db_blob_info.h"
#include "content/common/content_export.h"

namespace content {

struct CONTENT_EXPORT IndexedDBValue {
  IndexedDBValue();
  IndexedDBValue(const std::string& input_bits,
                 const std::vector<IndexedDBBlobInfo>& input_blob_info);
  ~IndexedDBValue();

  void swap(IndexedDBValue& value) {
    bits.swap(value.bits);
    blob_info.swap(value.blob_info);
  }

  bool empty() const { return bits.empty(); }
  void clear() {
    bits.clear();
    blob_info.clear();
  }

  size_t SizeEstimate() const {
    return bits.size() + blob_info.size() * sizeof(IndexedDBBlobInfo);
  }

  std::string bits;
  std::vector<IndexedDBBlobInfo> blob_info;
};

}  // namespace content

#endif  // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_VALUE_H_