• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (C) 2014 The Android Open Source Project
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef SHILL_NET_IO_READY_HANDLER_H_
18 #define SHILL_NET_IO_READY_HANDLER_H_
19 
20 #include <base/message_loop/message_loop.h>
21 
22 #include "shill/net/io_handler.h"
23 
24 namespace shill {
25 
26 // This handler is different from the IOInputHandler
27 // in that we don't read from the file handle and
28 // leave that to the caller.  This is useful in accept()ing
29 // sockets and effort to working with peripheral libraries.
30 class IOReadyHandler : public IOHandler,
31                        public base::MessageLoopForIO::Watcher {
32  public:
33   IOReadyHandler(int fd,
34                  ReadyMode mode,
35                  const ReadyCallback& ready_callback);
36   ~IOReadyHandler();
37 
38   void Start() override;
39   void Stop() override;
40 
41  private:
42   // base::MessageLoopForIO::Watcher methods.
43   void OnFileCanReadWithoutBlocking(int fd) override;
44   void OnFileCanWriteWithoutBlocking(int fd) override;
45 
46   int fd_;
47   base::MessageLoopForIO::FileDescriptorWatcher fd_watcher_;
48   ReadyMode ready_mode_;
49   ReadyCallback ready_callback_;
50 };
51 
52 }  // namespace shill
53 
54 #endif  // SHILL_NET_IO_READY_HANDLER_H_
55