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

Unified Diff: device/serial/serial_io_handler.cc

Issue 646053002: Implement permission_broker for serial devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: device/serial/serial_io_handler.cc
diff --git a/device/serial/serial_io_handler.cc b/device/serial/serial_io_handler.cc
index 341df294c96406eac7897569d40bd8e273193ebc..6e6d5be8ce26f160282087d3591952d68594cadd 100644
--- a/device/serial/serial_io_handler.cc
+++ b/device/serial/serial_io_handler.cc
@@ -27,12 +27,34 @@ void SerialIoHandler::Open(const std::string& port,
DCHECK(open_complete_.is_null());
open_complete_ = callback;
DCHECK(file_thread_message_loop_.get());
- file_thread_message_loop_->PostTask(
- FROM_HERE,
- base::Bind(&SerialIoHandler::StartOpen,
- this,
- port,
- base::MessageLoopProxy::current()));
+ RequestAccess(port, file_thread_message_loop_);
+}
+
+void SerialIoHandler::RequestAccess(
+ const std::string& port,
+ scoped_refptr<base::MessageLoopProxy> io_message_loop) {
+ OnRequestAccessComplete(port, true /* success */);
+}
+
+void SerialIoHandler::OnRequestAccessComplete(const std::string& port,
+ bool success) {
+ DCHECK(CalledOnValidThread());
+ if (success) {
+ DCHECK(file_thread_message_loop_.get());
+ file_thread_message_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(&SerialIoHandler::StartOpen,
+ this,
+ port,
+ base::MessageLoopProxy::current()));
+ return;
+ } else {
+ DCHECK(!open_complete_.is_null());
+ OpenCompleteCallback callback = open_complete_;
+ open_complete_.Reset();
+ callback.Run(false);
+ return;
+ }
}
void SerialIoHandler::StartOpen(

Powered by Google App Engine
This is Rietveld 408576698