Home | History | Annotate | Download | only in plugin
      1 // Copyright (c) 2012 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 CONTENT_PLUGIN_PLUGIN_THREAD_H_
      6 #define CONTENT_PLUGIN_PLUGIN_THREAD_H_
      7 
      8 #include "base/files/file_path.h"
      9 #include "base/native_library.h"
     10 #include "build/build_config.h"
     11 #include "content/child/child_thread.h"
     12 #include "content/child/npapi/plugin_lib.h"
     13 #include "content/plugin/plugin_channel.h"
     14 
     15 #if defined(OS_POSIX)
     16 #include "base/file_descriptor_posix.h"
     17 #endif
     18 
     19 namespace content {
     20 
     21 // The PluginThread class represents a background thread where plugin instances
     22 // live.  Communication occurs between WebPluginDelegateProxy in the renderer
     23 // process and WebPluginDelegateStub in this thread through IPC messages.
     24 class PluginThread : public ChildThread {
     25  public:
     26   PluginThread();
     27   virtual ~PluginThread();
     28   virtual void Shutdown() OVERRIDE;
     29 
     30   // Returns the one plugin thread.
     31   static PluginThread* current();
     32 
     33   // Tells the plugin thread to terminate the process forcefully instead of
     34   // exiting cleanly.
     35   void SetForcefullyTerminatePluginProcess();
     36 
     37  private:
     38   virtual bool OnControlMessageReceived(const IPC::Message& msg) OVERRIDE;
     39 
     40   // Callback for when a channel has been created.
     41   void OnCreateChannel(int renderer_id, bool incognito);
     42   void OnPluginMessage(const std::vector<uint8> &data);
     43   void OnNotifyRenderersOfPendingShutdown();
     44 #if defined(OS_MACOSX)
     45   void OnAppActivated();
     46   void OnPluginFocusNotify(uint32 instance_id);
     47 #endif
     48 
     49   // The plugin module which is preloaded in Init
     50   base::NativeLibrary preloaded_plugin_module_;
     51 
     52   bool forcefully_terminate_plugin_process_;
     53 
     54   DISALLOW_COPY_AND_ASSIGN(PluginThread);
     55 };
     56 
     57 }  // namespace content
     58 
     59 #endif  // CONTENT_PLUGIN_PLUGIN_THREAD_H_
     60