Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROMEOS_BINDER_IPC_THREAD_H_ | |
| 6 #define CHROMEOS_BINDER_IPC_THREAD_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/message_loop/message_loop.h" | |
| 10 #include "base/threading/thread.h" | |
| 11 #include "chromeos/chromeos_export.h" | |
| 12 | |
| 13 namespace binder { | |
| 14 | |
| 15 class CommandBroker; | |
| 16 class Driver; | |
| 17 | |
| 18 // IpcThread manages binder-related resources (e.g. binder driver FD) and | |
| 19 // handles incoming binder commands. | |
|
satorux1
2016/01/14 06:34:18
Is it OK to instantiate this class and call Start(
hashimoto
2016/01/14 06:49:38
It's OK to do that like all other base::Thread sub
satorux1
2016/01/14 07:07:13
I felt this class was tricky because it deals with
hashimoto
2016/01/14 08:52:03
It deals with the binder driver, but all meaningfu
| |
| 20 class CHROMEOS_EXPORT IpcThread : public base::Thread, | |
| 21 public base::MessageLoopForIO::Watcher { | |
| 22 public: | |
| 23 IpcThread(); | |
| 24 ~IpcThread() override; | |
| 25 | |
| 26 Driver* driver() { return driver_.get(); } | |
| 27 CommandBroker* command_broker() { return command_broker_.get(); } | |
| 28 bool initialized() const { return initialized_; } | |
| 29 | |
| 30 // Starts this thread. | |
| 31 // Returns true on success. | |
| 32 bool Start(); | |
| 33 | |
| 34 // base::MessageLoopIO::Watcher overrides: | |
| 35 void OnFileCanReadWithoutBlocking(int fd) override; | |
| 36 void OnFileCanWriteWithoutBlocking(int fd) override; | |
| 37 | |
| 38 protected: | |
| 39 // base::Thread overrides: | |
| 40 void Init() override; | |
| 41 void CleanUp() override; | |
| 42 | |
| 43 private: | |
| 44 scoped_ptr<Driver> driver_; | |
| 45 scoped_ptr<CommandBroker> command_broker_; | |
| 46 scoped_ptr<base::MessageLoopForIO::FileDescriptorWatcher> watcher_; | |
| 47 bool initialized_ = false; | |
| 48 | |
| 49 DISALLOW_COPY_AND_ASSIGN(IpcThread); | |
| 50 }; | |
| 51 | |
| 52 } // namespace binder | |
| 53 | |
| 54 #endif // CHROMEOS_BINDER_IPC_THREAD_H_ | |
| OLD | NEW |