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

Side by Side Diff: chromeos/network/firewall_hole.h

Issue 2291983002: chromeos: Remove dbus::FileDescriptor from PermissionBrokerClient (Closed)
Patch Set: Address comments 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
« no previous file with comments | « chromeos/dbus/permission_broker_client.cc ('k') | chromeos/network/firewall_hole.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 CHROMEOS_NETWORK_FIREWALL_HOLE_H_ 5 #ifndef CHROMEOS_NETWORK_FIREWALL_HOLE_H_
6 #define CHROMEOS_NETWORK_FIREWALL_HOLE_H_ 6 #define CHROMEOS_NETWORK_FIREWALL_HOLE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 12
13 #include "base/callback_forward.h" 13 #include "base/callback_forward.h"
14 #include "base/files/scoped_file.h"
14 #include "chromeos/chromeos_export.h" 15 #include "chromeos/chromeos_export.h"
15 #include "dbus/file_descriptor.h"
16 16
17 namespace chromeos { 17 namespace chromeos {
18 18
19 // This class works with the Chrome OS permission broker to open a port in the 19 // This class works with the Chrome OS permission broker to open a port in the
20 // system firewall. It is closed on destruction. 20 // system firewall. It is closed on destruction.
21 class CHROMEOS_EXPORT FirewallHole { 21 class CHROMEOS_EXPORT FirewallHole {
22 public: 22 public:
23 enum class PortType { 23 enum class PortType {
24 UDP, 24 UDP,
25 TCP, 25 TCP,
26 }; 26 };
27 27
28 typedef base::Callback<void(std::unique_ptr<FirewallHole>)> OpenCallback; 28 typedef base::Callback<void(std::unique_ptr<FirewallHole>)> OpenCallback;
29 29
30 // Opens a port on the system firewall for the given network interface (or all 30 // Opens a port on the system firewall for the given network interface (or all
31 // interfaces if |interface| is ""). The hole will be closed when the object 31 // interfaces if |interface| is ""). The hole will be closed when the object
32 // provided to the callback is destroyed. 32 // provided to the callback is destroyed.
33 static void Open(PortType type, 33 static void Open(PortType type,
34 uint16_t port, 34 uint16_t port,
35 const std::string& interface, 35 const std::string& interface,
36 const OpenCallback& callback); 36 const OpenCallback& callback);
37 37
38 ~FirewallHole(); 38 ~FirewallHole();
39 39
40 private: 40 private:
41 static void RequestPortAccess(PortType type,
42 uint16_t port,
43 const std::string& interface,
44 dbus::ScopedFileDescriptor lifeline_local,
45 dbus::ScopedFileDescriptor lifeline_remote,
46 const OpenCallback& callback);
47
48 static void PortAccessGranted(PortType type, 41 static void PortAccessGranted(PortType type,
49 uint16_t port, 42 uint16_t port,
50 const std::string& interface, 43 const std::string& interface,
51 dbus::ScopedFileDescriptor lifeline_fd, 44 base::ScopedFD lifeline_fd,
52 const FirewallHole::OpenCallback& callback, 45 const FirewallHole::OpenCallback& callback,
53 bool success); 46 bool success);
54 47
55 FirewallHole(PortType type, 48 FirewallHole(PortType type,
56 uint16_t port, 49 uint16_t port,
57 const std::string& interface, 50 const std::string& interface,
58 dbus::ScopedFileDescriptor lifeline_fd); 51 base::ScopedFD lifeline_fd);
59 52
60 const PortType type_; 53 const PortType type_;
61 const uint16_t port_; 54 const uint16_t port_;
62 const std::string interface_; 55 const std::string interface_;
63 56
64 // A file descriptor used by firewalld to track the lifetime of this process. 57 // A file descriptor used by firewalld to track the lifetime of this process.
65 dbus::ScopedFileDescriptor lifeline_fd_; 58 base::ScopedFD lifeline_fd_;
66 }; 59 };
67 60
68 } // namespace chromeos 61 } // namespace chromeos
69 62
70 #endif // CHROMEOS_NETWORK_FIREWALL_HOLE_H_ 63 #endif // CHROMEOS_NETWORK_FIREWALL_HOLE_H_
OLDNEW
« no previous file with comments | « chromeos/dbus/permission_broker_client.cc ('k') | chromeos/network/firewall_hole.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698