summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gpu_process_host_ui_shim.h
diff options
context:
space:
mode:
authorKristian Monsen <kristianm@google.com>2011-05-31 20:30:28 +0100
committerKristian Monsen <kristianm@google.com>2011-06-14 20:31:41 -0700
commit72a454cd3513ac24fbdd0e0cb9ad70b86a99b801 (patch)
tree382278a54ce7a744d62fa510a9a80688cc12434b /chrome/browser/gpu_process_host_ui_shim.h
parentc4becdd46e31d261b930e4b5a539cbc1d45c23a6 (diff)
downloadexternal_chromium-72a454cd3513ac24fbdd0e0cb9ad70b86a99b801.zip
external_chromium-72a454cd3513ac24fbdd0e0cb9ad70b86a99b801.tar.gz
external_chromium-72a454cd3513ac24fbdd0e0cb9ad70b86a99b801.tar.bz2
Merge Chromium.org at r11.0.672.0: Initial merge by git.
Change-Id: I8b4aaf611a2a405fe3fe10e8a94ea7658645c192
Diffstat (limited to 'chrome/browser/gpu_process_host_ui_shim.h')
-rw-r--r--chrome/browser/gpu_process_host_ui_shim.h106
1 files changed, 103 insertions, 3 deletions
diff --git a/chrome/browser/gpu_process_host_ui_shim.h b/chrome/browser/gpu_process_host_ui_shim.h
index 17bf970..396c2fc 100644
--- a/chrome/browser/gpu_process_host_ui_shim.h
+++ b/chrome/browser/gpu_process_host_ui_shim.h
@@ -11,14 +11,34 @@
// portion of this class, the GpuProcessHost, is responsible for
// shuttling messages between the browser and GPU processes.
+#include <queue>
+
#include "base/callback.h"
+#include "base/linked_ptr.h"
#include "base/scoped_ptr.h"
#include "base/singleton.h"
+#include "base/values.h"
#include "base/threading/non_thread_safe.h"
+#include "chrome/common/gpu_feature_flags.h"
#include "chrome/common/gpu_info.h"
#include "chrome/common/message_router.h"
#include "ipc/ipc_channel.h"
-#include "gfx/native_widget_types.h"
+#include "ui/gfx/native_widget_types.h"
+
+namespace gfx {
+class Size;
+}
+
+class GpuBlacklist;
+struct GPUCreateCommandBufferConfig;
+class GPUInfo;
+struct GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params;
+struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params;
+
+namespace IPC {
+struct ChannelHandle;
+class Message;
+}
class GpuProcessHostUIShim : public IPC::Channel::Sender,
public IPC::Channel::Listener,
@@ -32,19 +52,49 @@ class GpuProcessHostUIShim : public IPC::Channel::Sender,
// IPC::Channel::Sender implementation.
virtual bool Send(IPC::Message* msg);
+ // Sends outstanding replies. This is only called
+ // in error situations like the GPU process crashing -- but is necessary
+ // to prevent the blocked clients from hanging.
+ void SendOutstandingReplies();
+
// IPC::Channel::Listener implementation.
// The GpuProcessHost causes this to be called on the UI thread to
// dispatch the incoming messages from the GPU process, which are
// actually received on the IO thread.
virtual bool OnMessageReceived(const IPC::Message& message);
+ typedef Callback2<const IPC::ChannelHandle&, const GPUInfo&>::Type
+ EstablishChannelCallback;
+
+ // Tells the GPU process to create a new channel for communication with a
+ // renderer. Once the GPU process responds asynchronously with the IPC handle
+ // and GPUInfo, we call the callback.
+ void EstablishGpuChannel(
+ int renderer_id, EstablishChannelCallback* callback);
+
+ typedef Callback0::Type SynchronizeCallback;
+
+ // Sends a reply message later when the next GpuHostMsg_SynchronizeReply comes
+ // in.
+ void Synchronize(SynchronizeCallback* callback);
+
+ typedef Callback1<int32>::Type CreateCommandBufferCallback;
+
+ // Tells the GPU process to create a new command buffer that draws into the
+ // window associated with the given renderer.
+ void CreateViewCommandBuffer(
+ int32 render_view_id,
+ int32 renderer_id,
+ const GPUCreateCommandBufferConfig& init_params,
+ CreateCommandBufferCallback* callback);
+
// See documentation on MessageRouter for AddRoute and RemoveRoute
void AddRoute(int32 routing_id, IPC::Channel::Listener* listener);
void RemoveRoute(int32 routing_id);
// Sends a message to the browser process to collect the information from the
// graphics card.
- void CollectGraphicsInfoAsynchronously();
+ void CollectGraphicsInfoAsynchronously(GPUInfo::Level level);
// Tells the GPU process to crash. Useful for testing.
void SendAboutGpuCrash();
@@ -63,26 +113,76 @@ class GpuProcessHostUIShim : public IPC::Channel::Sender,
gpu_info_collected_callback_.reset(callback);
}
+ ListValue* logMessages() const { return log_messages_.DeepCopy(); }
+
+ // Can be called directly from the UI thread to log a message.
+ void AddCustomLogMessage(int level, const std::string& header,
+ const std::string& message);
+
+ bool LoadGpuBlacklist();
+
private:
friend struct DefaultSingletonTraits<GpuProcessHostUIShim>;
GpuProcessHostUIShim();
virtual ~GpuProcessHostUIShim();
+ // TODO(apatrick): Following the pattern from GpuProcessHost. Talk to zmo
+ // and see if we can find a better mechanism.
+ bool EnsureInitialized();
+ bool Init();
+
// Message handlers.
+ bool OnControlMessageReceived(const IPC::Message& message);
+
+ void OnChannelEstablished(const IPC::ChannelHandle& channel_handle,
+ const GPUInfo& gpu_info);
+ void OnCommandBufferCreated(const int32 route_id);
+ void OnDestroyCommandBuffer(gfx::PluginWindowHandle window,
+ int32 renderer_id, int32 render_view_id);
void OnGraphicsInfoCollected(const GPUInfo& gpu_info);
+ void OnLogMessage(int level, const std::string& header,
+ const std::string& message);
+ void OnSynchronizeReply();
+#if defined(OS_LINUX)
+ void OnResizeXID(unsigned long xid, gfx::Size size, IPC::Message* reply_msg);
+#elif defined(OS_MACOSX)
+ void OnAcceleratedSurfaceSetIOSurface(
+ const GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params& params);
+ void OnAcceleratedSurfaceBuffersSwapped(
+ const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params);
+#elif defined(OS_WIN)
void OnScheduleComposite(int32 renderer_id, int32 render_view_id);
- bool OnControlMessageReceived(const IPC::Message& message);
+#endif
int last_routing_id_;
GPUInfo gpu_info_;
+ ListValue log_messages_;
MessageRouter router_;
// Used only in testing. If set, the callback is invoked when the GPU info
// has been collected.
scoped_ptr<Callback0::Type> gpu_info_collected_callback_;
+
+ // These are the channel requests that we have already sent to
+ // the GPU process, but haven't heard back about yet.
+ std::queue<linked_ptr<EstablishChannelCallback> > channel_requests_;
+
+ // The pending synchronization requests we need to reply to.
+ std::queue<linked_ptr<SynchronizeCallback> > synchronize_requests_;
+
+ // The pending create command buffer requests we need to reply to.
+ std::queue<linked_ptr<CreateCommandBufferCallback> >
+ create_command_buffer_requests_;
+
+ bool initialized_;
+ bool initialized_successfully_;
+
+ bool gpu_feature_flags_set_;
+ scoped_ptr<GpuBlacklist> gpu_blacklist_;
+ GpuFeatureFlags gpu_feature_flags_;
};
#endif // CHROME_BROWSER_GPU_PROCESS_HOST_UI_SHIM_H_