| 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" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 // See documentation on MessageRouter for AddRoute and RemoveRoute | 47 // See documentation on MessageRouter for AddRoute and RemoveRoute |
| 48 void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); | 48 void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); |
| 49 void RemoveRoute(int32 routing_id); | 49 void RemoveRoute(int32 routing_id); |
| 50 | 50 |
| 51 // 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 |
| 52 // renderer. Will asynchronously send message to object with given routing id | 52 // renderer. Will asynchronously send message to object with given routing id |
| 53 // on completion. | 53 // on completion. |
| 54 void EstablishGpuChannel(int renderer_id); | 54 void EstablishGpuChannel(int renderer_id); |
| 55 | 55 |
| 56 // Sends a reply message later when the next GpuHostMsg_SynchronizeReply comes |
| 57 // in. |
| 58 void Synchronize(int renderer_id, IPC::Message* reply); |
| 59 |
| 56 private: | 60 private: |
| 57 friend struct DefaultSingletonTraits<GpuProcessHost>; | 61 friend struct DefaultSingletonTraits<GpuProcessHost>; |
| 58 | 62 |
| 59 // Used to queue pending channel requests. | 63 // Used to queue pending channel requests. |
| 60 struct ChannelRequest { | 64 struct ChannelRequest { |
| 61 explicit ChannelRequest(int renderer_id) : renderer_id(renderer_id) {} | 65 explicit ChannelRequest(int renderer_id) : renderer_id(renderer_id) {} |
| 62 // Used to identify the renderer. The ID is used instead of a pointer to | 66 // Used to identify the renderer. The ID is used instead of a pointer to |
| 63 // the RenderProcessHost in case it is destroyed while the request is | 67 // the RenderProcessHost in case it is destroyed while the request is |
| 64 // pending. | 68 // pending. |
| 65 // TODO(apatrick): investigate whether these IDs are used for future | 69 // TODO(apatrick): investigate whether these IDs are used for future |
| 66 // render processes. | 70 // render processes. |
| 67 int renderer_id; | 71 int renderer_id; |
| 68 }; | 72 }; |
| 69 | 73 |
| 70 GpuProcessHost(); | 74 GpuProcessHost(); |
| 71 virtual ~GpuProcessHost(); | 75 virtual ~GpuProcessHost(); |
| 72 | 76 |
| 73 void OnControlMessageReceived(const IPC::Message& message); | 77 void OnControlMessageReceived(const IPC::Message& message); |
| 74 | 78 |
| 75 // Message handlers. | 79 // Message handlers. |
| 76 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); | 80 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); |
| 81 void OnSynchronizeReply(int renderer_id); |
| 77 | 82 |
| 78 void ReplyToRenderer(int renderer_id, | 83 void ReplyToRenderer(int renderer_id, |
| 79 const IPC::ChannelHandle& channel); | 84 const IPC::ChannelHandle& channel); |
| 80 | 85 |
| 81 // These are the channel requests that we have already sent to | 86 // These are the channel requests that we have already sent to |
| 82 // the GPU process, but haven't heard back about yet. | 87 // the GPU process, but haven't heard back about yet. |
| 83 std::queue<ChannelRequest> sent_requests_; | 88 std::queue<ChannelRequest> sent_requests_; |
| 84 | 89 |
| 85 // Copies applicable command line switches from the given |browser_cmd| line | 90 // Copies applicable command line switches from the given |browser_cmd| line |
| 86 // flags to the output |gpu_cmd| line flags. Not all switches will be | 91 // flags to the output |gpu_cmd| line flags. Not all switches will be |
| (...skipping 10 matching lines...) Expand all Loading... |
| 97 int last_routing_id_; | 102 int last_routing_id_; |
| 98 | 103 |
| 99 MessageRouter router_; | 104 MessageRouter router_; |
| 100 | 105 |
| 101 // Messages we queue while waiting for the process handle. We queue them here | 106 // Messages we queue while waiting for the process handle. We queue them here |
| 102 // instead of in the channel so that we ensure they're sent after init related | 107 // instead of in the channel so that we ensure they're sent after init related |
| 103 // messages that are sent once the process handle is available. This is | 108 // messages that are sent once the process handle is available. This is |
| 104 // because the queued messages may have dependencies on the init messages. | 109 // because the queued messages may have dependencies on the init messages. |
| 105 std::queue<IPC::Message*> queued_messages_; | 110 std::queue<IPC::Message*> queued_messages_; |
| 106 | 111 |
| 112 // The pending synchronization requests we need to reply to. |
| 113 std::queue<IPC::Message*> queued_synchronization_replies_; |
| 114 |
| 107 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); | 115 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); |
| 108 }; | 116 }; |
| 109 | 117 |
| 110 #endif // CHROME_BROWSER_GPU_PROCESS_HOST_H_ | 118 #endif // CHROME_BROWSER_GPU_PROCESS_HOST_H_ |
| OLD | NEW |