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

Side by Side Diff: base/supports_user_data.h

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 Created 4 years, 8 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
« no previous file with comments | « base/strings/utf_offset_string_conversions.cc ('k') | base/supports_user_data.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 BASE_SUPPORTS_USER_DATA_H_ 5 #ifndef BASE_SUPPORTS_USER_DATA_H_
6 #define BASE_SUPPORTS_USER_DATA_H_ 6 #define BASE_SUPPORTS_USER_DATA_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory>
9 10
10 #include "base/base_export.h" 11 #include "base/base_export.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/threading/thread_checker.h" 14 #include "base/threading/thread_checker.h"
15 15
16 namespace base { 16 namespace base {
17 17
18 // This is a helper for classes that want to allow users to stash random data by 18 // This is a helper for classes that want to allow users to stash random data by
19 // key. At destruction all the objects will be destructed. 19 // key. At destruction all the objects will be destructed.
20 class BASE_EXPORT SupportsUserData { 20 class BASE_EXPORT SupportsUserData {
21 public: 21 public:
22 SupportsUserData(); 22 SupportsUserData();
23 23
(...skipping 16 matching lines...) Expand all
40 // SupportsUserData is not thread-safe, and on debug build will assert it is 40 // SupportsUserData is not thread-safe, and on debug build will assert it is
41 // only used on one thread. Calling this method allows the caller to hand 41 // only used on one thread. Calling this method allows the caller to hand
42 // the SupportsUserData instance across threads. Use only if you are taking 42 // the SupportsUserData instance across threads. Use only if you are taking
43 // full control of the synchronization of that hand over. 43 // full control of the synchronization of that hand over.
44 void DetachUserDataThread(); 44 void DetachUserDataThread();
45 45
46 protected: 46 protected:
47 virtual ~SupportsUserData(); 47 virtual ~SupportsUserData();
48 48
49 private: 49 private:
50 using DataMap = std::map<const void*, scoped_ptr<Data>>; 50 using DataMap = std::map<const void*, std::unique_ptr<Data>>;
51 51
52 // Externally-defined data accessible by key. 52 // Externally-defined data accessible by key.
53 DataMap user_data_; 53 DataMap user_data_;
54 // Guards usage of |user_data_| 54 // Guards usage of |user_data_|
55 ThreadChecker thread_checker_; 55 ThreadChecker thread_checker_;
56 56
57 DISALLOW_COPY_AND_ASSIGN(SupportsUserData); 57 DISALLOW_COPY_AND_ASSIGN(SupportsUserData);
58 }; 58 };
59 59
60 // Adapter class that releases a refcounted object when the 60 // Adapter class that releases a refcounted object when the
(...skipping 12 matching lines...) Expand all
73 73
74 private: 74 private:
75 scoped_refptr<T> object_; 75 scoped_refptr<T> object_;
76 76
77 DISALLOW_COPY_AND_ASSIGN(UserDataAdapter); 77 DISALLOW_COPY_AND_ASSIGN(UserDataAdapter);
78 }; 78 };
79 79
80 } // namespace base 80 } // namespace base
81 81
82 #endif // BASE_SUPPORTS_USER_DATA_H_ 82 #endif // BASE_SUPPORTS_USER_DATA_H_
OLDNEW
« no previous file with comments | « base/strings/utf_offset_string_conversions.cc ('k') | base/supports_user_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698