1 // Copyright 2014 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.
5 #include "content/browser/indexed_db/indexed_db_blob_info.h"
8 #include "base/logging.h"
9 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h"
13 IndexedDBBlobInfo::IndexedDBBlobInfo()
14 : is_file_(false), size_(-1), key_(DatabaseMetaDataKey::kInvalidBlobKey
) {
17 IndexedDBBlobInfo::IndexedDBBlobInfo(const std::string
& uuid
,
18 const base::string16
& type
,
24 key_(DatabaseMetaDataKey::kInvalidBlobKey
) {
27 IndexedDBBlobInfo::IndexedDBBlobInfo(const base::string16
& type
,
30 : is_file_(false), type_(type
), size_(size
), key_(key
) {
33 IndexedDBBlobInfo::IndexedDBBlobInfo(const std::string
& uuid
,
34 const base::FilePath
& file_path
,
35 const base::string16
& file_name
,
36 const base::string16
& type
)
41 file_name_(file_name
),
42 file_path_(file_path
),
43 key_(DatabaseMetaDataKey::kInvalidBlobKey
) {
46 IndexedDBBlobInfo::IndexedDBBlobInfo(int64 key
,
47 const base::string16
& type
,
48 const base::string16
& file_name
)
49 : is_file_(true), type_(type
), size_(-1), file_name_(file_name
), key_(key
) {
52 IndexedDBBlobInfo::IndexedDBBlobInfo(const IndexedDBBlobInfo
& other
) = default;
54 IndexedDBBlobInfo::~IndexedDBBlobInfo() = default;
56 IndexedDBBlobInfo
& IndexedDBBlobInfo::operator=(
57 const IndexedDBBlobInfo
& other
) = default;
59 void IndexedDBBlobInfo::set_size(int64 size
) {
64 void IndexedDBBlobInfo::set_uuid(const std::string
& uuid
) {
65 DCHECK(uuid_
.empty());
67 DCHECK(!uuid_
.empty());
70 void IndexedDBBlobInfo::set_file_path(const base::FilePath
& file_path
) {
71 DCHECK(file_path_
.empty());
72 file_path_
= file_path
;
75 void IndexedDBBlobInfo::set_last_modified(const base::Time
& time
) {
76 DCHECK(base::Time().is_null());
78 last_modified_
= time
;
81 void IndexedDBBlobInfo::set_key(int64 key
) {
82 DCHECK_EQ(DatabaseMetaDataKey::kInvalidBlobKey
, key_
);
86 void IndexedDBBlobInfo::set_mark_used_callback(
87 const base::Closure
& mark_used_callback
) {
88 DCHECK(mark_used_callback_
.is_null());
89 mark_used_callback_
= mark_used_callback
;
92 void IndexedDBBlobInfo::set_release_callback(
93 const ReleaseCallback
& release_callback
) {
94 DCHECK(release_callback_
.is_null());
95 release_callback_
= release_callback
;
98 } // namespace content