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

Side by Side Diff: base/android/global_object_registry.cc

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
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 #include "base/android/global_object_registry.h"
6
7 namespace base {
8 namespace android {
9
10 GlobalObjectRegistry::GlobalObjectRegistry() {}
11 // static
12 GlobalObjectRegistry* GlobalObjectRegistry::GetInstance() {
13 static GlobalObjectRegistry* instance;
14 if (!instance)
15 instance = new GlobalObjectRegistry();
16 return instance;
17 }
18
19 void GlobalObjectRegistry::Set(Key key, const JavaRef<jobject>& java_object) {
20 DCHECK(mappings_.find(key) == mappings_.end());
21 mappings_[key] = ScopedJavaGlobalRef<jobject>(java_object);
22 }
23
24 ScopedJavaLocalRef<jobject> GlobalObjectRegistry::Take(Key key) {
25 auto iter = mappings_.find(key);
26 if (iter == mappings_.end())
27 return ScopedJavaLocalRef<jobject>();
28
29 ScopedJavaLocalRef<jobject> result(iter->second);
30 mappings_.erase(iter);
31 return result;
32 }
33
34 } // namespace android
35 } // namespace base
OLDNEW
« no previous file with comments | « base/android/global_object_registry.h ('k') | base/android/java/src/org/chromium/base/IParcelableChannel.aidl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698