OLD | NEW |
---|---|
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 <vector> |
9 | 9 |
10 #include "storage/browser/blob/blob_data_item.h" | |
10 #include "storage/browser/blob/scoped_file.h" | 11 #include "storage/browser/blob/scoped_file.h" |
11 #include "storage/browser/storage_browser_export.h" | 12 #include "storage/browser/storage_browser_export.h" |
12 | 13 |
13 namespace storage { | 14 namespace storage { |
14 | 15 |
15 // ShareableFileReference allows consumers to share FileReference for the | 16 // ShareableFileReference allows consumers to share FileReference for the |
16 // same path if it already exists in its internal map. | 17 // 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 | 18 // This class is non-thread-safe and all methods must be called on a single |
18 // thread. | 19 // thread. |
19 class STORAGE_EXPORT ShareableFileReference | 20 class STORAGE_EXPORT ShareableFileReference : public BlobDataItem::DataHandle { |
dmurph
2015/06/05 01:17:23
Can you actually keep this the way it was? And th
gavinp
2015/06/05 15:10:34
I'm totally confused. If we are going to allow spl
| |
20 : public base::RefCounted<ShareableFileReference> { | |
21 public: | 21 public: |
22 typedef ScopedFile::ScopeOutCallback FinalReleaseCallback; | 22 typedef ScopedFile::ScopeOutCallback FinalReleaseCallback; |
23 | 23 |
24 enum FinalReleasePolicy { | 24 enum FinalReleasePolicy { |
25 DELETE_ON_FINAL_RELEASE = ScopedFile::DELETE_ON_SCOPE_OUT, | 25 DELETE_ON_FINAL_RELEASE = ScopedFile::DELETE_ON_SCOPE_OUT, |
26 DONT_DELETE_ON_FINAL_RELEASE = ScopedFile::DONT_DELETE_ON_SCOPE_OUT, | 26 DONT_DELETE_ON_FINAL_RELEASE = ScopedFile::DONT_DELETE_ON_SCOPE_OUT, |
27 }; | 27 }; |
28 | 28 |
29 // Returns a ShareableFileReference for the given path, if no reference | 29 // Returns a ShareableFileReference for the given path, if no reference |
30 // for this path exists returns NULL. | 30 // for this path exists returns NULL. |
(...skipping 22 matching lines...) Expand all Loading... | |
53 | 53 |
54 // The full file path. | 54 // The full file path. |
55 const base::FilePath& path() const { return scoped_file_.path(); } | 55 const base::FilePath& path() const { return scoped_file_.path(); } |
56 | 56 |
57 // The |callback| is fired when the final reference of this instance | 57 // The |callback| is fired when the final reference of this instance |
58 // is released. If release policy is DELETE_ON_FINAL_RELEASE the | 58 // is released. If release policy is DELETE_ON_FINAL_RELEASE the |
59 // callback task(s) is/are posted before the deletion is scheduled. | 59 // callback task(s) is/are posted before the deletion is scheduled. |
60 void AddFinalReleaseCallback(const FinalReleaseCallback& callback); | 60 void AddFinalReleaseCallback(const FinalReleaseCallback& callback); |
61 | 61 |
62 private: | 62 private: |
63 friend class base::RefCounted<ShareableFileReference>; | |
64 | |
65 ShareableFileReference(ScopedFile scoped_file); | 63 ShareableFileReference(ScopedFile scoped_file); |
66 ~ShareableFileReference(); | 64 ~ShareableFileReference() override; |
67 | 65 |
68 ScopedFile scoped_file_; | 66 ScopedFile scoped_file_; |
69 | 67 |
70 DISALLOW_COPY_AND_ASSIGN(ShareableFileReference); | 68 DISALLOW_COPY_AND_ASSIGN(ShareableFileReference); |
71 }; | 69 }; |
72 | 70 |
73 } // namespace storage | 71 } // namespace storage |
74 | 72 |
75 #endif // STORAGE_BROWSER_BLOB_SHAREABLE_FILE_REFERENCE_H_ | 73 #endif // STORAGE_BROWSER_BLOB_SHAREABLE_FILE_REFERENCE_H_ |
OLD | NEW |