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

Side by Side Diff: talk/app/webrtc/java/jni/classreferenceholder.cc

Issue 1335923002: Add RTC_ prefix to (D)CHECKs and related macros. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase. Created 5 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 * libjingle 2 * libjingle
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 void LoadClass(JNIEnv* jni, const std::string& name); 44 void LoadClass(JNIEnv* jni, const std::string& name);
45 45
46 std::map<std::string, jclass> classes_; 46 std::map<std::string, jclass> classes_;
47 }; 47 };
48 48
49 // Allocated in LoadGlobalClassReferenceHolder(), 49 // Allocated in LoadGlobalClassReferenceHolder(),
50 // freed in FreeGlobalClassReferenceHolder(). 50 // freed in FreeGlobalClassReferenceHolder().
51 static ClassReferenceHolder* g_class_reference_holder = nullptr; 51 static ClassReferenceHolder* g_class_reference_holder = nullptr;
52 52
53 void LoadGlobalClassReferenceHolder() { 53 void LoadGlobalClassReferenceHolder() {
54 CHECK(g_class_reference_holder == nullptr); 54 RTC_CHECK(g_class_reference_holder == nullptr);
55 g_class_reference_holder = new ClassReferenceHolder(GetEnv()); 55 g_class_reference_holder = new ClassReferenceHolder(GetEnv());
56 } 56 }
57 57
58 void FreeGlobalClassReferenceHolder() { 58 void FreeGlobalClassReferenceHolder() {
59 g_class_reference_holder->FreeReferences(AttachCurrentThreadIfNeeded()); 59 g_class_reference_holder->FreeReferences(AttachCurrentThreadIfNeeded());
60 delete g_class_reference_holder; 60 delete g_class_reference_holder;
61 g_class_reference_holder = nullptr; 61 g_class_reference_holder = nullptr;
62 } 62 }
63 63
64 ClassReferenceHolder::ClassReferenceHolder(JNIEnv* jni) { 64 ClassReferenceHolder::ClassReferenceHolder(JNIEnv* jni) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 LoadClass(jni, "org/webrtc/SessionDescription"); 107 LoadClass(jni, "org/webrtc/SessionDescription");
108 LoadClass(jni, "org/webrtc/SessionDescription$Type"); 108 LoadClass(jni, "org/webrtc/SessionDescription$Type");
109 LoadClass(jni, "org/webrtc/StatsReport"); 109 LoadClass(jni, "org/webrtc/StatsReport");
110 LoadClass(jni, "org/webrtc/StatsReport$Value"); 110 LoadClass(jni, "org/webrtc/StatsReport$Value");
111 LoadClass(jni, "org/webrtc/VideoRenderer$I420Frame"); 111 LoadClass(jni, "org/webrtc/VideoRenderer$I420Frame");
112 LoadClass(jni, "org/webrtc/VideoCapturer"); 112 LoadClass(jni, "org/webrtc/VideoCapturer");
113 LoadClass(jni, "org/webrtc/VideoTrack"); 113 LoadClass(jni, "org/webrtc/VideoTrack");
114 } 114 }
115 115
116 ClassReferenceHolder::~ClassReferenceHolder() { 116 ClassReferenceHolder::~ClassReferenceHolder() {
117 CHECK(classes_.empty()) << "Must call FreeReferences() before dtor!"; 117 RTC_CHECK(classes_.empty()) << "Must call FreeReferences() before dtor!";
118 } 118 }
119 119
120 void ClassReferenceHolder::FreeReferences(JNIEnv* jni) { 120 void ClassReferenceHolder::FreeReferences(JNIEnv* jni) {
121 for (std::map<std::string, jclass>::const_iterator it = classes_.begin(); 121 for (std::map<std::string, jclass>::const_iterator it = classes_.begin();
122 it != classes_.end(); ++it) { 122 it != classes_.end(); ++it) {
123 jni->DeleteGlobalRef(it->second); 123 jni->DeleteGlobalRef(it->second);
124 } 124 }
125 classes_.clear(); 125 classes_.clear();
126 } 126 }
127 127
128 jclass ClassReferenceHolder::GetClass(const std::string& name) { 128 jclass ClassReferenceHolder::GetClass(const std::string& name) {
129 std::map<std::string, jclass>::iterator it = classes_.find(name); 129 std::map<std::string, jclass>::iterator it = classes_.find(name);
130 CHECK(it != classes_.end()) << "Unexpected GetClass() call for: " << name; 130 RTC_CHECK(it != classes_.end()) << "Unexpected GetClass() call for: " << name;
131 return it->second; 131 return it->second;
132 } 132 }
133 133
134 void ClassReferenceHolder::LoadClass(JNIEnv* jni, const std::string& name) { 134 void ClassReferenceHolder::LoadClass(JNIEnv* jni, const std::string& name) {
135 jclass localRef = jni->FindClass(name.c_str()); 135 jclass localRef = jni->FindClass(name.c_str());
136 CHECK_EXCEPTION(jni) << "error during FindClass: " << name; 136 CHECK_EXCEPTION(jni) << "error during FindClass: " << name;
137 CHECK(localRef) << name; 137 RTC_CHECK(localRef) << name;
138 jclass globalRef = reinterpret_cast<jclass>(jni->NewGlobalRef(localRef)); 138 jclass globalRef = reinterpret_cast<jclass>(jni->NewGlobalRef(localRef));
139 CHECK_EXCEPTION(jni) << "error during NewGlobalRef: " << name; 139 CHECK_EXCEPTION(jni) << "error during NewGlobalRef: " << name;
140 CHECK(globalRef) << name; 140 RTC_CHECK(globalRef) << name;
141 bool inserted = classes_.insert(std::make_pair(name, globalRef)).second; 141 bool inserted = classes_.insert(std::make_pair(name, globalRef)).second;
142 CHECK(inserted) << "Duplicate class name: " << name; 142 RTC_CHECK(inserted) << "Duplicate class name: " << name;
143 } 143 }
144 144
145 // Returns a global reference guaranteed to be valid for the lifetime of the 145 // Returns a global reference guaranteed to be valid for the lifetime of the
146 // process. 146 // process.
147 jclass FindClass(JNIEnv* jni, const char* name) { 147 jclass FindClass(JNIEnv* jni, const char* name) {
148 return g_class_reference_holder->GetClass(name); 148 return g_class_reference_holder->GetClass(name);
149 } 149 }
150 150
151 } // namespace webrtc_jni 151 } // namespace webrtc_jni
OLDNEW
« no previous file with comments | « talk/app/webrtc/java/jni/androidvideocapturer_jni.cc ('k') | talk/app/webrtc/java/jni/jni_helpers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698