using object tracking and creating flipper objects for debug components
Summary: Using ObjectTracker to track debug component nodes and creating flipper objects with debug component data Reviewed By: davidaurelio Differential Revision: D15462076 fbshipit-source-id: 5d0b28b6aea4729b85cc9de9ab35f2a07edbae1c
This commit is contained in:
committed by
Facebook Github Bot
parent
914cbf6ccd
commit
0d769aa1c2
@@ -65,21 +65,21 @@ public class DescriptorMapping {
|
|||||||
mMapping.put(clazz, descriptor);
|
mMapping.put(clazz, descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeDescriptor<?> descriptorForClass(Class<?> clazz) {
|
public NodeDescriptor<?> descriptorForClass(Class<?> clazz) {
|
||||||
while (!mMapping.containsKey(clazz)) {
|
while (!mMapping.containsKey(clazz)) {
|
||||||
clazz = clazz.getSuperclass();
|
clazz = clazz.getSuperclass();
|
||||||
}
|
}
|
||||||
return mMapping.get(clazz);
|
return mMapping.get(clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onConnect(FlipperConnection connection) {
|
public void onConnect(FlipperConnection connection) {
|
||||||
for (NodeDescriptor descriptor : mMapping.values()) {
|
for (NodeDescriptor descriptor : mMapping.values()) {
|
||||||
descriptor.setConnection(connection);
|
descriptor.setConnection(connection);
|
||||||
descriptor.setDescriptorMapping(this);
|
descriptor.setDescriptorMapping(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onDisconnect() {
|
public void onDisconnect() {
|
||||||
for (NodeDescriptor descriptor : mMapping.values()) {
|
for (NodeDescriptor descriptor : mMapping.values()) {
|
||||||
descriptor.setConnection(null);
|
descriptor.setConnection(null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ import java.util.Map;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class ObjectTracker {
|
public class ObjectTracker {
|
||||||
ObjectTracker() {}
|
public ObjectTracker() {}
|
||||||
|
|
||||||
private final Map<String, SoftReference<Object>> mObjects = new HashMap<>();
|
private final Map<String, SoftReference<Object>> mObjects = new HashMap<>();
|
||||||
|
|
||||||
void put(String id, Object obj) {
|
public void put(String id, Object obj) {
|
||||||
mObjects.put(id, new SoftReference<>(obj));
|
mObjects.put(id, new SoftReference<>(obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,11 +35,11 @@ public class ObjectTracker {
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear() {
|
public void clear() {
|
||||||
mObjects.clear();
|
mObjects.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean contains(String id) {
|
public boolean contains(String id) {
|
||||||
return mObjects.containsKey(id);
|
return mObjects.containsKey(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user