mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Log how long it takes to deliver private messages and attachments.
This commit is contained in:
@@ -53,14 +53,18 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static java.util.Collections.emptyList;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.briarproject.bramble.api.client.ContactGroupConstants.GROUP_KEY_CONTACT_ID;
|
||||
import static org.briarproject.bramble.api.sync.SyncConstants.MAX_MESSAGE_BODY_LENGTH;
|
||||
import static org.briarproject.bramble.util.IoUtils.copyAndClose;
|
||||
import static org.briarproject.bramble.util.LogUtils.logDuration;
|
||||
import static org.briarproject.bramble.util.LogUtils.now;
|
||||
import static org.briarproject.briar.api.attachment.MediaConstants.MSG_KEY_CONTENT_TYPE;
|
||||
import static org.briarproject.briar.api.attachment.MediaConstants.MSG_KEY_DESCRIPTOR_LENGTH;
|
||||
import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.NO_AUTO_DELETE_TIMER;
|
||||
@@ -84,6 +88,9 @@ class MessagingManagerImpl implements MessagingManager, IncomingMessageHook,
|
||||
ConversationClient, OpenDatabaseHook, ContactHook,
|
||||
ClientVersioningHook, CleanupHook {
|
||||
|
||||
private static final Logger LOG =
|
||||
getLogger(MessagingManagerImpl.class.getName());
|
||||
|
||||
private final DatabaseComponent db;
|
||||
private final ClientHelper clientHelper;
|
||||
private final MetadataParser metadataParser;
|
||||
@@ -201,6 +208,7 @@ class MessagingManagerImpl implements MessagingManager, IncomingMessageHook,
|
||||
private void incomingPrivateMessage(Transaction txn, Message m,
|
||||
BdfDictionary meta, boolean hasText, List<AttachmentHeader> headers)
|
||||
throws DbException, FormatException {
|
||||
long start = now();
|
||||
GroupId groupId = m.getGroupId();
|
||||
long timestamp = meta.getLong(MSG_KEY_TIMESTAMP);
|
||||
boolean local = meta.getBoolean(MSG_KEY_LOCAL);
|
||||
@@ -221,6 +229,7 @@ class MessagingManagerImpl implements MessagingManager, IncomingMessageHook,
|
||||
autoDeleteManager.receiveAutoDeleteTimer(txn, contactId, timer,
|
||||
timestamp);
|
||||
if (!headers.isEmpty()) stopAttachmentCleanupTimers(txn, m, headers);
|
||||
logDuration(LOG, "Receiving private message", start);
|
||||
}
|
||||
|
||||
private List<AttachmentHeader> parseAttachmentHeaders(GroupId g,
|
||||
@@ -256,6 +265,7 @@ class MessagingManagerImpl implements MessagingManager, IncomingMessageHook,
|
||||
|
||||
private void incomingAttachment(Transaction txn, Message m)
|
||||
throws DbException {
|
||||
long start = now();
|
||||
ContactId contactId = getContactId(txn, m.getGroupId());
|
||||
txn.attach(new AttachmentReceivedEvent(m.getId(), contactId));
|
||||
// If no private messages that list this attachment have been
|
||||
@@ -281,6 +291,7 @@ class MessagingManagerImpl implements MessagingManager, IncomingMessageHook,
|
||||
} catch (FormatException e) {
|
||||
throw new DbException(e);
|
||||
}
|
||||
logDuration(LOG, "Receiving attachment", start);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user