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

Side by Side Diff: chromeos/dbus/permission_broker_client.h

Issue 2291983002: chromeos: Remove dbus::FileDescriptor from PermissionBrokerClient (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CHROMEOS_DBUS_PERMISSION_BROKER_CLIENT_H_ 5 #ifndef CHROMEOS_DBUS_PERMISSION_BROKER_CLIENT_H_
6 #define CHROMEOS_DBUS_PERMISSION_BROKER_CLIENT_H_ 6 #define CHROMEOS_DBUS_PERMISSION_BROKER_CLIENT_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/files/scoped_file.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "chromeos/chromeos_export.h" 15 #include "chromeos/chromeos_export.h"
15 #include "chromeos/dbus/dbus_client.h" 16 #include "chromeos/dbus/dbus_client.h"
16 #include "dbus/file_descriptor.h"
17 17
18 namespace chromeos { 18 namespace chromeos {
19 19
20 // PermissionBrokerClient is used to communicate with the permission broker, a 20 // PermissionBrokerClient is used to communicate with the permission broker, a
21 // process that allows requesting permission to access specific device nodes. 21 // process that allows requesting permission to access specific device nodes.
22 // For example, one place that this client is used is within the USB extension 22 // For example, one place that this client is used is within the USB extension
23 // API code, where it is used to request explicit access to USB peripherals 23 // API code, where it is used to request explicit access to USB peripherals
24 // which the user the browser runs under normally wouldn't have access to. For 24 // which the user the browser runs under normally wouldn't have access to. For
25 // more details on the permission broker see: 25 // more details on the permission broker see:
26 // http://git.chromium.org/gitweb/?p=chromiumos/platform/permission_broker.git 26 // http://git.chromium.org/gitweb/?p=chromiumos/platform/permission_broker.git
27 class CHROMEOS_EXPORT PermissionBrokerClient : public DBusClient { 27 class CHROMEOS_EXPORT PermissionBrokerClient : public DBusClient {
28 public: 28 public:
29 // The ResultCallback is used for both the RequestPathAccess and 29 // The ResultCallback is used for both the RequestPathAccess and
30 // RequestUsbAccess methods. Its boolean parameter represents the result of 30 // RequestUsbAccess methods. Its boolean parameter represents the result of
31 // the operation that it was submitted alongside. 31 // the operation that it was submitted alongside.
32 typedef base::Callback<void(bool)> ResultCallback; 32 typedef base::Callback<void(bool)> ResultCallback;
33 33
34 // An OpenPathCallback callback is run when an OpenPath request is completed. 34 // An OpenPathCallback callback is run when an OpenPath request is completed.
35 typedef base::Callback<void(dbus::FileDescriptor)> OpenPathCallback; 35 typedef base::Callback<void(base::ScopedFD)> OpenPathCallback;
36 36
37 // An ErrorCallback callback is run when an error is returned by the 37 // An ErrorCallback callback is run when an error is returned by the
38 // permission broker. 38 // permission broker.
39 typedef base::Callback<void(const std::string& error_name, 39 typedef base::Callback<void(const std::string& error_name,
40 const std::string& message)> 40 const std::string& message)>
41 ErrorCallback; 41 ErrorCallback;
42 42
43 ~PermissionBrokerClient() override; 43 ~PermissionBrokerClient() override;
44 44
45 static PermissionBrokerClient* Create(); 45 static PermissionBrokerClient* Create();
46 46
47 // CheckPathAccess requests a hint from the permission broker about whether 47 // CheckPathAccess requests a hint from the permission broker about whether
48 // a later call to RequestPathAccess will be successful. It presumes that 48 // a later call to RequestPathAccess will be successful. It presumes that
49 // the |interface_id| value passed to RequestPathAccess will be 49 // the |interface_id| value passed to RequestPathAccess will be
50 // UsbDevicePermissionsData::ANY_INTERFACE). 50 // UsbDevicePermissionsData::ANY_INTERFACE).
51 virtual void CheckPathAccess(const std::string& path, 51 virtual void CheckPathAccess(const std::string& path,
52 const ResultCallback& callback) = 0; 52 const ResultCallback& callback) = 0;
53 53
54 // OpenPath requests that the permission broker open the device node 54 // OpenPath requests that the permission broker open the device node
55 // identified by |path| and return the resulting file descriptor. One of 55 // identified by |path| and return the resulting file descriptor. One of
56 // |callback| or |error_callback| is called. 56 // |callback| or |error_callback| is called.
57 virtual void OpenPath(const std::string& path, 57 virtual void OpenPath(const std::string& path,
58 const OpenPathCallback& callback, 58 const OpenPathCallback& callback,
59 const ErrorCallback& error_callback) = 0; 59 const ErrorCallback& error_callback) = 0;
60 60
61 // Requests the |port| be opened on the firewall for incoming TCP/IP 61 // Requests the |port| be opened on the firewall for incoming TCP/IP
62 // connections received on |interface| (an empty string indicates all 62 // connections received on |interface| (an empty string indicates all
63 // interfaces). An open pipe must be passed as |lifeline_fd| so that the 63 // interfaces). An open pipe must be passed as |lifeline_fd| so that the
64 // permission broker can monitor the lifetime of the calling process. 64 // permission broker can monitor the lifetime of the calling process.
satorux1 2016/08/31 05:18:08 add some comment about |lifeline_fd| like you did
hashimoto 2016/08/31 07:09:24 Done. Also reworded the existing comments to avoid
65 virtual void RequestTcpPortAccess(uint16_t port, 65 virtual void RequestTcpPortAccess(uint16_t port,
66 const std::string& interface, 66 const std::string& interface,
67 const dbus::FileDescriptor& lifeline_fd, 67 int lifeline_fd,
68 const ResultCallback& callback) = 0; 68 const ResultCallback& callback) = 0;
69 69
70 // Requests the |port| be opened on the firewall for incoming UDP packets 70 // Requests the |port| be opened on the firewall for incoming UDP packets
71 // received on |interface| (an empty string indicates all interfaces). An open 71 // received on |interface| (an empty string indicates all interfaces). An open
72 // pipe must be passed as |lifeline_fd| so that the permission broker can 72 // pipe must be passed as |lifeline_fd| so that the permission broker can
73 // monitor the lifetime of the calling process. 73 // monitor the lifetime of the calling process.
74 virtual void RequestUdpPortAccess(uint16_t port, 74 virtual void RequestUdpPortAccess(uint16_t port,
75 const std::string& interface, 75 const std::string& interface,
76 const dbus::FileDescriptor& lifeline_fd, 76 int lifeline_fd,
77 const ResultCallback& callback) = 0; 77 const ResultCallback& callback) = 0;
78 78
79 // Releases a request for an open firewall port for TCP/IP connections. The 79 // Releases a request for an open firewall port for TCP/IP connections. The
80 // |port| and |interface| parameters must be the same as a previous call to 80 // |port| and |interface| parameters must be the same as a previous call to
81 // RequestTcpPortAccess. 81 // RequestTcpPortAccess.
82 virtual void ReleaseTcpPort(uint16_t port, 82 virtual void ReleaseTcpPort(uint16_t port,
83 const std::string& interface, 83 const std::string& interface,
84 const ResultCallback& callback) = 0; 84 const ResultCallback& callback) = 0;
85 85
86 // Releases a request for an open firewall port for UDP packets. The |port| 86 // Releases a request for an open firewall port for UDP packets. The |port|
87 // and |interface| parameters must be the same as a previous call to 87 // and |interface| parameters must be the same as a previous call to
88 // RequestUdpPortAccess. 88 // RequestUdpPortAccess.
89 virtual void ReleaseUdpPort(uint16_t port, 89 virtual void ReleaseUdpPort(uint16_t port,
90 const std::string& interface, 90 const std::string& interface,
91 const ResultCallback& callback) = 0; 91 const ResultCallback& callback) = 0;
92 92
93 protected: 93 protected:
94 PermissionBrokerClient(); 94 PermissionBrokerClient();
95 95
96 private: 96 private:
97 DISALLOW_COPY_AND_ASSIGN(PermissionBrokerClient); 97 DISALLOW_COPY_AND_ASSIGN(PermissionBrokerClient);
98 }; 98 };
99 99
100 } // namespace chromeos 100 } // namespace chromeos
101 101
102 #endif // CHROMEOS_DBUS_PERMISSION_BROKER_CLIENT_H_ 102 #endif // CHROMEOS_DBUS_PERMISSION_BROKER_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698