OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef IPC_ATTACHMENT_BROKER_UNPRIVILEGED_H_ | |
6 #define IPC_ATTACHMENT_BROKER_UNPRIVILEGED_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "ipc/attachment_broker.h" | |
10 #include "ipc/ipc_export.h" | |
11 | |
12 namespace IPC { | |
13 | |
14 class Endpoint; | |
15 class Sender; | |
16 | |
17 // This abstract subclass of AttachmentBroker is intended for use in | |
18 // non-privileged processes. | |
19 class IPC_EXPORT AttachmentBrokerUnprivileged : public IPC::AttachmentBroker { | |
20 public: | |
21 AttachmentBrokerUnprivileged(); | |
22 ~AttachmentBrokerUnprivileged() override; | |
23 | |
24 // If there is no global attachment broker, makes a new | |
25 // AttachmentBrokerUnprivileged and sets it as the global attachment broker. | |
26 // This method is thread safe. | |
27 static void CreateBrokerIfNeeded(); | |
28 | |
29 // AttachmentBroker: | |
30 void RegisterBrokerCommunicationChannel(Endpoint* endpoint) override; | |
31 void DeregisterBrokerCommunicationChannel(Endpoint* endpoint) override; | |
32 bool IsPrivilegedBroker() override; | |
33 | |
34 protected: | |
35 IPC::Sender* get_sender() { return sender_; } | |
36 | |
37 // Errors that can be reported by subclasses. | |
38 // These match tools/metrics/histograms/histograms.xml. | |
39 // This enum is append-only. | |
40 enum UMAError { | |
41 // The brokerable attachment was successfully processed. | |
42 SUCCESS = 0, | |
43 // The brokerable attachment's destination was not the process that received | |
44 // the attachment. | |
45 WRONG_DESTINATION = 1, | |
46 // An error occurred while trying to receive a Mach port with mach_msg(). | |
47 ERR_RECEIVE_MACH_MESSAGE = 2, | |
48 ERROR_MAX | |
49 }; | |
50 | |
51 // Emits an UMA metric. | |
52 void LogError(UMAError error); | |
53 | |
54 private: | |
55 // |sender_| is used to send Messages to the privileged broker process. | |
56 // |sender_| must live at least as long as this instance. | |
57 IPC::Sender* sender_; | |
58 DISALLOW_COPY_AND_ASSIGN(AttachmentBrokerUnprivileged); | |
59 }; | |
60 | |
61 } // namespace IPC | |
62 | |
63 #endif // IPC_ATTACHMENT_BROKER_UNPRIVILEGED_H_ | |
OLD | NEW |