summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipc/attachment_broker_unprivileged.cc7
-rw-r--r--ipc/attachment_broker_unprivileged.h15
-rw-r--r--ipc/attachment_broker_unprivileged_win.cc5
-rw-r--r--tools/metrics/histograms/histograms.xml19
4 files changed, 45 insertions, 1 deletions
diff --git a/ipc/attachment_broker_unprivileged.cc b/ipc/attachment_broker_unprivileged.cc
index 44125b3..ce4e8ab 100644
--- a/ipc/attachment_broker_unprivileged.cc
+++ b/ipc/attachment_broker_unprivileged.cc
@@ -4,6 +4,7 @@
#include "ipc/attachment_broker_unprivileged.h"
+#include "base/metrics/histogram_macros.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_endpoint.h"
@@ -22,4 +23,10 @@ void AttachmentBrokerUnprivileged::DesignateBrokerCommunicationChannel(
endpoint->SetAttachmentBrokerEndpoint(true);
}
+void AttachmentBrokerUnprivileged::LogError(UMAError error) {
+ UMA_HISTOGRAM_ENUMERATION(
+ "IPC.AttachmentBrokerUnprivileged.BrokerAttachmentError", error,
+ ERROR_MAX);
+}
+
} // namespace IPC
diff --git a/ipc/attachment_broker_unprivileged.h b/ipc/attachment_broker_unprivileged.h
index 1e1e60e..4f847a6 100644
--- a/ipc/attachment_broker_unprivileged.h
+++ b/ipc/attachment_broker_unprivileged.h
@@ -27,6 +27,21 @@ class IPC_EXPORT AttachmentBrokerUnprivileged : public IPC::AttachmentBroker {
protected:
IPC::Sender* get_sender() { return sender_; }
+ // Errors that can be reported by subclasses.
+ // These match tools/metrics/histograms.xml.
+ // This enum is append-only.
+ enum UMAError {
+ // The brokerable attachment was successfully processed.
+ SUCCESS = 0,
+ // The brokerable attachment's destination was not the process that received
+ // the attachment.
+ WRONG_DESTINATION = 1,
+ ERROR_MAX
+ };
+
+ // Emits an UMA metric.
+ void LogError(UMAError error);
+
private:
// |sender_| is used to send Messages to the privileged broker process.
// |sender_| must live at least as long as this instance.
diff --git a/ipc/attachment_broker_unprivileged_win.cc b/ipc/attachment_broker_unprivileged_win.cc
index f5a6e04..094192e 100644
--- a/ipc/attachment_broker_unprivileged_win.cc
+++ b/ipc/attachment_broker_unprivileged_win.cc
@@ -48,12 +48,15 @@ bool AttachmentBrokerUnprivilegedWin::OnMessageReceived(const Message& msg) {
void AttachmentBrokerUnprivilegedWin::OnWinHandleHasBeenDuplicated(
const IPC::internal::HandleAttachmentWin::WireFormat& wire_format) {
// The IPC message was intended for a different process. Ignore it.
- if (wire_format.destination_process != base::Process::Current().Pid())
+ if (wire_format.destination_process != base::Process::Current().Pid()) {
+ LogError(WRONG_DESTINATION);
return;
+ }
scoped_refptr<BrokerableAttachment> attachment(
new IPC::internal::HandleAttachmentWin(wire_format));
HandleReceivedAttachment(attachment);
+ LogError(SUCCESS);
}
} // namespace IPC
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index aef4266..8cef2df 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -16280,6 +16280,15 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary>
</histogram>
+<histogram name="IPC.AttachmentBrokerUnprivileged.BrokerAttachmentError"
+ enum="IPCAttachmentBrokerUnprivilegedBrokerAttachmentError">
+ <owner>erikchen@chromium.org</owner>
+ <summary>
+ Errors that an unprivileged attachment broker encounters while trying to
+ broker attachments.
+ </summary>
+</histogram>
+
<histogram name="Keyboard.KeystrokeDeltas" units="milliseconds">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<summary>
@@ -62350,6 +62359,16 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</int>
</enum>
+<enum name="IPCAttachmentBrokerUnprivilegedBrokerAttachmentError" type="int">
+ <int value="0" label="SUCCESS">
+ The brokerable attachment was successfully processed.
+ </int>
+ <int value="1" label="DESTINATION_NOT_FOUND">
+ The brokerable attachment's destination was not the process that received
+ the attachment.
+ </int>
+</enum>
+
<enum name="IPPermissionStatus" type="int">
<int value="0" label="Unknown"/>
<int value="1" label="Not requested"/>