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.
5 #ifndef MOJO_COMMON_ENVIRONMENT_DATA_H_
6 #define MOJO_COMMON_ENVIRONMENT_DATA_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "base/synchronization/lock.h"
12 #include "mojo/common/mojo_common_export.h"
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 {
22 class MOJO_COMMON_EXPORT Data {
31 static EnvironmentData* GetInstance();
33 void SetData(const void* key, scoped_ptr<Data> data);
35 Data* GetData(const void* key);
38 typedef std::map<const void*, Data*> DataMap;
40 static EnvironmentData* instance_;
42 base::Lock data_lock_;
46 DISALLOW_COPY_AND_ASSIGN(EnvironmentData);
52 #endif // MOJO_COMMON_ENVIRONMENT_DATA_H_