| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "device/serial/serial_io_handler.h" | 5 #include "device/serial/serial_io_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 void SerialIoHandler::Open(const std::string& port, | 38 void SerialIoHandler::Open(const std::string& port, |
| 39 const serial::ConnectionOptions& options, | 39 const serial::ConnectionOptions& options, |
| 40 const OpenCompleteCallback& callback) { | 40 const OpenCompleteCallback& callback) { |
| 41 DCHECK(CalledOnValidThread()); | 41 DCHECK(CalledOnValidThread()); |
| 42 DCHECK(open_complete_.is_null()); | 42 DCHECK(open_complete_.is_null()); |
| 43 open_complete_ = callback; | 43 open_complete_ = callback; |
| 44 DCHECK(file_thread_task_runner_.get()); | 44 DCHECK(file_thread_task_runner_.get()); |
| 45 DCHECK(ui_thread_task_runner_.get()); | 45 DCHECK(ui_thread_task_runner_.get()); |
| 46 MergeConnectionOptions(options); | 46 MergeConnectionOptions(options); |
| 47 port_ = port; | |
| 48 | 47 |
| 49 #if defined(OS_CHROMEOS) | 48 #if defined(OS_CHROMEOS) |
| 50 chromeos::PermissionBrokerClient* client = | 49 chromeos::PermissionBrokerClient* client = |
| 51 chromeos::DBusThreadManager::Get()->GetPermissionBrokerClient(); | 50 chromeos::DBusThreadManager::Get()->GetPermissionBrokerClient(); |
| 52 DCHECK(client) << "Could not get permission_broker client."; | 51 DCHECK(client) << "Could not get permission_broker client."; |
| 53 // PermissionBrokerClient should be called on the UI thread. | 52 // PermissionBrokerClient should be called on the UI thread. |
| 54 ui_thread_task_runner_->PostTask( | 53 ui_thread_task_runner_->PostTask( |
| 55 FROM_HERE, base::Bind(&chromeos::PermissionBrokerClient::OpenPath, | 54 FROM_HERE, base::Bind(&chromeos::PermissionBrokerClient::OpenPath, |
| 56 base::Unretained(client), port, | 55 base::Unretained(client), port, |
| 57 base::Bind(&SerialIoHandler::OnPathOpened, this, | 56 base::Bind(&SerialIoHandler::OnPathOpened, this, |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 } | 257 } |
| 259 | 258 |
| 260 void SerialIoHandler::QueueWriteCompleted(int bytes_written, | 259 void SerialIoHandler::QueueWriteCompleted(int bytes_written, |
| 261 serial::SendError error) { | 260 serial::SendError error) { |
| 262 base::MessageLoop::current()->PostTask( | 261 base::MessageLoop::current()->PostTask( |
| 263 FROM_HERE, | 262 FROM_HERE, |
| 264 base::Bind(&SerialIoHandler::WriteCompleted, this, bytes_written, error)); | 263 base::Bind(&SerialIoHandler::WriteCompleted, this, bytes_written, error)); |
| 265 } | 264 } |
| 266 | 265 |
| 267 } // namespace device | 266 } // namespace device |
| OLD | NEW |