Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: ipc/attachment_broker_privileged.h

Issue 1739203004: Add support for Attachment Brokering of IPC::Channels on multiple threads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ipc/attachment_broker_mac_unittest.cc ('k') | ipc/attachment_broker_privileged.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef IPC_ATTACHMENT_BROKER_PRIVILEGED_H_ 5 #ifndef IPC_ATTACHMENT_BROKER_PRIVILEGED_H_
6 #define IPC_ATTACHMENT_BROKER_PRIVILEGED_H_ 6 #define IPC_ATTACHMENT_BROKER_PRIVILEGED_H_
7 7
8 #include <utility>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
12 #include "build/build_config.h" 14 #include "build/build_config.h"
13 #include "ipc/attachment_broker.h" 15 #include "ipc/attachment_broker.h"
14 #include "ipc/ipc_export.h" 16 #include "ipc/ipc_export.h"
15 17
16 #if defined(OS_MACOSX) && !defined(OS_IOS) 18 #if defined(OS_MACOSX) && !defined(OS_IOS)
17 namespace base { 19 namespace base {
18 class PortProvider; 20 class PortProvider;
19 } // namespace base 21 } // namespace base
20 #endif // defined(OS_MACOSX) && !defined(OS_IOS) 22 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
(...skipping 20 matching lines...) Expand all
41 #else 43 #else
42 static void CreateBrokerIfNeeded(); 44 static void CreateBrokerIfNeeded();
43 #endif // defined(OS_MACOSX) && !defined(OS_IOS) 45 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
44 46
45 // Similar to CreateBrokerIfNeeded(), but useful for single process unit tests 47 // Similar to CreateBrokerIfNeeded(), but useful for single process unit tests
46 // that don't need real attachment brokering, and don't want to deal with 48 // that don't need real attachment brokering, and don't want to deal with
47 // setting up a fake PortProvider. 49 // setting up a fake PortProvider.
48 static void CreateBrokerForSingleProcessTests(); 50 static void CreateBrokerForSingleProcessTests();
49 51
50 // AttachmentBroker overrides. 52 // AttachmentBroker overrides.
51 void RegisterCommunicationChannel(Endpoint* endpoint) override; 53 void RegisterCommunicationChannel(
54 Endpoint* endpoint,
55 scoped_refptr<base::SingleThreadTaskRunner> runner) override;
52 void DeregisterCommunicationChannel(Endpoint* endpoint) override; 56 void DeregisterCommunicationChannel(Endpoint* endpoint) override;
53 bool IsPrivilegedBroker() override; 57 bool IsPrivilegedBroker() override;
54 58
55 protected: 59 protected:
60 using EndpointRunnerPair =
61 std::pair<Endpoint*, scoped_refptr<base::SingleThreadTaskRunner>>;
62
56 // Returns the sender whose peer's process id is |id|. 63 // Returns the sender whose peer's process id is |id|.
57 // Returns nullptr if no sender is found. 64 // Returns nullptr if no sender is found.
58 // The lock returned by get_lock() must already be acquired before calling 65 // The lock returned by get_lock() must already be acquired before calling
59 // this method. The return value is only guaranteed to be valid while the lock 66 // this method. The return value is only guaranteed to be valid while the lock
60 // is held. 67 // is held.
61 Sender* GetSenderWithProcessId(base::ProcessId id); 68 EndpointRunnerPair GetSenderWithProcessId(base::ProcessId id);
69
70 // Sends a message to the endpoint, dispatching onto another thread if
71 // necessary.
72 void SendMessageToEndpoint(EndpointRunnerPair pair, Message* message);
62 73
63 // Errors that can be reported by subclasses. 74 // Errors that can be reported by subclasses.
64 // These match tools/metrics/histograms.xml. 75 // These match tools/metrics/histograms.xml.
65 // This enum is append-only. 76 // This enum is append-only.
66 enum UMAError { 77 enum UMAError {
67 // The brokerable attachment had a valid destination. This is the success 78 // The brokerable attachment had a valid destination. This is the success
68 // case. 79 // case.
69 DESTINATION_FOUND = 0, 80 DESTINATION_FOUND = 0,
70 // The brokerable attachment had a destination, but the broker did not have 81 // The brokerable attachment had a destination, but the broker did not have
71 // a channel of communication with that process. 82 // a channel of communication with that process.
(...skipping 26 matching lines...) Expand all
98 ERROR_COULD_NOT_OPEN_SOURCE_OR_DEST = 13, 109 ERROR_COULD_NOT_OPEN_SOURCE_OR_DEST = 13,
99 // The broker was asked to transfer a HANDLE with invalid permissions. 110 // The broker was asked to transfer a HANDLE with invalid permissions.
100 ERROR_INVALID_PERMISSIONS = 14, 111 ERROR_INVALID_PERMISSIONS = 14,
101 ERROR_MAX 112 ERROR_MAX
102 }; 113 };
103 114
104 // Emits an UMA metric. 115 // Emits an UMA metric.
105 void LogError(UMAError error); 116 void LogError(UMAError error);
106 117
107 private: 118 private:
108 std::vector<Endpoint*> endpoints_; 119 // A vector of Endpoints, and the SingleThreadTaskRunner that should be used
120 // to invoke Send() on each Endpoint.
121 std::vector<EndpointRunnerPair> endpoints_;
109 DISALLOW_COPY_AND_ASSIGN(AttachmentBrokerPrivileged); 122 DISALLOW_COPY_AND_ASSIGN(AttachmentBrokerPrivileged);
110 }; 123 };
111 124
112 } // namespace IPC 125 } // namespace IPC
113 126
114 #endif // IPC_ATTACHMENT_BROKER_PRIVILEGED_H_ 127 #endif // IPC_ATTACHMENT_BROKER_PRIVILEGED_H_
OLDNEW
« no previous file with comments | « ipc/attachment_broker_mac_unittest.cc ('k') | ipc/attachment_broker_privileged.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698