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

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

Issue 1288373002: [BlobAsync] Patch 2: Common Constants (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@async1
Patch Set: Created 5 years, 4 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
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef STORAGE_BROWSER_BLOB_BLOB_DATA_ITEM_H_ 5 #ifndef STORAGE_BROWSER_BLOB_BLOB_DATA_ITEM_H_
6 #define STORAGE_BROWSER_BLOB_BLOB_DATA_ITEM_H_ 6 #define STORAGE_BROWSER_BLOB_BLOB_DATA_ITEM_H_
7 7
8 #include <ostream>
9
8 #include "base/basictypes.h" 10 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
10 #include "storage/browser/storage_browser_export.h" 12 #include "storage/browser/storage_browser_export.h"
11 #include "storage/common/data_element.h" 13 #include "storage/common/data_element.h"
12 14
13 namespace disk_cache { 15 namespace disk_cache {
14 class Entry; 16 class Entry;
15 } 17 }
16 18
17 namespace storage { 19 namespace storage {
(...skipping 25 matching lines...) Expand all
43 const base::FilePath& path() const { return item_->path(); } 45 const base::FilePath& path() const { return item_->path(); }
44 const GURL& filesystem_url() const { return item_->filesystem_url(); } 46 const GURL& filesystem_url() const { return item_->filesystem_url(); }
45 const std::string& blob_uuid() const { return item_->blob_uuid(); } 47 const std::string& blob_uuid() const { return item_->blob_uuid(); }
46 uint64 offset() const { return item_->offset(); } 48 uint64 offset() const { return item_->offset(); }
47 uint64 length() const { return item_->length(); } 49 uint64 length() const { return item_->length(); }
48 const base::Time& expected_modification_time() const { 50 const base::Time& expected_modification_time() const {
49 return item_->expected_modification_time(); 51 return item_->expected_modification_time();
50 } 52 }
51 const DataElement& data_element() const { return *item_; } 53 const DataElement& data_element() const { return *item_; }
52 const DataElement* data_element_ptr() const { return item_.get(); } 54 const DataElement* data_element_ptr() const { return item_.get(); }
55 DataElement* data_element_ptr() { return item_.get(); }
53 56
54 disk_cache::Entry* disk_cache_entry() const { return disk_cache_entry_; } 57 disk_cache::Entry* disk_cache_entry() const { return disk_cache_entry_; }
55 int disk_cache_stream_index() const { return disk_cache_stream_index_; } 58 int disk_cache_stream_index() const { return disk_cache_stream_index_; }
56 59
57 private: 60 private:
58 friend class BlobDataBuilder; 61 friend class BlobDataBuilder;
59 friend class BlobStorageContext; 62 friend class BlobStorageContext;
60 friend class base::RefCounted<BlobDataItem>; 63 friend class base::RefCounted<BlobDataItem>;
64 friend std::ostream& operator<<(std::ostream& os, const BlobDataItem& x);
61 65
62 BlobDataItem(scoped_ptr<DataElement> item); 66 BlobDataItem(scoped_ptr<DataElement> item);
63 BlobDataItem(scoped_ptr<DataElement> item, 67 BlobDataItem(scoped_ptr<DataElement> item,
64 const scoped_refptr<DataHandle>& data_handle); 68 const scoped_refptr<DataHandle>& data_handle);
65 BlobDataItem(scoped_ptr<DataElement> item, 69 BlobDataItem(scoped_ptr<DataElement> item,
66 const scoped_refptr<DataHandle>& data_handle, 70 const scoped_refptr<DataHandle>& data_handle,
67 disk_cache::Entry* entry, 71 disk_cache::Entry* entry,
68 int disk_cache_stream_index_); 72 int disk_cache_stream_index_);
69 virtual ~BlobDataItem(); 73 virtual ~BlobDataItem();
70 74
71 scoped_ptr<DataElement> item_; 75 scoped_ptr<DataElement> item_;
72 scoped_refptr<DataHandle> data_handle_; 76 scoped_refptr<DataHandle> data_handle_;
73 77
74 // This naked pointer is safe because the scope is protected by the DataHandle 78 // This naked pointer is safe because the scope is protected by the DataHandle
75 // instance for disk cache entries during the lifetime of this BlobDataItem. 79 // instance for disk cache entries during the lifetime of this BlobDataItem.
76 disk_cache::Entry* disk_cache_entry_; 80 disk_cache::Entry* disk_cache_entry_;
77 int disk_cache_stream_index_; // For TYPE_DISK_CACHE_ENTRY. 81 int disk_cache_stream_index_; // For TYPE_DISK_CACHE_ENTRY.
78 }; 82 };
79 83
84 STORAGE_EXPORT std::ostream& operator<<(std::ostream& os,
85 const BlobDataItem& x);
86
80 #if defined(UNIT_TEST) 87 #if defined(UNIT_TEST)
81 inline bool operator==(const BlobDataItem& a, const BlobDataItem& b) { 88 inline bool operator==(const BlobDataItem& a, const BlobDataItem& b) {
82 return a.disk_cache_entry() == b.disk_cache_entry() && 89 return a.disk_cache_entry() == b.disk_cache_entry() &&
83 a.disk_cache_stream_index() == b.disk_cache_stream_index() && 90 a.disk_cache_stream_index() == b.disk_cache_stream_index() &&
84 a.data_element() == b.data_element(); 91 a.data_element() == b.data_element();
85 } 92 }
86 93
87 inline bool operator!=(const BlobDataItem& a, const BlobDataItem& b) { 94 inline bool operator!=(const BlobDataItem& a, const BlobDataItem& b) {
88 return !(a == b); 95 return !(a == b);
89 } 96 }
90 #endif // defined(UNIT_TEST) 97 #endif // defined(UNIT_TEST)
91 98
92 } // namespace storage 99 } // namespace storage
93 100
94 #endif // STORAGE_BROWSER_BLOB_BLOB_DATA_ITEM_H_ 101 #endif // STORAGE_BROWSER_BLOB_BLOB_DATA_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698