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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « base/BUILD.gn ('k') | base/android/global_object_registry.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 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 BASE_ANDROID_GLOBAL_OBJECT_REGISTRY_H_
6 #define BASE_ANDROID_GLOBAL_OBJECT_REGISTRY_H_
7
8 #include <stdint.h>
9
10 #include <map>
11
12 #include "base/android/scoped_java_ref.h"
13 #include "build/build_config.h"
14
15 namespace base {
16 namespace android {
17
18 // The GlobalObjectRegistry is a singleton object used to store and retrieve
19 // Java objects from native code. It is useful during child process creation and
20 // is used somehow similarlty to the way GlobalDescriptors is used to deal with
21 // file descriptors.
22 // It might make sense in the future to merge this class and GlobalDescriptors
23 // into a unique ProcessInitiContext class.
24 class BASE_EXPORT GlobalObjectRegistry final {
25 public:
26 typedef uint32_t Key;
27
28 // Returns the singleton instance of GlobalObjectRegistry.
29 static GlobalObjectRegistry* GetInstance();
30
31 // Stores |java_object| and associates it with |key|.
32 void Set(Key key, const JavaRef<jobject>& java_object);
33
34 ScopedJavaLocalRef<jobject> Take(Key key);
35
36 private:
37 GlobalObjectRegistry();
38
39 std::map<Key, ScopedJavaGlobalRef<jobject>> mappings_;
40
41 DISALLOW_COPY_AND_ASSIGN(GlobalObjectRegistry);
42 };
43
44 } // namespace android
45 } // namespace base
46
47 #endif // BASE_ANDROID_GLOBAL_OBJECT_REGISTRY_H_
OLDNEW
« 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