ipc/chromium/src/chrome/common/child_thread.h

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     1 // Copyright (c) 2009 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.
     5 #ifndef CHROME_COMMON_CHILD_THREAD_H_
     6 #define CHROME_COMMON_CHILD_THREAD_H_
     8 #include "base/thread.h"
     9 #include "chrome/common/ipc_sync_channel.h"
    10 #include "chrome/common/message_router.h"
    12 class ResourceDispatcher;
    14 // Child processes's background thread should derive from this class.
    15 class ChildThread : public IPC::Channel::Listener,
    16                     public IPC::Message::Sender,
    17                     public base::Thread {
    18  public:
    19   // Creates the thread.
    20   ChildThread(Thread::Options options);
    21   virtual ~ChildThread();
    23   // IPC::Message::Sender implementation:
    24   virtual bool Send(IPC::Message* msg);
    26   // See documentation on MessageRouter for AddRoute and RemoveRoute
    27   void AddRoute(int32_t routing_id, IPC::Channel::Listener* listener);
    28   void RemoveRoute(int32_t routing_id);
    30   MessageLoop* owner_loop() { return owner_loop_; }
    32  protected:
    33   friend class ChildProcess;
    35   // Starts the thread.
    36   bool Run();
    38   // Overrides the channel name.  Used for --single-process mode.
    39   void SetChannelName(const std::wstring& name) { channel_name_ = name; }
    41   // Called when the process refcount is 0.
    42   void OnProcessFinalRelease();
    44  protected:
    45   // The required stack size if V8 runs on a thread.
    46   static const size_t kV8StackSize;
    48   virtual void OnControlMessageReceived(const IPC::Message& msg) { }
    50   // Returns the one child thread.
    51   static ChildThread* current();
    53   IPC::Channel* channel() { return channel_.get(); }
    55   // Thread implementation.
    56   virtual void Init();
    57   virtual void CleanUp();
    59  private:
    60   // IPC::Channel::Listener implementation:
    61   virtual void OnMessageReceived(const IPC::Message& msg);
    62   virtual void OnChannelError();
    64 #ifdef MOZ_NUWA_PROCESS
    65   static void MarkThread();
    66 #endif
    68   // The message loop used to run tasks on the thread that started this thread.
    69   MessageLoop* owner_loop_;
    71   std::wstring channel_name_;
    72   scoped_ptr<IPC::Channel> channel_;
    74   // Used only on the background render thread to implement message routing
    75   // functionality to the consumers of the ChildThread.
    76   MessageRouter router_;
    78   Thread::Options options_;
    80   // If true, checks with the browser process before shutdown.  This avoids race
    81   // conditions if the process refcount is 0 but there's an IPC message inflight
    82   // that would addref it.
    83   bool check_with_browser_before_shutdown_;
    85   DISALLOW_EVIL_CONSTRUCTORS(ChildThread);
    86 };
    88 #endif  // CHROME_COMMON_CHILD_THREAD_H_

mercurial