b20eb527227c7b672b75aecb3d24d22d80a9e900
[platform/framework/web/crosswalk.git] / src / content / browser / indexed_db / indexed_db_blob_info.cc
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.
4
5 #include "content/browser/indexed_db/indexed_db_blob_info.h"
6
7 #include "base/logging.h"
8 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h"
9
10 namespace content {
11
12 IndexedDBBlobInfo::IndexedDBBlobInfo()
13     : is_file_(false),
14       size_(-1),
15       key_(DatabaseMetaDataKey::kInvalidBlobKey) {}
16
17 IndexedDBBlobInfo::~IndexedDBBlobInfo() {}
18
19 IndexedDBBlobInfo::IndexedDBBlobInfo(const std::string& uuid,
20                                      const base::string16& type,
21                                      int64 size)
22     : is_file_(false),
23       uuid_(uuid),
24       type_(type),
25       size_(size),
26       key_(DatabaseMetaDataKey::kInvalidBlobKey) {}
27
28 IndexedDBBlobInfo::IndexedDBBlobInfo(const base::string16& type,
29                                      int64 size,
30                                      int64 key)
31     : is_file_(false), type_(type), size_(size), key_(key) {}
32
33 IndexedDBBlobInfo::IndexedDBBlobInfo(const base::FilePath& file_path,
34                                      const base::string16& file_name,
35                                      const base::string16& type)
36     : is_file_(true),
37       type_(type),
38       size_(-1),
39       file_name_(file_name),
40       file_path_(file_path),
41       key_(DatabaseMetaDataKey::kInvalidBlobKey) {}
42
43 IndexedDBBlobInfo::IndexedDBBlobInfo(int64 key,
44                                      const base::string16& type,
45                                      const base::string16& file_name)
46     : is_file_(true),
47       type_(type),
48       size_(-1),
49       file_name_(file_name),
50       key_(key) {}
51
52 void IndexedDBBlobInfo::set_size(int64 size) {
53   DCHECK_EQ(-1, size_);
54   size_ = size;
55 }
56
57 void IndexedDBBlobInfo::set_uuid(const std::string& uuid) {
58   DCHECK(uuid_.empty());
59   uuid_ = uuid;
60   DCHECK(!uuid_.empty());
61 }
62
63 void IndexedDBBlobInfo::set_file_path(const base::FilePath& file_path) {
64   DCHECK(file_path_.empty());
65   file_path_ = file_path;
66 }
67
68 void IndexedDBBlobInfo::set_last_modified(const base::Time& time) {
69   DCHECK(base::Time().is_null());
70   DCHECK(is_file_);
71   last_modified_ = time;
72 }
73
74 void IndexedDBBlobInfo::set_key(int64 key) {
75   DCHECK_EQ(DatabaseMetaDataKey::kInvalidBlobKey, key_);
76   key_ = key;
77 }
78
79 void IndexedDBBlobInfo::set_mark_used_callback(
80     const base::Closure& mark_used_callback) {
81   DCHECK(mark_used_callback_.is_null());
82   mark_used_callback_ = mark_used_callback;
83 }
84
85 void IndexedDBBlobInfo::set_release_callback(
86     const ReleaseCallback& release_callback) {
87   DCHECK(release_callback_.is_null());
88   release_callback_ = release_callback;
89 }
90
91 }  // namespace content