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

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

Issue 1108083002: Create blobs from Disk Cache entries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remediate + windows build Created 5 years, 6 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_SHAREABLE_FILE_REFERENCE_H_ 5 #ifndef STORAGE_BROWSER_BLOB_SHAREABLE_FILE_REFERENCE_H_
6 #define STORAGE_BROWSER_BLOB_SHAREABLE_FILE_REFERENCE_H_ 6 #define STORAGE_BROWSER_BLOB_SHAREABLE_FILE_REFERENCE_H_
7 7
8 #include <vector> 8 #include "storage/browser/blob/blob_data_item.h"
9
10 #include "storage/browser/blob/scoped_file.h" 9 #include "storage/browser/blob/scoped_file.h"
11 #include "storage/browser/storage_browser_export.h" 10 #include "storage/browser/storage_browser_export.h"
12 11
13 namespace storage { 12 namespace storage {
14 13
15 // ShareableFileReference allows consumers to share FileReference for the 14 // ShareableFileReference allows consumers to share FileReference for the
16 // same path if it already exists in its internal map. 15 // same path if it already exists in its internal map.
17 // This class is non-thread-safe and all methods must be called on a single 16 // This class is non-thread-safe and all methods must be called on a single
18 // thread. 17 // thread.
19 class STORAGE_EXPORT ShareableFileReference 18 // This class inherits directly from BlobDataItem::DataHandle as an optimization
20 : public base::RefCounted<ShareableFileReference> { 19 // to remove double-dereferences from refcounting the DataHandle objects. This
20 // only works because there are no other fields in the DataHandle.
michaeln 2015/06/12 23:43:06 I don't think the editorial comments about dbl-der
dmurph 2015/06/13 00:09:43 I asked him to add this in case it wasn't clear fo
gavinp 2015/06/15 14:01:19 Removed, just because I'm slightly with michaeln h
21 class STORAGE_EXPORT ShareableFileReference : public BlobDataItem::DataHandle {
21 public: 22 public:
22 typedef ScopedFile::ScopeOutCallback FinalReleaseCallback; 23 typedef ScopedFile::ScopeOutCallback FinalReleaseCallback;
23 24
24 enum FinalReleasePolicy { 25 enum FinalReleasePolicy {
25 DELETE_ON_FINAL_RELEASE = ScopedFile::DELETE_ON_SCOPE_OUT, 26 DELETE_ON_FINAL_RELEASE = ScopedFile::DELETE_ON_SCOPE_OUT,
26 DONT_DELETE_ON_FINAL_RELEASE = ScopedFile::DONT_DELETE_ON_SCOPE_OUT, 27 DONT_DELETE_ON_FINAL_RELEASE = ScopedFile::DONT_DELETE_ON_SCOPE_OUT,
27 }; 28 };
28 29
29 // Returns a ShareableFileReference for the given path, if no reference 30 // Returns a ShareableFileReference for the given path, if no reference
30 // for this path exists returns NULL. 31 // for this path exists returns NULL.
(...skipping 22 matching lines...) Expand all
53 54
54 // The full file path. 55 // The full file path.
55 const base::FilePath& path() const { return scoped_file_.path(); } 56 const base::FilePath& path() const { return scoped_file_.path(); }
56 57
57 // The |callback| is fired when the final reference of this instance 58 // The |callback| is fired when the final reference of this instance
58 // is released. If release policy is DELETE_ON_FINAL_RELEASE the 59 // is released. If release policy is DELETE_ON_FINAL_RELEASE the
59 // callback task(s) is/are posted before the deletion is scheduled. 60 // callback task(s) is/are posted before the deletion is scheduled.
60 void AddFinalReleaseCallback(const FinalReleaseCallback& callback); 61 void AddFinalReleaseCallback(const FinalReleaseCallback& callback);
61 62
62 private: 63 private:
63 friend class base::RefCounted<ShareableFileReference>;
64
65 ShareableFileReference(ScopedFile scoped_file); 64 ShareableFileReference(ScopedFile scoped_file);
66 ~ShareableFileReference(); 65 ~ShareableFileReference() override;
67 66
68 ScopedFile scoped_file_; 67 ScopedFile scoped_file_;
69 68
70 DISALLOW_COPY_AND_ASSIGN(ShareableFileReference); 69 DISALLOW_COPY_AND_ASSIGN(ShareableFileReference);
71 }; 70 };
72 71
73 } // namespace storage 72 } // namespace storage
74 73
75 #endif // STORAGE_BROWSER_BLOB_SHAREABLE_FILE_REFERENCE_H_ 74 #endif // STORAGE_BROWSER_BLOB_SHAREABLE_FILE_REFERENCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698