diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-15 19:20:41 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-15 19:20:41 +0000 |
commit | 2dcf702dacaaf1c46e29101da213c26f0465732a (patch) | |
tree | 026d73ae3053a78fec1a0f01b06bb1c89f6cc50a /content | |
parent | 4c76d7cc78ca3eef79535a3c2a4d934f436c6797 (diff) | |
download | chromium_src-2dcf702dacaaf1c46e29101da213c26f0465732a.zip chromium_src-2dcf702dacaaf1c46e29101da213c26f0465732a.tar.gz chromium_src-2dcf702dacaaf1c46e29101da213c26f0465732a.tar.bz2 |
Inverted dependency between code in content/common/gpu and the GpuWatchdogThread class.This completes the split between code in content/gpu, which only ever runs in the GPU process and code in content/common/gpu, which can run in any process, though in practice only the GPU process or the browser process.I updated the DEPS file in content/common to enforce the dependency and prevent code that could run in either process depend on code that should only run in the GPU process.TEST=tryBUG=none
TEST=try
BUG=none
Review URL: http://codereview.chromium.org/6840041
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81784 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/common/DEPS | 3 | ||||
-rw-r--r-- | content/common/gpu/gpu_channel.cc | 8 | ||||
-rw-r--r-- | content/common/gpu/gpu_channel.h | 6 | ||||
-rw-r--r-- | content/common/gpu/gpu_channel_manager.cc | 7 | ||||
-rw-r--r-- | content/common/gpu/gpu_channel_manager.h | 6 | ||||
-rw-r--r-- | content/common/gpu/gpu_command_buffer_stub.cc | 12 | ||||
-rw-r--r-- | content/common/gpu/gpu_command_buffer_stub.h | 6 | ||||
-rw-r--r-- | content/common/gpu/gpu_watchdog.h | 24 | ||||
-rw-r--r-- | content/content_common.gypi | 1 | ||||
-rw-r--r-- | content/gpu/gpu_watchdog_thread.h | 6 |
10 files changed, 53 insertions, 26 deletions
diff --git a/content/common/DEPS b/content/common/DEPS index fd53eb5..b9894f8 100644 --- a/content/common/DEPS +++ b/content/common/DEPS @@ -1,6 +1,3 @@ include_rules = [
- # Don't add any more dependencies on this directory. Refactoring out the
- # remaining dependency on gpu_watchdog_thread.h is underway.
- "+content/gpu",
]
diff --git a/content/common/gpu/gpu_channel.cc b/content/common/gpu/gpu_channel.cc index 305ed34..21b6d06 100644 --- a/content/common/gpu/gpu_channel.cc +++ b/content/common/gpu/gpu_channel.cc @@ -24,13 +24,13 @@ #endif GpuChannel::GpuChannel(GpuChannelManager* gpu_channel_manager, - GpuWatchdogThread* gpu_watchdog_thread, + GpuWatchdog* watchdog, int renderer_id) : gpu_channel_manager_(gpu_channel_manager), renderer_id_(renderer_id), renderer_process_(base::kNullProcessHandle), renderer_pid_(base::kNullProcessId), - watchdog_thread_(gpu_watchdog_thread) { + watchdog_(watchdog) { DCHECK(gpu_channel_manager); DCHECK(renderer_id); const CommandLine* command_line = CommandLine::ForCurrentProcess(); @@ -117,7 +117,7 @@ void GpuChannel::CreateViewCommandBuffer( this, window, NULL, gfx::Size(), disallowed_extensions_, init_params.allowed_extensions, init_params.attribs, 0, *route_id, renderer_id_, render_view_id, - watchdog_thread_)); + watchdog_)); router_.AddRoute(*route_id, stub.get()); stubs_.AddWithID(stub.release(), *route_id); #endif // ENABLE_GPU @@ -203,7 +203,7 @@ void GpuChannel::OnCreateOffscreenCommandBuffer( init_params.attribs, parent_texture_id, *route_id, - 0, 0, watchdog_thread_)); + 0, 0, watchdog_)); router_.AddRoute(*route_id, stub.get()); stubs_.AddWithID(stub.release(), *route_id); #else diff --git a/content/common/gpu/gpu_channel.h b/content/common/gpu/gpu_channel.h index 1a8a489..012656e 100644 --- a/content/common/gpu/gpu_channel.h +++ b/content/common/gpu/gpu_channel.h @@ -21,8 +21,8 @@ #include "ui/gfx/size.h" class GpuChannelManager; -class GpuWatchdogThread; struct GPUCreateCommandBufferConfig; +class GpuWatchdog; class MessageLoop; class TransportTexture; @@ -38,7 +38,7 @@ class GpuChannel : public IPC::Channel::Listener, public: // Takes ownership of the renderer process handle. GpuChannel(GpuChannelManager* gpu_channel_manager, - GpuWatchdogThread* gpu_watchdog_thread, + GpuWatchdog* watchdog, int renderer_id); virtual ~GpuChannel(); @@ -139,7 +139,7 @@ class GpuChannel : public IPC::Channel::Listener, bool log_messages_; // True if we should log sent and received messages. gpu::gles2::DisallowedExtensions disallowed_extensions_; - GpuWatchdogThread* watchdog_thread_; + GpuWatchdog* watchdog_; DISALLOW_COPY_AND_ASSIGN(GpuChannel); }; diff --git a/content/common/gpu/gpu_channel_manager.cc b/content/common/gpu/gpu_channel_manager.cc index f6d39a9..bb00d90 100644 --- a/content/common/gpu/gpu_channel_manager.cc +++ b/content/common/gpu/gpu_channel_manager.cc @@ -15,20 +15,19 @@ #include "chrome/common/chrome_switches.h" #include "content/common/child_process.h" #include "content/common/gpu_messages.h" -#include "content/gpu/gpu_watchdog_thread.h" #include "ipc/ipc_channel_handle.h" #include "ui/gfx/gl/gl_context.h" #include "ui/gfx/gl/gl_implementation.h" GpuChannelManager::GpuChannelManager(IPC::Message::Sender* browser_channel, - GpuWatchdogThread* gpu_watchdog_thread, + GpuWatchdog* watchdog, MessageLoop* io_message_loop, base::WaitableEvent* shutdown_event) : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), io_message_loop_(io_message_loop), shutdown_event_(shutdown_event), browser_channel_(browser_channel), - watchdog_thread_(gpu_watchdog_thread) { + watchdog_(watchdog) { DCHECK(browser_channel); DCHECK(io_message_loop); DCHECK(shutdown_event); @@ -74,7 +73,7 @@ void GpuChannelManager::OnEstablishChannel(int renderer_id) { GpuChannelMap::const_iterator iter = gpu_channels_.find(renderer_id); if (iter == gpu_channels_.end()) - channel = new GpuChannel(this, watchdog_thread_, renderer_id); + channel = new GpuChannel(this, watchdog_, renderer_id); else channel = iter->second; diff --git a/content/common/gpu/gpu_channel_manager.h b/content/common/gpu/gpu_channel_manager.h index d42b6d4..4770075 100644 --- a/content/common/gpu/gpu_channel_manager.h +++ b/content/common/gpu/gpu_channel_manager.h @@ -27,6 +27,8 @@ namespace IPC { struct ChannelHandle; } +class GpuWatchdog; + // A GpuChannelManager is a thread responsible for issuing rendering commands // managing the lifetimes of GPU channels and forwarding IPC requests from the // browser process to them based on the corresponding renderer ID. @@ -41,7 +43,7 @@ class GpuChannelManager : public IPC::Channel::Listener, public IPC::Message::Sender { public: GpuChannelManager(IPC::Message::Sender* browser_channel, - GpuWatchdogThread* gpu_watchdog_thread, + GpuWatchdog* watchdog, MessageLoop* io_message_loop, base::WaitableEvent* shutdown_event); ~GpuChannelManager(); @@ -92,7 +94,7 @@ class GpuChannelManager : public IPC::Channel::Listener, // process. typedef base::hash_map<int, scoped_refptr<GpuChannel> > GpuChannelMap; GpuChannelMap gpu_channels_; - GpuWatchdogThread* watchdog_thread_; + GpuWatchdog* watchdog_; DISALLOW_COPY_AND_ASSIGN(GpuChannelManager); }; diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc index 3bf1f9ab..94c8c6f 100644 --- a/content/common/gpu/gpu_command_buffer_stub.cc +++ b/content/common/gpu/gpu_command_buffer_stub.cc @@ -12,7 +12,7 @@ #include "content/common/gpu/gpu_channel.h" #include "content/common/gpu/gpu_channel_manager.h" #include "content/common/gpu/gpu_command_buffer_stub.h" -#include "content/gpu/gpu_watchdog_thread.h" +#include "content/common/gpu/gpu_watchdog.h" #include "gpu/command_buffer/common/constants.h" #include "gpu/common/gpu_trace_event.h" #include "ui/gfx/gl/gl_context.h" @@ -39,7 +39,7 @@ GpuCommandBufferStub::GpuCommandBufferStub( int32 route_id, int32 renderer_id, int32 render_view_id, - GpuWatchdogThread* gpu_watchdog_thread) + GpuWatchdog* watchdog) : channel_(channel), handle_(handle), parent_( @@ -55,7 +55,7 @@ GpuCommandBufferStub::GpuCommandBufferStub( #endif // defined(OS_WIN) renderer_id_(renderer_id), render_view_id_(render_view_id), - watchdog_thread_(gpu_watchdog_thread) { + watchdog_(watchdog) { } #if defined(OS_WIN) @@ -258,7 +258,7 @@ void GpuCommandBufferStub::OnInitialize( &gpu::GpuScheduler::ProcessCommands)); scheduler_->SetSwapBuffersCallback( NewCallback(this, &GpuCommandBufferStub::OnSwapBuffers)); - if (watchdog_thread_) + if (watchdog_) scheduler_->SetCommandProcessedCallback( NewCallback(this, &GpuCommandBufferStub::OnCommandProcessed)); @@ -288,8 +288,8 @@ void GpuCommandBufferStub::OnInitialize( } void GpuCommandBufferStub::OnCommandProcessed() { - if (watchdog_thread_) - watchdog_thread_->CheckArmed(); + if (watchdog_) + watchdog_->CheckArmed(); } void GpuCommandBufferStub::OnGetState(gpu::CommandBuffer::State* state) { diff --git a/content/common/gpu/gpu_command_buffer_stub.h b/content/common/gpu/gpu_command_buffer_stub.h index 7b7a9ba..6e6a039 100644 --- a/content/common/gpu/gpu_command_buffer_stub.h +++ b/content/common/gpu/gpu_command_buffer_stub.h @@ -21,7 +21,7 @@ #include "ui/gfx/size.h" class GpuChannel; -class GpuWatchdogThread; +class GpuWatchdog; class GpuCommandBufferStub : public IPC::Channel::Listener, @@ -40,7 +40,7 @@ class GpuCommandBufferStub int32 route_id, int32 renderer_id, int32 render_view_id, - GpuWatchdogThread* gpu_watchdog_thread); + GpuWatchdog* watchdog); virtual ~GpuCommandBufferStub(); @@ -132,7 +132,7 @@ class GpuCommandBufferStub scoped_ptr<gpu::CommandBufferService> command_buffer_; scoped_ptr<gpu::GpuScheduler> scheduler_; - GpuWatchdogThread* watchdog_thread_; + GpuWatchdog* watchdog_; DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferStub); }; diff --git a/content/common/gpu/gpu_watchdog.h b/content/common/gpu/gpu_watchdog.h new file mode 100644 index 0000000..4d20b0d --- /dev/null +++ b/content/common/gpu/gpu_watchdog.h @@ -0,0 +1,24 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_COMMON_GPU_GPU_WATCHDOG_H_ +#define CONTENT_COMMON_GPU_GPU_WATCHDOG_H_ + +// Interface for objects that monitor the a GPUProcessor's progress. The +// GPUProcessor will regularly invoke CheckArmed. +class GpuWatchdog { + public: + GpuWatchdog() { + } + + virtual ~GpuWatchdog() { + }; + + virtual void CheckArmed() = 0; + + private: + DISALLOW_COPY_AND_ASSIGN(GpuWatchdog); +}; + +#endif // CONTENT_COMMON_GPU_GPU_WATCHDOG_H_ diff --git a/content/content_common.gypi b/content/content_common.gypi index de8e378..00764b3 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -107,6 +107,7 @@ 'common/gpu/gpu_video_decoder.h', 'common/gpu/gpu_video_service.cc', 'common/gpu/gpu_video_service.h', + 'common/gpu/gpu_watchdog.h', 'common/gpu/media/gpu_video_device.h', 'common/gpu/media/fake_gl_video_decode_engine.cc', 'common/gpu/media/fake_gl_video_decode_engine.h', diff --git a/content/gpu/gpu_watchdog_thread.h b/content/gpu/gpu_watchdog_thread.h index 68aeea7..df4a471 100644 --- a/content/gpu/gpu_watchdog_thread.h +++ b/content/gpu/gpu_watchdog_thread.h @@ -11,10 +11,12 @@ #include "base/task.h" #include "base/threading/thread.h" #include "base/time.h" +#include "content/common/gpu/gpu_watchdog.h" // A thread that intermitently sends tasks to a group of watched message loops // and deliberately crashes if one of them does not respond after a timeout. class GpuWatchdogThread : public base::Thread, + public GpuWatchdog, public base::RefCountedThreadSafe<GpuWatchdogThread> { public: explicit GpuWatchdogThread(int timeout); @@ -23,7 +25,9 @@ class GpuWatchdogThread : public base::Thread, // Accessible on watched thread but only modified by watchdog thread. bool armed() const { return armed_; } void PostAcknowledge(); - void CheckArmed(); + + // Implement GpuWatchdog. + virtual void CheckArmed(); protected: virtual void Init(); |