Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(429)

Side by Side Diff: storage/browser/blob/blob_data_item.h

Issue 810403004: [Storage] Blob Storage Refactoring pt 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed copyright Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2015 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 #ifndef STORAGE_BROWSER_BLOB_BLOB_DATA_ITEM_H_
6 #define STORAGE_BROWSER_BLOB_BLOB_DATA_ITEM_H_
7
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "storage/browser/blob/shareable_file_reference.h"
11 #include "storage/browser/storage_browser_export.h"
12 #include "storage/common/data_element.h"
13
14 namespace storage {
15 class BlobDataBuilder;
16 class BlobStorageContext;
17
18 // Ref counted blob item. This class owns the backing data of the blob item.
19 // The backing data is immutable, and cannot change after creation.
20 // The purpose of this class is to allow the resource to stick around in the
21 // snapshot even after the resource was swapped in the blob (either to disk or
22 // to memory) by the BlobStorageContext.
23 class STORAGE_EXPORT BlobDataItem : public base::RefCounted<BlobDataItem> {
24 public:
25 storage::DataElement::Type type() const { return item_->type(); }
26 const char* bytes() const { return item_->bytes(); }
27 const base::FilePath& path() const { return item_->path(); }
28 const GURL& filesystem_url() const { return item_->filesystem_url(); }
29 const std::string& blob_uuid() const { return item_->blob_uuid(); }
30 uint64 offset() const { return item_->offset(); }
31 uint64 length() const { return item_->length(); }
32 const base::Time& expected_modification_time() const {
33 return item_->expected_modification_time();
34 }
35 const DataElement& data_element() const { return *item_; }
36 const DataElement* data_element_ptr() const { return item_.get(); }
37
38 private:
39 friend class BlobDataBuilder;
40 friend class BlobStorageContext;
41 friend class base::RefCounted<BlobDataItem>;
42 BlobDataItem(scoped_ptr<DataElement> item);
43 BlobDataItem(scoped_ptr<DataElement> item,
44 scoped_refptr<ShareableFileReference> file_handle);
45 virtual ~BlobDataItem();
46
47 scoped_ptr<storage::DataElement> item_;
48 scoped_refptr<ShareableFileReference> file_handle_;
49 };
50
51 #if defined(UNIT_TEST)
52 inline bool operator==(const BlobDataItem& a, const BlobDataItem& b) {
53 return a.data_element() == b.data_element();
54 }
55
56 inline bool operator!=(const BlobDataItem& a, const BlobDataItem& b) {
57 return !(a == b);
58 }
59 #endif // defined(UNIT_TEST)
60
61 } // namespace storage
62
63 #endif // STORAGE_BROWSER_BLOB_BLOB_DATA_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698