1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef dom_plugins_IOThreadChild_h 8 #define dom_plugins_IOThreadChild_h 1 9 10 #include "chrome/common/child_thread.h" 11 #include "mozilla/ipc/NodeController.h" 12 13 namespace mozilla { 14 namespace ipc { 15 //----------------------------------------------------------------------------- 16 17 // The IOThreadChild class represents a background thread where the 18 // IPC IO MessageLoop lives. 19 class IOThreadChild : public ChildThread { 20 public: IOThreadChild()21 IOThreadChild() 22 : ChildThread(base::Thread::Options(MessageLoop::TYPE_IO, 23 0)) // stack size 24 {} 25 26 ~IOThreadChild() = default; 27 message_loop()28 static MessageLoop* message_loop() { 29 return IOThreadChild::current()->Thread::message_loop(); 30 } 31 TakeInitialPort()32 static ScopedPort TakeInitialPort() { 33 return IOThreadChild::current()->ChildThread::TakeInitialPort(); 34 } 35 36 protected: current()37 static IOThreadChild* current() { 38 return static_cast<IOThreadChild*>(ChildThread::current()); 39 } 40 41 private: 42 DISALLOW_EVIL_CONSTRUCTORS(IOThreadChild); 43 }; 44 45 } // namespace ipc 46 } // namespace mozilla 47 48 #endif // ifndef dom_plugins_IOThreadChild_h 49