| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/fake_permission_broker_client.h" | 5 #include "chromeos/dbus/fake_permission_broker_client.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/posix/eintr_wrapper.h" | 14 #include "base/posix/eintr_wrapper.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "base/task_scheduler/post_task.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "base/threading/worker_pool.h" | |
| 18 | 18 |
| 19 namespace chromeos { | 19 namespace chromeos { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 const char kOpenFailedError[] = "open_failed"; | 23 const char kOpenFailedError[] = "open_failed"; |
| 24 | 24 |
| 25 // So that real devices can be accessed by tests and "Chromium OS on Linux" this | 25 // So that real devices can be accessed by tests and "Chromium OS on Linux" this |
| 26 // function implements a simplified version of the method implemented by the | 26 // function implements a simplified version of the method implemented by the |
| 27 // permission broker by opening the path specified and returning the resulting | 27 // permission broker by opening the path specified and returning the resulting |
| (...skipping 27 matching lines...) Expand all Loading... |
| 55 | 55 |
| 56 void FakePermissionBrokerClient::CheckPathAccess( | 56 void FakePermissionBrokerClient::CheckPathAccess( |
| 57 const std::string& path, | 57 const std::string& path, |
| 58 const ResultCallback& callback) { | 58 const ResultCallback& callback) { |
| 59 callback.Run(true); | 59 callback.Run(true); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void FakePermissionBrokerClient::OpenPath(const std::string& path, | 62 void FakePermissionBrokerClient::OpenPath(const std::string& path, |
| 63 const OpenPathCallback& callback, | 63 const OpenPathCallback& callback, |
| 64 const ErrorCallback& error_callback) { | 64 const ErrorCallback& error_callback) { |
| 65 base::WorkerPool::PostTask( | 65 base::PostTaskWithTraits( |
| 66 FROM_HERE, base::Bind(&chromeos::OpenPath, path, callback, error_callback, | 66 FROM_HERE, base::TaskTraits() |
| 67 base::ThreadTaskRunnerHandle::Get()), | 67 .WithShutdownBehavior( |
| 68 false); | 68 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) |
| 69 .MayBlock(), |
| 70 base::Bind(&chromeos::OpenPath, path, callback, error_callback, |
| 71 base::ThreadTaskRunnerHandle::Get())); |
| 69 } | 72 } |
| 70 | 73 |
| 71 void FakePermissionBrokerClient::RequestTcpPortAccess( | 74 void FakePermissionBrokerClient::RequestTcpPortAccess( |
| 72 uint16_t port, | 75 uint16_t port, |
| 73 const std::string& interface, | 76 const std::string& interface, |
| 74 int lifeline_fd, | 77 int lifeline_fd, |
| 75 const ResultCallback& callback) { | 78 const ResultCallback& callback) { |
| 76 callback.Run(true); | 79 callback.Run(true); |
| 77 } | 80 } |
| 78 | 81 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 92 } | 95 } |
| 93 | 96 |
| 94 void FakePermissionBrokerClient::ReleaseUdpPort( | 97 void FakePermissionBrokerClient::ReleaseUdpPort( |
| 95 uint16_t port, | 98 uint16_t port, |
| 96 const std::string& interface, | 99 const std::string& interface, |
| 97 const ResultCallback& callback) { | 100 const ResultCallback& callback) { |
| 98 callback.Run(true); | 101 callback.Run(true); |
| 99 } | 102 } |
| 100 | 103 |
| 101 } // namespace chromeos | 104 } // namespace chromeos |
| OLD | NEW |