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

Side by Side Diff: webrtc/examples/unityplugin/classreferenceholder.cc

Issue 3009613002: Android: Replace webrtc_jni namespace with nested jni namespace (Closed)
Patch Set: Rebase Created 3 years, 3 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
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 #include "webrtc/examples/unityplugin/classreferenceholder.h" 10 #include "webrtc/examples/unityplugin/classreferenceholder.h"
(...skipping 18 matching lines...) Expand all
29 private: 29 private:
30 std::map<std::string, jclass> classes_; 30 std::map<std::string, jclass> classes_;
31 }; 31 };
32 32
33 // Allocated in LoadGlobalClassReferenceHolder(), 33 // Allocated in LoadGlobalClassReferenceHolder(),
34 // freed in FreeGlobalClassReferenceHolder(). 34 // freed in FreeGlobalClassReferenceHolder().
35 static ClassReferenceHolder* g_class_reference_holder = nullptr; 35 static ClassReferenceHolder* g_class_reference_holder = nullptr;
36 36
37 void LoadGlobalClassReferenceHolder() { 37 void LoadGlobalClassReferenceHolder() {
38 RTC_CHECK(g_class_reference_holder == nullptr); 38 RTC_CHECK(g_class_reference_holder == nullptr);
39 g_class_reference_holder = new ClassReferenceHolder(webrtc_jni::GetEnv()); 39 g_class_reference_holder = new ClassReferenceHolder(webrtc::jni::GetEnv());
40 } 40 }
41 41
42 void FreeGlobalClassReferenceHolder() { 42 void FreeGlobalClassReferenceHolder() {
43 g_class_reference_holder->FreeReferences( 43 g_class_reference_holder->FreeReferences(
44 webrtc_jni::AttachCurrentThreadIfNeeded()); 44 webrtc::jni::AttachCurrentThreadIfNeeded());
45 delete g_class_reference_holder; 45 delete g_class_reference_holder;
46 g_class_reference_holder = nullptr; 46 g_class_reference_holder = nullptr;
47 } 47 }
48 48
49 ClassReferenceHolder::ClassReferenceHolder(JNIEnv* jni) { 49 ClassReferenceHolder::ClassReferenceHolder(JNIEnv* jni) {
50 LoadClass(jni, "org/webrtc/UnityUtility"); 50 LoadClass(jni, "org/webrtc/UnityUtility");
51 } 51 }
52 52
53 ClassReferenceHolder::~ClassReferenceHolder() { 53 ClassReferenceHolder::~ClassReferenceHolder() {
54 RTC_CHECK(classes_.empty()) << "Must call FreeReferences() before dtor!"; 54 RTC_CHECK(classes_.empty()) << "Must call FreeReferences() before dtor!";
(...skipping 24 matching lines...) Expand all
79 RTC_CHECK(inserted) << "Duplicate class name: " << name; 79 RTC_CHECK(inserted) << "Duplicate class name: " << name;
80 } 80 }
81 81
82 // Returns a global reference guaranteed to be valid for the lifetime of the 82 // Returns a global reference guaranteed to be valid for the lifetime of the
83 // process. 83 // process.
84 jclass FindClass(JNIEnv* jni, const char* name) { 84 jclass FindClass(JNIEnv* jni, const char* name) {
85 return g_class_reference_holder->GetClass(name); 85 return g_class_reference_holder->GetClass(name);
86 } 86 }
87 87
88 } // namespace unity_plugin 88 } // namespace unity_plugin
OLDNEW
« no previous file with comments | « webrtc/examples/unityplugin/classreferenceholder.h ('k') | webrtc/examples/unityplugin/jni_onload.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698