| OLD | NEW |
| 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 #include "chromeos/dbus/permission_broker_client.h" | 5 #include "chromeos/dbus/permission_broker_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "dbus/bus.h" | 9 #include "dbus/bus.h" |
| 10 #include "dbus/message.h" | 10 #include "dbus/message.h" |
| 11 #include "dbus/object_proxy.h" | 11 #include "dbus/object_proxy.h" |
| 12 #include "third_party/cros_system_api/dbus/service_constants.h" | 12 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 13 | 13 |
| 14 using permission_broker::kCheckPathAccess; |
| 14 using permission_broker::kPermissionBrokerInterface; | 15 using permission_broker::kPermissionBrokerInterface; |
| 15 using permission_broker::kPermissionBrokerServiceName; | 16 using permission_broker::kPermissionBrokerServiceName; |
| 16 using permission_broker::kPermissionBrokerServicePath; | 17 using permission_broker::kPermissionBrokerServicePath; |
| 17 using permission_broker::kReleaseTcpPort; | 18 using permission_broker::kReleaseTcpPort; |
| 18 using permission_broker::kReleaseUdpPort; | 19 using permission_broker::kReleaseUdpPort; |
| 19 using permission_broker::kRequestPathAccess; | 20 using permission_broker::kRequestPathAccess; |
| 20 using permission_broker::kRequestTcpPortAccess; | 21 using permission_broker::kRequestTcpPortAccess; |
| 21 using permission_broker::kRequestUdpPortAccess; | 22 using permission_broker::kRequestUdpPortAccess; |
| 22 | 23 |
| 23 namespace chromeos { | 24 namespace chromeos { |
| 24 | 25 |
| 25 class PermissionBrokerClientImpl : public PermissionBrokerClient { | 26 class PermissionBrokerClientImpl : public PermissionBrokerClient { |
| 26 public: | 27 public: |
| 27 PermissionBrokerClientImpl() : proxy_(NULL), weak_ptr_factory_(this) {} | 28 PermissionBrokerClientImpl() : proxy_(NULL), weak_ptr_factory_(this) {} |
| 28 | 29 |
| 30 void CheckPathAccess(const std::string& path, |
| 31 const ResultCallback& callback) override { |
| 32 dbus::MethodCall method_call(kPermissionBrokerInterface, kCheckPathAccess); |
| 33 dbus::MessageWriter writer(&method_call); |
| 34 writer.AppendString(path); |
| 35 proxy_->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 36 base::Bind(&PermissionBrokerClientImpl::OnResponse, |
| 37 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 38 } |
| 39 |
| 29 void RequestPathAccess(const std::string& path, | 40 void RequestPathAccess(const std::string& path, |
| 30 const int interface_id, | 41 const int interface_id, |
| 31 const ResultCallback& callback) override { | 42 const ResultCallback& callback) override { |
| 32 dbus::MethodCall method_call(kPermissionBrokerInterface, | 43 dbus::MethodCall method_call(kPermissionBrokerInterface, |
| 33 kRequestPathAccess); | 44 kRequestPathAccess); |
| 34 dbus::MessageWriter writer(&method_call); | 45 dbus::MessageWriter writer(&method_call); |
| 35 writer.AppendString(path); | 46 writer.AppendString(path); |
| 36 writer.AppendInt32(interface_id); | 47 writer.AppendInt32(interface_id); |
| 37 proxy_->CallMethod(&method_call, | 48 proxy_->CallMethod(&method_call, |
| 38 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 49 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 141 |
| 131 PermissionBrokerClient::PermissionBrokerClient() {} | 142 PermissionBrokerClient::PermissionBrokerClient() {} |
| 132 | 143 |
| 133 PermissionBrokerClient::~PermissionBrokerClient() {} | 144 PermissionBrokerClient::~PermissionBrokerClient() {} |
| 134 | 145 |
| 135 PermissionBrokerClient* PermissionBrokerClient::Create() { | 146 PermissionBrokerClient* PermissionBrokerClient::Create() { |
| 136 return new PermissionBrokerClientImpl(); | 147 return new PermissionBrokerClientImpl(); |
| 137 } | 148 } |
| 138 | 149 |
| 139 } // namespace chromeos | 150 } // namespace chromeos |
| OLD | NEW |