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

Unified Diff: base/android/global_object_registry.h

Issue 2735113003: Changing SpawnChild to return a struct.
Patch Set: Created 3 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 | « base/BUILD.gn ('k') | base/android/global_object_registry.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/global_object_registry.h
diff --git a/base/android/global_object_registry.h b/base/android/global_object_registry.h
new file mode 100644
index 0000000000000000000000000000000000000000..9cff32b314b62c10da9d3f8929d0948f9b123a61
--- /dev/null
+++ b/base/android/global_object_registry.h
@@ -0,0 +1,47 @@
+// Copyright 2017 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 BASE_ANDROID_GLOBAL_OBJECT_REGISTRY_H_
+#define BASE_ANDROID_GLOBAL_OBJECT_REGISTRY_H_
+
+#include <stdint.h>
+
+#include <map>
+
+#include "base/android/scoped_java_ref.h"
+#include "build/build_config.h"
+
+namespace base {
+namespace android {
+
+// The GlobalObjectRegistry is a singleton object used to store and retrieve
+// Java objects from native code. It is useful during child process creation and
+// is used somehow similarlty to the way GlobalDescriptors is used to deal with
+// file descriptors.
+// It might make sense in the future to merge this class and GlobalDescriptors
+// into a unique ProcessInitiContext class.
+class BASE_EXPORT GlobalObjectRegistry final {
+ public:
+ typedef uint32_t Key;
+
+ // Returns the singleton instance of GlobalObjectRegistry.
+ static GlobalObjectRegistry* GetInstance();
+
+ // Stores |java_object| and associates it with |key|.
+ void Set(Key key, const JavaRef<jobject>& java_object);
+
+ ScopedJavaLocalRef<jobject> Take(Key key);
+
+ private:
+ GlobalObjectRegistry();
+
+ std::map<Key, ScopedJavaGlobalRef<jobject>> mappings_;
+
+ DISALLOW_COPY_AND_ASSIGN(GlobalObjectRegistry);
+};
+
+} // namespace android
+} // namespace base
+
+#endif // BASE_ANDROID_GLOBAL_OBJECT_REGISTRY_H_
« no previous file with comments | « base/BUILD.gn ('k') | base/android/global_object_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698