| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_GPU_PROCESS_HOST_H_ | 5 #ifndef CHROME_BROWSER_GPU_PROCESS_HOST_H_ |
| 6 #define CHROME_BROWSER_GPU_PROCESS_HOST_H_ | 6 #define CHROME_BROWSER_GPU_PROCESS_HOST_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
| 12 #include "base/singleton.h" | 12 #include "base/singleton.h" |
| 13 #include "chrome/browser/child_process_launcher.h" | 13 #include "chrome/browser/child_process_launcher.h" |
| 14 #include "chrome/common/gpu_native_window_handle.h" | 14 #include "chrome/common/gpu_native_window_handle.h" |
| 15 #include "chrome/common/message_router.h" | 15 #include "chrome/common/message_router.h" |
| 16 #include "gfx/native_widget_types.h" |
| 16 #include "ipc/ipc_channel_handle.h" | 17 #include "ipc/ipc_channel_handle.h" |
| 17 #include "ipc/ipc_channel_proxy.h" | 18 #include "ipc/ipc_channel_proxy.h" |
| 18 | 19 |
| 19 class ChildProcessLauncher; | 20 class ChildProcessLauncher; |
| 20 class CommandBufferProxy; | 21 class CommandBufferProxy; |
| 21 | 22 |
| 22 class GpuProcessHost : public IPC::Channel::Sender, | 23 class GpuProcessHost : public IPC::Channel::Sender, |
| 23 public IPC::Channel::Listener, | 24 public IPC::Channel::Listener, |
| 24 public ChildProcessLauncher::Client { | 25 public ChildProcessLauncher::Client { |
| 25 public: | 26 public: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 43 // ChildProcessLauncher::Client implementation. | 44 // ChildProcessLauncher::Client implementation. |
| 44 virtual void OnProcessLaunched(); | 45 virtual void OnProcessLaunched(); |
| 45 | 46 |
| 46 // See documentation on MessageRouter for AddRoute and RemoveRoute | 47 // See documentation on MessageRouter for AddRoute and RemoveRoute |
| 47 void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); | 48 void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); |
| 48 void RemoveRoute(int32 routing_id); | 49 void RemoveRoute(int32 routing_id); |
| 49 | 50 |
| 50 // Tells the GPU process to create a new channel for communication with a | 51 // Tells the GPU process to create a new channel for communication with a |
| 51 // renderer. Will asynchronously send message to object with given routing id | 52 // renderer. Will asynchronously send message to object with given routing id |
| 52 // on completion. | 53 // on completion. |
| 53 void EstablishGpuChannel(int renderer_id, int routing_id); | 54 void EstablishGpuChannel(int renderer_id); |
| 54 | 55 |
| 55 private: | 56 private: |
| 56 friend struct DefaultSingletonTraits<GpuProcessHost>; | 57 friend struct DefaultSingletonTraits<GpuProcessHost>; |
| 57 | 58 |
| 58 // Used to queue pending channel requests. | 59 // Used to queue pending channel requests. |
| 59 struct ChannelRequest { | 60 struct ChannelRequest { |
| 60 ChannelRequest(int renderer_id, | 61 explicit ChannelRequest(int renderer_id) : renderer_id(renderer_id) {} |
| 61 int routing_id) : | |
| 62 renderer_id(renderer_id), | |
| 63 routing_id(routing_id) {} | |
| 64 // Used to identify the renderer. The ID is used instead of a pointer to | 62 // Used to identify the renderer. The ID is used instead of a pointer to |
| 65 // the RenderProcessHost in case it is destroyed while the request is | 63 // the RenderProcessHost in case it is destroyed while the request is |
| 66 // pending. | 64 // pending. |
| 67 // TODO(apatrick): investigate whether these IDs are used for future | 65 // TODO(apatrick): investigate whether these IDs are used for future |
| 68 // render processes. | 66 // render processes. |
| 69 int renderer_id; | 67 int renderer_id; |
| 70 | |
| 71 // Routing ID of object to receive reply message. | |
| 72 int routing_id; | |
| 73 }; | 68 }; |
| 74 | 69 |
| 75 GpuProcessHost(); | 70 GpuProcessHost(); |
| 76 virtual ~GpuProcessHost(); | 71 virtual ~GpuProcessHost(); |
| 77 | 72 |
| 78 void OnControlMessageReceived(const IPC::Message& message); | 73 void OnControlMessageReceived(const IPC::Message& message); |
| 79 | 74 |
| 80 // Message handlers. | 75 // Message handlers. |
| 81 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); | 76 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); |
| 82 | 77 |
| 83 void ReplyToRenderer(int renderer_id, | 78 void ReplyToRenderer(int renderer_id, |
| 84 int routing_id, | |
| 85 const IPC::ChannelHandle& channel); | 79 const IPC::ChannelHandle& channel); |
| 86 | 80 |
| 87 // These are the channel requests that we have already sent to | 81 // These are the channel requests that we have already sent to |
| 88 // the GPU process, but haven't heard back about yet. | 82 // the GPU process, but haven't heard back about yet. |
| 89 std::queue<ChannelRequest> sent_requests_; | 83 std::queue<ChannelRequest> sent_requests_; |
| 90 | 84 |
| 91 // Copies applicable command line switches from the given |browser_cmd| line | 85 // Copies applicable command line switches from the given |browser_cmd| line |
| 92 // flags to the output |gpu_cmd| line flags. Not all switches will be | 86 // flags to the output |gpu_cmd| line flags. Not all switches will be |
| 93 // copied over. | 87 // copied over. |
| 94 void PropagateBrowserCommandLineToGpu(const CommandLine& browser_cmd, | 88 void PropagateBrowserCommandLineToGpu(const CommandLine& browser_cmd, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 107 // Messages we queue while waiting for the process handle. We queue them here | 101 // Messages we queue while waiting for the process handle. We queue them here |
| 108 // instead of in the channel so that we ensure they're sent after init related | 102 // instead of in the channel so that we ensure they're sent after init related |
| 109 // messages that are sent once the process handle is available. This is | 103 // messages that are sent once the process handle is available. This is |
| 110 // because the queued messages may have dependencies on the init messages. | 104 // because the queued messages may have dependencies on the init messages. |
| 111 std::queue<IPC::Message*> queued_messages_; | 105 std::queue<IPC::Message*> queued_messages_; |
| 112 | 106 |
| 113 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); | 107 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); |
| 114 }; | 108 }; |
| 115 | 109 |
| 116 #endif // CHROME_BROWSER_GPU_PROCESS_HOST_H_ | 110 #endif // CHROME_BROWSER_GPU_PROCESS_HOST_H_ |
| OLD | NEW |