LCOV - code coverage report
Current view: directory - ipc/chromium/src/chrome/common - child_thread.h (source / functions) Found Hit Coverage
Test: app.info Lines: 2 1 50.0 %
Date: 2012-06-02 Functions: 2 1 50.0 %

       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.
       4                 : 
       5                 : #ifndef CHROME_COMMON_CHILD_THREAD_H_
       6                 : #define CHROME_COMMON_CHILD_THREAD_H_
       7                 : 
       8                 : #include "base/thread.h"
       9                 : #include "chrome/common/ipc_sync_channel.h"
      10                 : #include "chrome/common/message_router.h"
      11                 : 
      12                 : class ResourceDispatcher;
      13                 : 
      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();
      22                 : 
      23                 :   // IPC::Message::Sender implementation:
      24                 :   virtual bool Send(IPC::Message* msg);
      25                 : 
      26                 :   // See documentation on MessageRouter for AddRoute and RemoveRoute
      27                 :   void AddRoute(int32 routing_id, IPC::Channel::Listener* listener);
      28                 :   void RemoveRoute(int32 routing_id);
      29                 : 
      30                 :   MessageLoop* owner_loop() { return owner_loop_; }
      31                 : 
      32                 :  protected:
      33                 :   friend class ChildProcess;
      34                 : 
      35                 :   // Starts the thread.
      36                 :   bool Run();
      37                 : 
      38                 :   // Overrides the channel name.  Used for --single-process mode.
      39                 :   void SetChannelName(const std::wstring& name) { channel_name_ = name; }
      40                 : 
      41                 :   // Called when the process refcount is 0.
      42                 :   void OnProcessFinalRelease();
      43                 : 
      44                 :  protected:
      45                 :   // The required stack size if V8 runs on a thread.
      46                 :   static const size_t kV8StackSize;
      47                 : 
      48               0 :   virtual void OnControlMessageReceived(const IPC::Message& msg) { }
      49                 : 
      50                 :   // Returns the one child thread.
      51                 :   static ChildThread* current();
      52                 : 
      53               1 :   IPC::Channel* channel() { return channel_.get(); }
      54                 : 
      55                 :   // Thread implementation.
      56                 :   virtual void Init();
      57                 :   virtual void CleanUp();
      58                 : 
      59                 :  private:
      60                 :   // IPC::Channel::Listener implementation:
      61                 :   virtual void OnMessageReceived(const IPC::Message& msg);
      62                 :   virtual void OnChannelError();
      63                 : 
      64                 :   // The message loop used to run tasks on the thread that started this thread.
      65                 :   MessageLoop* owner_loop_;
      66                 : 
      67                 :   std::wstring channel_name_;
      68                 :   scoped_ptr<IPC::Channel> channel_;
      69                 : 
      70                 :   // Used only on the background render thread to implement message routing
      71                 :   // functionality to the consumers of the ChildThread.
      72                 :   MessageRouter router_;
      73                 : 
      74                 :   Thread::Options options_;
      75                 : 
      76                 :   // If true, checks with the browser process before shutdown.  This avoids race
      77                 :   // conditions if the process refcount is 0 but there's an IPC message inflight
      78                 :   // that would addref it.
      79                 :   bool check_with_browser_before_shutdown_;
      80                 : 
      81                 :   DISALLOW_EVIL_CONSTRUCTORS(ChildThread);
      82                 : };
      83                 : 
      84                 : #endif  // CHROME_COMMON_CHILD_THREAD_H_

Generated by: LCOV version 1.7