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

Unified Diff: mojo/common/environment_data.h

Issue 218583009: Adds a way to associate key/value pairs with the environment (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make mojo_service_manager depend on mojo_common_lib Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/app/mojo/mojo_init.cc ('k') | mojo/common/environment_data.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/common/environment_data.h
diff --git a/mojo/common/environment_data.h b/mojo/common/environment_data.h
new file mode 100644
index 0000000000000000000000000000000000000000..4440df227ec7177515420b962eff010161569b3d
--- /dev/null
+++ b/mojo/common/environment_data.h
@@ -0,0 +1,52 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_COMMON_ENVIRONMENT_DATA_H_
+#define MOJO_COMMON_ENVIRONMENT_DATA_H_
+
+#include <map>
+
+#include "base/memory/scoped_ptr.h"
+#include "base/synchronization/lock.h"
+#include "mojo/common/mojo_common_export.h"
+
+namespace mojo {
+namespace common {
+
+// EnvironmentData is used to store arbitrary key/value pairs in the
+// environment. The key/value pairs are owned by the Environment and deleted
+// when it is deleted.
+class MOJO_COMMON_EXPORT EnvironmentData {
+ public:
+ class MOJO_COMMON_EXPORT Data {
+ public:
+ Data() {}
+ virtual ~Data() {}
+ };
+
+ EnvironmentData();
+ ~EnvironmentData();
+
+ static EnvironmentData* GetInstance();
+
+ void SetData(const void* key, scoped_ptr<Data> data);
+
+ Data* GetData(const void* key);
+
+ private:
+ typedef std::map<const void*, Data*> DataMap;
+
+ static EnvironmentData* instance_;
+
+ base::Lock data_lock_;
+
+ DataMap data_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(EnvironmentData);
+};
+
+} // namespace common
+} // namespace mojo
+
+#endif // MOJO_COMMON_ENVIRONMENT_DATA_H_
« no previous file with comments | « content/app/mojo/mojo_init.cc ('k') | mojo/common/environment_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698