use of com.google.protobuf3jarjar.ByteString in project android by JetBrains.
the class MemoryDataPoller method getHeapDump.
@Override
public void getHeapDump(HeapDumpDataRequest request, StreamObserver<DumpDataResponse> responseObserver) {
DumpDataResponse.Builder responseBuilder = DumpDataResponse.newBuilder();
synchronized (myUpdatingDataLock) {
int index = Collections.binarySearch(myHeapData, new HeapDumpSample(request.getDumpId()), (o1, o2) -> o1.myInfo.getDumpId() - o2.myInfo.getDumpId());
if (index < 0) {
responseBuilder.setStatus(DumpDataResponse.Status.NOT_FOUND);
} else {
HeapDumpSample dump = myHeapData.get(index);
if (dump.isError) {
responseBuilder.setStatus(DumpDataResponse.Status.FAILURE_UNKNOWN);
} else {
ByteString data = dump.myData;
if (data == null) {
responseBuilder.setStatus(DumpDataResponse.Status.NOT_READY);
} else {
responseBuilder.setStatus(DumpDataResponse.Status.SUCCESS);
responseBuilder.setData(data);
}
}
}
}
responseObserver.onNext(responseBuilder.build());
responseObserver.onCompleted();
}
use of com.google.protobuf3jarjar.ByteString in project android by JetBrains.
the class NetworkProfilerStage method setConnection.
/**
* Sets the active connection, or clears the previously selected active connection if given data is null.
*/
public void setConnection(@Nullable HttpData data) {
if (data != null && data.getResponsePayloadId() != null && data.getResponsePayloadFile() == null) {
ByteString payload = myRequestsModel.requestResponsePayload(data);
File file = null;
try {
file = FileUtil.createTempFile(data.getResponsePayloadId(), getFileSuffixFromContentType(data));
FileOutputStream outputStream = new FileOutputStream(file);
payload.writeTo(outputStream);
} catch (IOException e) {
return;
} finally {
if (file != null) {
file.deleteOnExit();
}
}
data.setResponsePayloadFile(file);
}
myConnection = data;
myConnectionDataEnabled = true;
getStudioProfilers().modeChanged();
aspect.changed(NetworkProfilerAspect.ACTIVE_CONNECTION);
}
use of com.google.protobuf3jarjar.ByteString in project android by JetBrains.
the class MemoryPoller method poll.
@Override
protected void poll() throws StatusRuntimeException {
MemoryRequest request = MemoryRequest.newBuilder().setAppId(myAppId).setStartTime(myStartTimestampNs).setEndTime(Long.MAX_VALUE).build();
MemoryData result = myService.getMemoryService().getData(request);
myDataCache.appendMemorySamples(result.getMemSamplesList());
myDataCache.appendVmStatsSamples(result.getVmStatsSamplesList());
List<HeapDumpInfo> pendingFetch = new ArrayList<>();
for (int i = 0; i < result.getHeapDumpInfosCount(); i++) {
HeapDumpInfo info = result.getHeapDumpInfos(i);
if (myHasPendingHeapDumpSample) {
// Note - if there is an existing pending heap dump, the first info from the response should represent the same info
assert i == 0 && info.getEndTime() != UNFINISHED_TIMESTAMP;
HeapDumpInfo previousLastInfo = myDataCache.swapLastHeapDumpInfo(info);
assert previousLastInfo.getFilePath().equals(info.getFilePath());
myHasPendingHeapDumpSample = false;
pendingFetch.add(info);
} else {
myDataCache.appendHeapDumpInfo(info);
if (info.getEndTime() == UNFINISHED_TIMESTAMP) {
// Note - there should be at most one unfinished heap dump request at a time. e.g. the final info from the response.
assert i == result.getHeapDumpInfosCount() - 1;
myHasPendingHeapDumpSample = true;
} else {
pendingFetch.add(info);
}
}
}
if (!pendingFetch.isEmpty()) {
ApplicationManager.getApplication().executeOnPooledThread(() -> {
for (HeapDumpInfo info : pendingFetch) {
ByteString heapDumpData = pullHeapDumpData(info);
if (heapDumpData != null) {
myDataCache.addPulledHeapDumpData(info, heapDumpData);
}
}
});
}
if (result.getEndTimestamp() > myStartTimestampNs) {
myStartTimestampNs = result.getEndTimestamp();
}
}
Aggregations