Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / content / browser / renderer_host / render_message_filter.h
index d23d9b7..9d83626 100644 (file)
 #include "base/sequenced_task_runner_helpers.h"
 #include "base/strings/string16.h"
 #include "build/build_config.h"
-#include "content/common/pepper_renderer_instance_data.h"
+#include "cc/resources/shared_bitmap_manager.h"
 #include "content/public/browser/browser_message_filter.h"
 #include "content/public/common/three_d_api_types.h"
+#include "ipc/message_filter.h"
 #include "media/audio/audio_parameters.h"
 #include "media/base/channel_layout.h"
 #include "net/cookies/canonical_cookie.h"
 #include "third_party/WebKit/public/web/WebPopupType.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/gpu_memory_buffer.h"
 #include "ui/gfx/native_widget_types.h"
 #include "ui/surface/transport_dib.h"
 
 #if defined(OS_MACOSX)
+#include <IOSurface/IOSurfaceAPI.h>
 #include "base/mac/scoped_cftyperef.h"
 #include "content/common/mac/font_loader.h"
 #endif
 #include "base/threading/worker_pool.h"
 #endif
 
+#if defined(ENABLE_PLUGINS)
+#include "content/common/pepper_renderer_instance_data.h"
+#endif
+
 struct FontDescriptor;
+struct FrameHostMsg_AddNavigationTransitionData_Params;
 struct ViewHostMsg_CreateWindow_Params;
 
 namespace blink {
@@ -52,7 +61,6 @@ class TaskRunner;
 }
 
 namespace gfx {
-class Rect;
 struct GpuMemoryBufferHandle;
 }
 
