summaryrefslogtreecommitdiffstats
path: root/storage/browser/blob/blob_data_snapshot.cc
blob: 0071a11dfd2e9fd96b9aad2380de8e3db0e19802 (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
// Copyright (c) 2015 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.

#include <stddef.h>
#include <stdint.h>

#include "storage/browser/blob/blob_data_snapshot.h"

namespace storage {

BlobDataSnapshot::BlobDataSnapshot(
    const std::string& uuid,
    const std::string& content_type,
    const std::string& content_disposition,
    const std::vector<scoped_refptr<BlobDataItem>>& items)
    : uuid_(uuid),
      content_type_(content_type),
      content_disposition_(content_disposition),
      items_(items) {
}

BlobDataSnapshot::BlobDataSnapshot(const std::string& uuid,
                                   const std::string& content_type,
                                   const std::string& content_disposition)
    : uuid_(uuid),
      content_type_(content_type),
      content_disposition_(content_disposition) {
}

BlobDataSnapshot::BlobDataSnapshot(const BlobDataSnapshot& other)
    : uuid_(other.uuid_),
      content_type_(other.content_type_),
      content_disposition_(other.content_disposition_),
      items_(other.items_) {
}

BlobDataSnapshot::~BlobDataSnapshot() {
}

size_t BlobDataSnapshot::GetMemoryUsage() const {
  int64_t memory = 0;
  for (const auto& data_item : items_) {
    if (data_item->type() == DataElement::TYPE_BYTES)
      memory += data_item->length();
  }
  return memory;
}

}  // namespace storage