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

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

Issue 1004593005: base::RefCounted now DCHECKs when referenced from multiple threads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix lots of tests using UnsafeRefCounted. Created 5 years, 9 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 <vector>
9 9
10 #include "storage/browser/blob/scoped_file.h" 10 #include "storage/browser/blob/scoped_file.h"
11 #include "storage/browser/storage_browser_export.h" 11 #include "storage/browser/storage_browser_export.h"
12 12
13 namespace storage { 13 namespace storage {
14 14
15 // ShareableFileReference allows consumers to share FileReference for the 15 // ShareableFileReference allows consumers to share FileReference for the
16 // same path if it already exists in its internal map. 16 // 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 17 // This class is non-thread-safe and all methods must be called on a single
18 // thread. 18 // thread.
19 // TODO(mgiuca): Avoid using UnsafeRefCounted. http://crbug.com/469952.
19 class STORAGE_EXPORT ShareableFileReference 20 class STORAGE_EXPORT ShareableFileReference
20 : public base::RefCounted<ShareableFileReference> { 21 : public base::UnsafeRefCounted<ShareableFileReference> {
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 friend class base::UnsafeRefCounted<ShareableFileReference>;
64 65
65 ShareableFileReference(ScopedFile scoped_file); 66 ShareableFileReference(ScopedFile scoped_file);
66 ~ShareableFileReference(); 67 ~ShareableFileReference();
67 68
68 ScopedFile scoped_file_; 69 ScopedFile scoped_file_;
69 70
70 DISALLOW_COPY_AND_ASSIGN(ShareableFileReference); 71 DISALLOW_COPY_AND_ASSIGN(ShareableFileReference);
71 }; 72 };
72 73
73 } // namespace storage 74 } // namespace storage
74 75
75 #endif // STORAGE_BROWSER_BLOB_SHAREABLE_FILE_REFERENCE_H_ 76 #endif // STORAGE_BROWSER_BLOB_SHAREABLE_FILE_REFERENCE_H_
OLDNEW
« base/memory/ref_counted.h ('K') | « sql/connection.h ('k') | ui/gfx/image/image.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698