Whitelist window states to persist on ASH app windows.
[chromium-blink-merge.git] / ios / public / consumer / base / supports_user_data.h
blob5986c57def848909d981a9b2f013867aaa13364b
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.
5 #ifndef IOS_PUBLIC_CONSUMER_BASE_SUPPORTS_USER_DATA_H_
6 #define IOS_PUBLIC_CONSUMER_BASE_SUPPORTS_USER_DATA_H_
8 namespace ios {
10 class SupportsUserDataInternal;
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();
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() {}
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);
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();
40 protected:
41 virtual ~SupportsUserData();
43 private:
44 // Owned by this object and scoped to its lifetime.
45 SupportsUserDataInternal* internal_helper_;
48 } // namespace ios
50 #endif // IOS_PUBLIC_CONSUMER_BASE_SUPPORTS_USER_DATA_H_