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; |
47 | 48 |
48 #if defined(OS_CHROMEOS) | 49 #if defined(OS_CHROMEOS) |
49 chromeos::PermissionBrokerClient* client = | 50 chromeos::PermissionBrokerClient* client = |
50 chromeos::DBusThreadManager::Get()->GetPermissionBrokerClient(); | 51 chromeos::DBusThreadManager::Get()->GetPermissionBrokerClient(); |
51 DCHECK(client) << "Could not get permission_broker client."; | 52 DCHECK(client) << "Could not get permission_broker client."; |
52 // PermissionBrokerClient should be called on the UI thread. | 53 // PermissionBrokerClient should be called on the UI thread. |
53 ui_thread_task_runner_->PostTask( | 54 ui_thread_task_runner_->PostTask( |
54 FROM_HERE, base::Bind(&chromeos::PermissionBrokerClient::OpenPath, | 55 FROM_HERE, base::Bind(&chromeos::PermissionBrokerClient::OpenPath, |
55 base::Unretained(client), port, | 56 base::Unretained(client), port, |
56 base::Bind(&SerialIoHandler::OnPathOpened, this, | 57 base::Bind(&SerialIoHandler::OnPathOpened, this, |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 } | 258 } |
258 | 259 |
259 void SerialIoHandler::QueueWriteCompleted(int bytes_written, | 260 void SerialIoHandler::QueueWriteCompleted(int bytes_written, |
260 serial::SendError error) { | 261 serial::SendError error) { |
261 base::MessageLoop::current()->PostTask( | 262 base::MessageLoop::current()->PostTask( |
262 FROM_HERE, | 263 FROM_HERE, |
263 base::Bind(&SerialIoHandler::WriteCompleted, this, bytes_written, error)); | 264 base::Bind(&SerialIoHandler::WriteCompleted, this, bytes_written, error)); |
264 } | 265 } |
265 | 266 |
266 } // namespace device | 267 } // namespace device |
OLD | NEW |