OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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 MOJO_COMMON_ENVIRONMENT_DATA_H_ |
| 6 #define MOJO_COMMON_ENVIRONMENT_DATA_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/synchronization/lock.h" |
| 12 #include "mojo/common/mojo_common_export.h" |
| 13 |
| 14 namespace mojo { |
| 15 namespace common { |
| 16 |
| 17 // EnvironmentData is used to store arbitrary key/value pairs in the |
| 18 // environment. The key/value pairs are owned by the Environment and deleted |
| 19 // when it is deleted. |
| 20 class MOJO_COMMON_EXPORT EnvironmentData { |
| 21 public: |
| 22 class MOJO_COMMON_EXPORT Data { |
| 23 public: |
| 24 Data() {} |
| 25 virtual ~Data() {} |
| 26 }; |
| 27 |
| 28 EnvironmentData(); |
| 29 ~EnvironmentData(); |
| 30 |
| 31 static EnvironmentData* GetInstance(); |
| 32 |
| 33 void SetData(const void* key, scoped_ptr<Data> data); |
| 34 |
| 35 Data* GetData(const void* key); |
| 36 |
| 37 private: |
| 38 typedef std::map<const void*, Data*> DataMap; |
| 39 |
| 40 static EnvironmentData* instance_; |
| 41 |
| 42 base::Lock data_lock_; |
| 43 |
| 44 DataMap data_map_; |
| 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(EnvironmentData); |
| 47 }; |
| 48 |
| 49 } // namespace common |
| 50 } // namespace mojo |
| 51 |
| 52 #endif // MOJO_COMMON_ENVIRONMENT_DATA_H_ |
OLD | NEW |