@@ -62,6 +70,7 @@ struct MediaLogEvent;
 }
 
 namespace net {
+class CookieStore;
 class KeygenHandler;
 class URLRequestContext;
 class URLRequestContextGetter;
@@ -80,11 +89,10 @@ struct WebPluginInfo;
 
 // This class filters out incoming IPC messages for the renderer process on the
 // IPC thread.
-class RenderMessageFilter : public BrowserMessageFilter {
+class CONTENT_EXPORT RenderMessageFilter : public BrowserMessageFilter {
  public:
   // Create the filter.
   RenderMessageFilter(int render_process_id,
-                      bool is_guest,
                       PluginServiceImpl * plugin_service,
                       BrowserContext* browser_context,
                       net::URLRequestContextGetter* request_context,
@@ -93,25 +101,33 @@ class RenderMessageFilter : public BrowserMessageFilter {
                       MediaInternals* media_internals,
                       DOMStorageContextWrapper* dom_storage_context);
 
-  // IPC::ChannelProxy::MessageFilter methods:
-  virtual void OnChannelClosing() OVERRIDE;
-  virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
+  // IPC::MessageFilter methods:
+  void OnChannelClosing() override;
 
   // BrowserMessageFilter methods:
-  virtual bool OnMessageReceived(const IPC::Message& message,
-                                 bool* message_was_ok) OVERRIDE;
-  virtual void OnDestruct() const OVERRIDE;
-  virtual base::TaskRunner* OverrideTaskRunnerForMessage(
-      const IPC::Message& message) OVERRIDE;
+  bool OnMessageReceived(const IPC::Message& message) override;
+  void OnDestruct() const override;
+  base::TaskRunner* OverrideTaskRunnerForMessage(
+      const IPC::Message& message) override;
 
   bool OffTheRecord() const;
 
   int render_process_id() const { return render_process_id_; }
 
-  // Returns the correct net::URLRequestContext depending on what type of url is
+  // Returns the correct net::CookieStore depending on what type of url is
   // given.
   // Only call on the IO thread.
-  net::URLRequestContext* GetRequestContextForURL(const GURL& url);
+  net::CookieStore* GetCookieStoreForURL(const GURL& url);
+
+ protected:
+  ~RenderMessageFilter() override;
+
+  // This method will be overridden by TestSaveImageFromDataURL class for test.
+  virtual void DownloadUrl(int render_view_id,
+                           const GURL& url,
+                           const Referrer& referrer,
+                           const base::string16& suggested_name,
+                           const bool use_prompt) const;
 
  private:
   friend class BrowserThread;
@@ -119,8 +135,6 @@ class RenderMessageFilter : public BrowserMessageFilter {
 
   class OpenChannelToNpapiPluginCallback;
 
-  virtual ~RenderMessageFilter();
-
   void OnGetProcessMemorySizes(size_t* private_bytes, size_t* shared_bytes);
   void OnCreateWindow(const ViewHostMsg_CreateWindow_Params& params,
                       int* route_id,
@@ -147,7 +161,8 @@ class RenderMessageFilter : public BrowserMessageFilter {
                        IPC::Message* reply_msg);
   void OnDeleteCookie(const GURL& url,
                       const std::string& cookieName);
-  void OnCookiesEnabled(const GURL& url,
+  void OnCookiesEnabled(int render_frame_id,
+                        const GURL& url,
                         const GURL& first_party_for_cookies,
                         bool* cookies_enabled);
 
@@ -162,6 +177,7 @@ class RenderMessageFilter : public BrowserMessageFilter {
                                 const base::string16& characters);
 #endif
 
+#if defined(ENABLE_PLUGINS)
   void OnGetPlugins(bool refresh, IPC::Message* reply_msg);
   void GetPluginsCallback(IPC::Message* reply_msg,
                           const std::vector<WebPluginInfo>& plugins);
@@ -189,16 +205,16 @@ class RenderMessageFilter : public BrowserMessageFilter {
                                              bool is_external);
   void OnOpenChannelToPpapiBroker(int routing_id,
                                   const base::FilePath& path);
+#endif  // defined(ENABLE_PLUGINS)
   void OnGenerateRoutingID(int* route_id);
-  void OnDownloadUrl(const IPC::Message& message,
+  void OnDownloadUrl(int render_view_id,
                      const GURL& url,
                      const Referrer& referrer,
                      const base::string16& suggested_name);
+  void OnSaveImageFromDataURL(int render_view_id, const std::string& url_str);
   void OnCheckNotificationPermission(const GURL& source_origin,
                                      int* permission_level);
 
-  void OnGetCPUUsage(int* cpu_usage);
-
   void OnGetAudioHardwareConfig(media::AudioParameters* input_params,
                                 media::AudioParameters* output_params);
 
@@ -212,8 +228,23 @@ class RenderMessageFilter : public BrowserMessageFilter {
   // in the renderer on POSIX due to the sandbox.
   void OnAllocateSharedMemory(uint32 buffer_size,
                               base::SharedMemoryHandle* handle);
+  void AllocateSharedBitmapOnFileThread(uint32 buffer_size,
+                                        const cc::SharedBitmapId& id,
+                                        IPC::Message* reply_msg);
+  void OnAllocateSharedBitmap(uint32 buffer_size,
+                              const cc::SharedBitmapId& id,
+                              IPC::Message* reply_msg);
+  void OnAllocatedSharedBitmap(size_t buffer_size,
+                               const base::SharedMemoryHandle& handle,
+                               const cc::SharedBitmapId& id);
+  void OnDeletedSharedBitmap(const cc::SharedBitmapId& id);
   void OnResolveProxy(const GURL& url, IPC::Message* reply_msg);
 
+  // Browser side discardable shared memory allocation.
+  void OnAllocateLockedDiscardableSharedMemory(
+      uint32 size,
+      base::SharedMemoryHandle* handle);
+
   // Browser side transport DIB allocation
   void OnAllocTransportDIB(uint32 size,
                            bool cache_in_browser,
@@ -249,7 +280,6 @@ class RenderMessageFilter : public BrowserMessageFilter {
   void OnCompletedOpenChannelToNpapiPlugin(
       OpenChannelToNpapiPluginCallback* client);
 
-  void OnUpdateIsDelayed(const IPC::Message& msg);
   void OnAre3DAPIsBlocked(int render_view_id,
                           const GURL& top_origin_url,
                           ThreeDAPIType requester,
@@ -264,10 +294,18 @@ class RenderMessageFilter : public BrowserMessageFilter {
                             uint32_t data_size);
 #endif
 
+  void OnAddNavigationTransitionData(
+      FrameHostMsg_AddNavigationTransitionData_Params params);
+
   void OnAllocateGpuMemoryBuffer(uint32 width,
                                  uint32 height,
-                                 uint32 internalformat,
-                                 gfx::GpuMemoryBufferHandle* handle);
+                                 gfx::GpuMemoryBuffer::Format format,
+                                 gfx::GpuMemoryBuffer::Usage usage,
+                                 IPC::Message* reply);
+  void GpuMemoryBufferAllocated(IPC::Message* reply,
+                                const gfx::GpuMemoryBufferHandle& handle);
+  void OnDeletedGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
+                                uint32 sync_point);
 
   // Cached resource request dispatcher host and plugin service, guaranteed to
   // be non-null if Init succeeds. We do not own the objects, they are managed
@@ -295,24 +333,11 @@ class RenderMessageFilter : public BrowserMessageFilter {
 
   int render_process_id_;
 
-  bool is_guest_;
-
   std::set<OpenChannelToNpapiPluginCallback*> plugin_host_clients_;
 
-  // Records the last time we sampled CPU usage of the renderer process.
-  base::TimeTicks cpu_usage_sample_time_;
-  // Records the last sampled CPU usage in percents.
-  int cpu_usage_;
-  // Used for sampling CPU usage of the renderer process.
-  scoped_ptr<base::ProcessMetrics> process_metrics_;
-
   media::AudioManager* audio_manager_;
   MediaInternals* media_internals_;
 
-#if defined(OS_MACOSX)
-  base::ScopedCFTypeRef<CFTypeRef> last_io_surface_;
-#endif
-
   DISALLOW_COPY_AND_ASSIGN(RenderMessageFilter);
 };