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 "media/audio/async_socket_io_handler.h" | 5 #include "media/audio/async_socket_io_handler.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include "base/eintr_wrapper.h" | 8 #include "base/eintr_wrapper.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
11 | 11 |
12 AsyncSocketIoHandler::AsyncSocketIoHandler() | 12 AsyncSocketIoHandler::AsyncSocketIoHandler() |
13 : socket_(base::SyncSocket::kInvalidHandle), | 13 : socket_(base::SyncSocket::kInvalidHandle), |
14 is_watching_(false) {} | 14 pending_buffer_(NULL), |
| 15 pending_buffer_len_(0), |
| 16 is_watching_(false) { |
| 17 } |
15 | 18 |
16 AsyncSocketIoHandler::~AsyncSocketIoHandler() { | 19 AsyncSocketIoHandler::~AsyncSocketIoHandler() { |
17 DCHECK(CalledOnValidThread()); | 20 DCHECK(CalledOnValidThread()); |
18 } | 21 } |
19 | 22 |
20 void AsyncSocketIoHandler::OnFileCanReadWithoutBlocking(int socket) { | 23 void AsyncSocketIoHandler::OnFileCanReadWithoutBlocking(int socket) { |
21 DCHECK(CalledOnValidThread()); | 24 DCHECK(CalledOnValidThread()); |
22 DCHECK_EQ(socket, socket_); | 25 DCHECK_EQ(socket, socket_); |
23 if (!read_complete_.is_null()) { | 26 if (!read_complete_.is_null()) { |
24 int bytes_read = HANDLE_EINTR(read(socket_, pending_buffer_, | 27 int bytes_read = HANDLE_EINTR(read(socket_, pending_buffer_, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 83 |
81 void AsyncSocketIoHandler::EnsureWatchingSocket() { | 84 void AsyncSocketIoHandler::EnsureWatchingSocket() { |
82 DCHECK(CalledOnValidThread()); | 85 DCHECK(CalledOnValidThread()); |
83 if (!is_watching_ && socket_ != base::SyncSocket::kInvalidHandle) { | 86 if (!is_watching_ && socket_ != base::SyncSocket::kInvalidHandle) { |
84 is_watching_ = MessageLoopForIO::current()->WatchFileDescriptor( | 87 is_watching_ = MessageLoopForIO::current()->WatchFileDescriptor( |
85 socket_, true, MessageLoopForIO::WATCH_READ, &socket_watcher_, this); | 88 socket_, true, MessageLoopForIO::WATCH_READ, &socket_watcher_, this); |
86 } | 89 } |
87 } | 90 } |
88 | 91 |
89 } // namespace media. | 92 } // namespace media. |
OLD | NEW |