Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(630)

Side by Side Diff: content/common/gpu/gpu_channel_manager.h

Issue 9289052: Adding GpuMemoryManager to track GpuCommandBufferStub visibility and last_used_time and dictate mem… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Minor updates, working on tests Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_ 5 #ifndef CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_
6 #define CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_ 6 #define CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/hash_tables.h" 9 #include "base/hash_tables.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/message_loop_proxy.h" 12 #include "base/message_loop_proxy.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "content/common/gpu/gpu_memory_manager.h"
14 #include "ipc/ipc_channel.h" 15 #include "ipc/ipc_channel.h"
15 #include "ipc/ipc_message.h" 16 #include "ipc/ipc_message.h"
16 #include "ui/gfx/native_widget_types.h" 17 #include "ui/gfx/native_widget_types.h"
17 18
18 namespace base { 19 namespace base {
19 class WaitableEvent; 20 class WaitableEvent;
20 } 21 }
21 22
22 namespace IPC { 23 namespace IPC {
23 struct ChannelHandle; 24 struct ChannelHandle;
24 } 25 }
25 26
26 class ChildThread; 27 class ChildThread;
27 class GpuChannel; 28 class GpuChannel;
28 class GpuWatchdog; 29 class GpuWatchdog;
29 struct GPUCreateCommandBufferConfig; 30 struct GPUCreateCommandBufferConfig;
30 31
31 // A GpuChannelManager is a thread responsible for issuing rendering commands 32 // A GpuChannelManager is a thread responsible for issuing rendering commands
32 // managing the lifetimes of GPU channels and forwarding IPC requests from the 33 // managing the lifetimes of GPU channels and forwarding IPC requests from the
33 // browser process to them based on the corresponding renderer ID. 34 // browser process to them based on the corresponding renderer ID.
34 // 35 //
35 // A GpuChannelManager can also be hosted in the browser process in single 36 // A GpuChannelManager can also be hosted in the browser process in single
36 // process or in-process GPU modes. In this case there is no corresponding 37 // process or in-process GPU modes. In this case there is no corresponding
37 // GpuChildThread and this is the reason the GpuChildThread is referenced via 38 // GpuChildThread and this is the reason the GpuChildThread is referenced via
38 // a pointer to IPC::Message::Sender, which can be implemented by other hosts 39 // a pointer to IPC::Message::Sender, which can be implemented by other hosts
39 // to send IPC messages to the browser process IO thread on the 40 // to send IPC messages to the browser process IO thread on the
40 // GpuChannelManager's behalf. 41 // GpuChannelManager's behalf.
41 class GpuChannelManager : public IPC::Channel::Listener, 42 class GpuChannelManager : public IPC::Channel::Listener,
42 public IPC::Message::Sender { 43 public IPC::Message::Sender,
44 public GpuMemoryManagerClient {
43 public: 45 public:
44 GpuChannelManager(ChildThread* gpu_child_thread, 46 GpuChannelManager(ChildThread* gpu_child_thread,
45 GpuWatchdog* watchdog, 47 GpuWatchdog* watchdog,
46 base::MessageLoopProxy* io_message_loop, 48 base::MessageLoopProxy* io_message_loop,
47 base::WaitableEvent* shutdown_event); 49 base::WaitableEvent* shutdown_event);
48 virtual ~GpuChannelManager(); 50 virtual ~GpuChannelManager();
49 51
50 // Remove the channel for a particular renderer. 52 // Remove the channel for a particular renderer.
51 void RemoveChannel(int client_id); 53 void RemoveChannel(int client_id);
52 54
53 // Listener overrides. 55 // Listener overrides.
54 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 56 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
55 57
56 // Sender overrides. 58 // Sender overrides.
57 virtual bool Send(IPC::Message* msg) OVERRIDE; 59 virtual bool Send(IPC::Message* msg) OVERRIDE;
58 60
61 // GpuMemoryManagerClient overrides.
62 virtual void AppendAllCommandBufferStubs(
63 std::vector<GpuMemoryManageableCommandBufferStub*>& stubs_with_surface,
64 std::vector<GpuMemoryManageableCommandBufferStub*>& stubs_without_surface)
65 OVERRIDE;
66
59 void LoseAllContexts(); 67 void LoseAllContexts();
60 68
61 base::WeakPtrFactory<GpuChannelManager> weak_factory_; 69 base::WeakPtrFactory<GpuChannelManager> weak_factory_;
62 70
63 int GenerateRouteID(); 71 int GenerateRouteID();
64 void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); 72 void AddRoute(int32 routing_id, IPC::Channel::Listener* listener);
65 void RemoveRoute(int32 routing_id); 73 void RemoveRoute(int32 routing_id);
66 74
75 GpuMemoryManager* gpu_memory_manager() { return &gpu_memory_manager_; }
76
67 GpuChannel* LookupChannel(int32 client_id); 77 GpuChannel* LookupChannel(int32 client_id);
68 78
69 private: 79 private:
70 // Message handlers. 80 // Message handlers.
71 void OnEstablishChannel(int client_id, int share_client_id); 81 void OnEstablishChannel(int client_id, int share_client_id);
72 void OnCloseChannel(const IPC::ChannelHandle& channel_handle); 82 void OnCloseChannel(const IPC::ChannelHandle& channel_handle);
73 void OnVisibilityChanged( 83 void OnVisibilityChanged(
74 int32 render_view_id, int32 client_id, bool visible); 84 int32 render_view_id, int32 client_id, bool visible);
75 void OnCreateViewCommandBuffer( 85 void OnCreateViewCommandBuffer(
76 gfx::PluginWindowHandle window, 86 gfx::PluginWindowHandle window,
77 int32 render_view_id, 87 int32 render_view_id,
78 int32 client_id, 88 int32 client_id,
79 const GPUCreateCommandBufferConfig& init_params); 89 const GPUCreateCommandBufferConfig& init_params);
80 90
81 void OnLoseAllContexts(); 91 void OnLoseAllContexts();
82 92
83 scoped_refptr<base::MessageLoopProxy> io_message_loop_; 93 scoped_refptr<base::MessageLoopProxy> io_message_loop_;
84 base::WaitableEvent* shutdown_event_; 94 base::WaitableEvent* shutdown_event_;
85 95
86 // Used to send and receive IPC messages from the browser process. 96 // Used to send and receive IPC messages from the browser process.
87 ChildThread* gpu_child_thread_; 97 ChildThread* gpu_child_thread_;
88 98
89 // These objects manage channels to individual renderer processes there is 99 // These objects manage channels to individual renderer processes there is
90 // one channel for each renderer process that has connected to this GPU 100 // one channel for each renderer process that has connected to this GPU
91 // process. 101 // process.
92 typedef base::hash_map<int, scoped_refptr<GpuChannel> > GpuChannelMap; 102 typedef base::hash_map<int, scoped_refptr<GpuChannel> > GpuChannelMap;
93 GpuChannelMap gpu_channels_; 103 GpuChannelMap gpu_channels_;
104 GpuMemoryManager gpu_memory_manager_;
94 GpuWatchdog* watchdog_; 105 GpuWatchdog* watchdog_;
95 106
96 DISALLOW_COPY_AND_ASSIGN(GpuChannelManager); 107 DISALLOW_COPY_AND_ASSIGN(GpuChannelManager);
97 }; 108 };
98 109
99 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_ 110 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698