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

Side by Side Diff: ios/public/consumer/base/supports_user_data.h

Issue 781643004: Cleanup WebState and WebStateUserData API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef IOS_PUBLIC_CONSUMER_BASE_SUPPORTS_USER_DATA_H_
6 #define IOS_PUBLIC_CONSUMER_BASE_SUPPORTS_USER_DATA_H_
7
8 namespace ios {
9
10 class SupportsUserDataInternal;
11
12 // This is a helper for classes that want to allow users to stash random data by
13 // key. At destruction all the objects will be destructed.
14 class SupportsUserData {
15 public:
16 SupportsUserData();
17
18 // Derive from this class and add your own data members to associate extra
19 // information with this object. Alternatively, add this as a public base
20 // class to any class with a virtual destructor.
21 class Data {
22 public:
23 virtual ~Data() {}
24 };
25
26 // The user data allows the clients to associate data with this object.
27 // Multiple user data values can be stored under different keys.
28 // This object will TAKE OWNERSHIP of the given data pointer, and will
29 // delete the object if it is changed or the object is destroyed.
30 Data* GetUserData(const void* key) const;
31 void SetUserData(const void* key, Data* data);
32 void RemoveUserData(const void* key);
33
34 // SupportsUserData is not thread-safe, and on debug build will assert it is
35 // only used on one thread. Calling this method allows the caller to hand
36 // the SupportsUserData instance across threads. Use only if you are taking
37 // full control of the synchronization of that handover.
38 void DetachUserDataThread();
39
40 protected:
41 virtual ~SupportsUserData();
42
43 private:
44 // Owned by this object and scoped to its lifetime.
45 SupportsUserDataInternal* internal_helper_;
46 };
47
48 } // namespace ios
49
50 #endif // IOS_PUBLIC_CONSUMER_BASE_SUPPORTS_USER_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698