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 #ifndef MEDIA_AUDIO_ASYNC_SOCKET_IO_HANDLER_H_ | 5 #ifndef BASE_ASYNC_SOCKET_IO_HANDLER_H_ |
6 #define MEDIA_AUDIO_ASYNC_SOCKET_IO_HANDLER_H_ | 6 #define BASE_ASYNC_SOCKET_IO_HANDLER_H_ |
7 | 7 |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/sync_socket.h" | 9 #include "base/sync_socket.h" |
10 #include "base/threading/non_thread_safe.h" | 10 #include "base/threading/non_thread_safe.h" |
11 #include "media/base/media_export.h" | |
12 | 11 |
13 namespace media { | 12 namespace media { |
14 | 13 |
15 // The message loop callback interface is different based on platforms. | 14 // The message loop callback interface is different based on platforms. |
16 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
17 typedef base::MessageLoopForIO::IOHandler MessageLoopIOHandler; | 16 typedef base::MessageLoopForIO::IOHandler MessageLoopIOHandler; |
18 #elif defined(OS_POSIX) | 17 #elif defined(OS_POSIX) |
19 typedef base::MessageLoopForIO::Watcher MessageLoopIOHandler; | 18 typedef base::MessageLoopForIO::Watcher MessageLoopIOHandler; |
20 #endif | 19 #endif |
21 | 20 |
(...skipping 23 matching lines...) Expand all Loading... |
45 // // Issue another read. | 44 // // Issue another read. |
46 // CHECK(io_handler.Read(&buffer_[0], sizeof(buffer_))); | 45 // CHECK(io_handler.Read(&buffer_[0], sizeof(buffer_))); |
47 // } | 46 // } |
48 // } | 47 // } |
49 // | 48 // |
50 // media::AsyncSocketIoHandler io_handler; | 49 // media::AsyncSocketIoHandler io_handler; |
51 // base::CancelableSyncSocket* socket_; | 50 // base::CancelableSyncSocket* socket_; |
52 // char buffer_[kBufferSize]; | 51 // char buffer_[kBufferSize]; |
53 // }; | 52 // }; |
54 // | 53 // |
55 class MEDIA_EXPORT AsyncSocketIoHandler | 54 class BASE_EXPORT AsyncSocketIoHandler |
56 : public NON_EXPORTED_BASE(base::NonThreadSafe), | 55 : public NON_EXPORTED_BASE(base::NonThreadSafe), |
57 public NON_EXPORTED_BASE(MessageLoopIOHandler) { | 56 public NON_EXPORTED_BASE(MessageLoopIOHandler) { |
58 public: | 57 public: |
59 AsyncSocketIoHandler(); | 58 AsyncSocketIoHandler(); |
60 virtual ~AsyncSocketIoHandler(); | 59 virtual ~AsyncSocketIoHandler(); |
61 | 60 |
62 // Type definition for the callback. The parameter tells how many | 61 // Type definition for the callback. The parameter tells how many |
63 // bytes were read and is 0 if an error occurred. | 62 // bytes were read and is 0 if an error occurred. |
64 typedef base::Callback<void(int)> ReadCompleteCallback; | 63 typedef base::Callback<void(int)> ReadCompleteCallback; |
65 | 64 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // |true| iff the message loop is watching the socket for IO events. | 102 // |true| iff the message loop is watching the socket for IO events. |
104 bool is_watching_; | 103 bool is_watching_; |
105 #endif | 104 #endif |
106 ReadCompleteCallback read_complete_; | 105 ReadCompleteCallback read_complete_; |
107 | 106 |
108 DISALLOW_COPY_AND_ASSIGN(AsyncSocketIoHandler); | 107 DISALLOW_COPY_AND_ASSIGN(AsyncSocketIoHandler); |
109 }; | 108 }; |
110 | 109 |
111 } // namespace media. | 110 } // namespace media. |
112 | 111 |
113 #endif // MEDIA_AUDIO_ASYNC_SOCKET_IO_HANDLER_H_ | 112 #endif // BASE_ASYNC_SOCKET_IO_HANDLER_H_ |
OLD | NEW |