diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-26 19:44:45 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-26 19:44:45 +0000 |
commit | 2f28bf6ce145538ceb7fe86b1f240c0b77a17941 (patch) | |
tree | ffb98e7a61b80301a2ea6f0e50e7fb724b194d13 /chrome/browser | |
parent | c275784353349d34a2785ca36f990e2f2a24a02f (diff) | |
download | chromium_src-2f28bf6ce145538ceb7fe86b1f240c0b77a17941.zip chromium_src-2f28bf6ce145538ceb7fe86b1f240c0b77a17941.tar.gz chromium_src-2f28bf6ce145538ceb7fe86b1f240c0b77a17941.tar.bz2 |
Move GpuProcessHostUIShim and GpuDataManager now that they don't depend on grit (which would have caused a circular dependency in gyp).
Review URL: http://codereview.chromium.org/6903026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83060 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/browser_process_impl.cc | 2 | ||||
-rw-r--r-- | chrome/browser/gpu_data_manager.cc | 214 | ||||
-rw-r--r-- | chrome/browser/gpu_data_manager.h | 108 | ||||
-rw-r--r-- | chrome/browser/gpu_pixel_browsertest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/gpu_process_host_ui_shim.cc | 321 | ||||
-rw-r--r-- | chrome/browser/gpu_process_host_ui_shim.h | 123 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_log.cc | 2 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host_view_mac.mm | 2 | ||||
-rw-r--r-- | chrome/browser/tab_contents/render_view_host_delegate_helper.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/webui/gpu_internals_ui.cc | 2 | ||||
-rw-r--r-- | chrome/browser/web_resource/gpu_blacklist_updater.cc | 2 |
11 files changed, 7 insertions, 773 deletions
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index 5641927..54d848a 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -28,7 +28,6 @@ #include "chrome/browser/extensions/user_script_listener.h" #include "chrome/browser/first_run/upgrade_util.h" #include "chrome/browser/google/google_url_tracker.h" -#include "chrome/browser/gpu_process_host_ui_shim.h" #include "chrome/browser/icon_manager.h" #include "chrome/browser/intranet_redirect_detector.h" #include "chrome/browser/io_thread.h" @@ -65,6 +64,7 @@ #include "content/browser/browser_child_process_host.h" #include "content/browser/browser_thread.h" #include "content/browser/child_process_security_policy.h" +#include "content/browser/gpu_process_host_ui_shim.h" #include "content/browser/plugin_service.h" #include "content/browser/renderer_host/render_process_host.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" diff --git a/chrome/browser/gpu_data_manager.cc b/chrome/browser/gpu_data_manager.cc deleted file mode 100644 index e839072..0000000 --- a/chrome/browser/gpu_data_manager.cc +++ /dev/null @@ -1,214 +0,0 @@ -// 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. - -#include "chrome/browser/gpu_data_manager.h" - -#include "base/command_line.h" -#include "base/metrics/histogram.h" -#include "base/string_number_conversions.h" -#include "chrome/common/child_process_logging.h" -#include "chrome/common/chrome_switches.h" -#include "content/browser/browser_thread.h" -#include "content/browser/gpu_blacklist.h" -#include "content/browser/gpu_process_host.h" -#include "content/common/gpu/gpu_messages.h" -#include "content/gpu/gpu_info_collector.h" -#include "ui/gfx/gl/gl_implementation.h" -#include "ui/gfx/gl/gl_switches.h" - -GpuDataManager::GpuDataManager() - : complete_gpu_info_already_requested_(false) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - - GPUInfo gpu_info; - gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info); - UpdateGpuInfo(gpu_info); -} - -GpuDataManager::~GpuDataManager() { } - -GpuDataManager* GpuDataManager::GetInstance() { - return Singleton<GpuDataManager>::get(); -} - -void GpuDataManager::RequestCompleteGpuInfoIfNeeded() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (complete_gpu_info_already_requested_) - return; - complete_gpu_info_already_requested_ = true; - - GpuProcessHost::SendOnIO( - 0, - content::CAUSE_FOR_GPU_LAUNCH_GPUDATAMANAGER_REQUESTCOMPLETEGPUINFOIFNEEDED, - new GpuMsg_CollectGraphicsInfo()); -} - -void GpuDataManager::UpdateGpuInfo(const GPUInfo& gpu_info) { - base::AutoLock auto_lock(gpu_info_lock_); - if (!gpu_info_.Merge(gpu_info)) - return; - child_process_logging::SetGpuInfo(gpu_info_); -} - -const GPUInfo& GpuDataManager::gpu_info() const { - base::AutoLock auto_lock(gpu_info_lock_); - return gpu_info_; -} - -Value* GpuDataManager::GetFeatureStatus() { - const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); - if (gpu_blacklist_.get()) - return gpu_blacklist_->GetFeatureStatus(GpuAccessAllowed(), - browser_command_line.HasSwitch(switches::kDisableAcceleratedCompositing), - browser_command_line.HasSwitch(switches::kEnableAccelerated2dCanvas), - browser_command_line.HasSwitch(switches::kDisableExperimentalWebGL), - browser_command_line.HasSwitch(switches::kDisableGLMultisampling)); - return NULL; -} - -std::string GpuDataManager::GetBlacklistVersion() const { - if (gpu_blacklist_.get() != NULL) { - uint16 version_major, version_minor; - if (gpu_blacklist_->GetVersion(&version_major, - &version_minor)) { - std::string version_string = - base::UintToString(static_cast<unsigned>(version_major)) + - "." + - base::UintToString(static_cast<unsigned>(version_minor)); - return version_string; - } - } - return ""; -} - -void GpuDataManager::AddLogMessage(Value* msg) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - log_messages_.Append(msg); -} - -const ListValue& GpuDataManager::log_messages() const { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - return log_messages_; -} - -GpuFeatureFlags GpuDataManager::GetGpuFeatureFlags() { - return gpu_feature_flags_; -} - -bool GpuDataManager::GpuAccessAllowed() { - return gpu_feature_flags_.flags() == 0; -} - -void GpuDataManager::AddGpuInfoUpdateCallback(Callback0::Type* callback) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - gpu_info_update_callbacks_.insert(callback); -} - -bool GpuDataManager::RemoveGpuInfoUpdateCallback(Callback0::Type* callback) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - std::set<Callback0::Type*>::iterator i = - gpu_info_update_callbacks_.find(callback); - if (i != gpu_info_update_callbacks_.end()) { - gpu_info_update_callbacks_.erase(i); - return true; - } - return false; -} - -void GpuDataManager::AppendRendererCommandLine( - CommandLine* command_line) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - DCHECK(command_line); - - uint32 flags = gpu_feature_flags_.flags(); - if ((flags & GpuFeatureFlags::kGpuFeatureWebgl) && - !command_line->HasSwitch(switches::kDisableExperimentalWebGL)) - command_line->AppendSwitch(switches::kDisableExperimentalWebGL); - if ((flags & GpuFeatureFlags::kGpuFeatureMultisampling) && - !command_line->HasSwitch(switches::kDisableGLMultisampling)) - command_line->AppendSwitch(switches::kDisableGLMultisampling); - // If we have kGpuFeatureAcceleratedCompositing, we disable all GPU features. - if (flags & GpuFeatureFlags::kGpuFeatureAcceleratedCompositing) { - const char* switches[] = { - switches::kDisableAcceleratedCompositing, - switches::kDisableExperimentalWebGL - }; - const int switch_count = sizeof(switches) / sizeof(char*); - for (int i = 0; i < switch_count; ++i) { - if (!command_line->HasSwitch(switches[i])) - command_line->AppendSwitch(switches[i]); - } - } -} - -void GpuDataManager::UpdateGpuBlacklist(GpuBlacklist* gpu_blacklist) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - gpu_blacklist_.reset(gpu_blacklist); - UpdateGpuFeatureFlags(); -} - -void GpuDataManager::RunGpuInfoUpdateCallbacks() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - std::set<Callback0::Type*>::iterator i = gpu_info_update_callbacks_.begin(); - for (; i != gpu_info_update_callbacks_.end(); ++i) { - (*i)->Run(); - } -} - -void GpuDataManager::UpdateGpuFeatureFlags() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - - GpuBlacklist* gpu_blacklist = GetGpuBlacklist(); - if (gpu_blacklist == NULL) - return; - - // We don't set a lock around modifying gpu_feature_flags_ since it's just an - // int. - if (!gpu_blacklist) { - gpu_feature_flags_.set_flags(0); - return; - } - - { - base::AutoLock auto_lock(gpu_info_lock_); - gpu_feature_flags_ = gpu_blacklist->DetermineGpuFeatureFlags( - GpuBlacklist::kOsAny, NULL, gpu_info_); - - // If gpu is blacklisted, no further GPUInfo will be collected. - gpu_info_.finalized = true; - } - - uint32 max_entry_id = gpu_blacklist->max_entry_id(); - if (!gpu_feature_flags_.flags()) { - UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry", - 0, max_entry_id + 1); - return; - } - - // Notify clients that GpuInfo state has changed - RunGpuInfoUpdateCallbacks(); - - // TODO(zmo): move histograming to GpuBlacklist::DetermineGpuFeatureFlags. - std::vector<uint32> flag_entries; - gpu_blacklist->GetGpuFeatureFlagEntries( - GpuFeatureFlags::kGpuFeatureAll, flag_entries); - DCHECK_GT(flag_entries.size(), 0u); - for (size_t i = 0; i < flag_entries.size(); ++i) { - UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry", - flag_entries[i], max_entry_id + 1); - } -} - -GpuBlacklist* GpuDataManager::GetGpuBlacklist() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); - if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) || - browser_command_line.GetSwitchValueASCII( - switches::kUseGL) == gfx::kGLImplementationOSMesaName) - return NULL; - // No need to return an empty blacklist. - if (gpu_blacklist_.get() != NULL && gpu_blacklist_->max_entry_id() == 0) - return NULL; - return gpu_blacklist_.get(); -} diff --git a/chrome/browser/gpu_data_manager.h b/chrome/browser/gpu_data_manager.h deleted file mode 100644 index f8db70c..0000000 --- a/chrome/browser/gpu_data_manager.h +++ /dev/null @@ -1,108 +0,0 @@ -// 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 CHROME_BROWSER_GPU_DATA_MANAGER_H_ -#define CHROME_BROWSER_GPU_DATA_MANAGER_H_ -#pragma once - -#include <set> -#include <string> - -#include "base/callback.h" -#include "base/memory/scoped_ptr.h" -#include "base/memory/singleton.h" -#include "base/synchronization/lock.h" -#include "base/values.h" -#include "content/common/gpu/gpu_feature_flags.h" -#include "content/common/gpu/gpu_info.h" - -class CommandLine; -class GpuBlacklist; - -class GpuDataManager { - public: - // Getter for the singleton. This will return NULL on failure. - static GpuDataManager* GetInstance(); - - // Requests complete GPUinfo if it has not already been requested - void RequestCompleteGpuInfoIfNeeded(); - - // Only update if the current GPUInfo is not finalized. - void UpdateGpuInfo(const GPUInfo& gpu_info); - - const GPUInfo& gpu_info() const; - - // Returns status of various GPU features. Return type is - // GpuBlacklist::GetFeatureStatus, or NULL if blacklist is - // uninitialized. Caller is responsible for deleting the returned value. - Value* GetFeatureStatus(); - - std::string GetBlacklistVersion() const; - - void AddLogMessage(Value* msg); - - const ListValue& log_messages() const; - - // Can be called on any thread. - GpuFeatureFlags GetGpuFeatureFlags(); - - // This indicator might change because we could collect more GPU info or - // because the GPU blacklist could be updated. - // If this returns false, any further GPU access, including launching GPU - // process, establish GPU channel, and GPU info collection, should be - // blocked. - // Can be called on any thread. - bool GpuAccessAllowed(); - - // Add a callback. - void AddGpuInfoUpdateCallback(Callback0::Type* callback); - - // Remove a callback. - // Returns true if removed, or false if it was not found. - bool RemoveGpuInfoUpdateCallback(Callback0::Type* callback); - - // Inserting disable-feature switches into renderer process command-line - // in correspondance to preliminary gpu feature flags. - void AppendRendererCommandLine(CommandLine* command_line); - - // Gives ownership of the latest blacklist. This is always called on the UI - // thread. - void UpdateGpuBlacklist(GpuBlacklist* gpu_blacklist); - - private: - friend struct DefaultSingletonTraits<GpuDataManager>; - - GpuDataManager(); - virtual ~GpuDataManager(); - - // Check if we should go ahead and use gpu blacklist. - // If not, return NULL; otherwise, update and return the current list. - GpuBlacklist* GetGpuBlacklist(); - - // If flags hasn't been set and GPUInfo is available, run through blacklist - // and compute the flags. - void UpdateGpuFeatureFlags(); - - // Call all callbacks. - void RunGpuInfoUpdateCallbacks(); - - bool complete_gpu_info_already_requested_; - - bool gpu_feature_flags_set_; - GpuFeatureFlags gpu_feature_flags_; - - GPUInfo gpu_info_; - mutable base::Lock gpu_info_lock_; - - scoped_ptr<GpuBlacklist> gpu_blacklist_; - - // Map of callbacks. - std::set<Callback0::Type*> gpu_info_update_callbacks_; - - ListValue log_messages_; - - DISALLOW_COPY_AND_ASSIGN(GpuDataManager); -}; - -#endif // CHROME_BROWSER_GPU_DATA_MANAGER_H_ diff --git a/chrome/browser/gpu_pixel_browsertest.cc b/chrome/browser/gpu_pixel_browsertest.cc index ae71982..4e6931c 100644 --- a/chrome/browser/gpu_pixel_browsertest.cc +++ b/chrome/browser/gpu_pixel_browsertest.cc @@ -12,7 +12,6 @@ #include "base/path_service.h" #include "base/string_util.h" #include "base/stringprintf.h" -#include "chrome/browser/gpu_data_manager.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/common/chrome_paths.h" @@ -20,6 +19,7 @@ #include "chrome/test/in_process_browser_test.h" #include "chrome/test/test_launcher_utils.h" #include "chrome/test/ui_test_utils.h" +#include "content/browser/gpu_data_manager.h" #include "content/browser/gpu_process_host.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/tab_contents.h" diff --git a/chrome/browser/gpu_process_host_ui_shim.cc b/chrome/browser/gpu_process_host_ui_shim.cc deleted file mode 100644 index b7737cb..0000000 --- a/chrome/browser/gpu_process_host_ui_shim.cc +++ /dev/null @@ -1,321 +0,0 @@ -// TODO(jam): move this file to src/content once we have an interface that the -// embedder provides. We can then use it to get the resource and resize the -// window. -// 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. - -#include "chrome/browser/gpu_process_host_ui_shim.h" - -#include "base/command_line.h" -#include "base/id_map.h" -#include "base/process_util.h" -#include "chrome/browser/browser_process.h" -#include "chrome/browser/gpu_data_manager.h" -#include "chrome/browser/io_thread.h" -#include "content/browser/browser_thread.h" -#include "content/browser/gpu_process_host.h" -#include "content/browser/renderer_host/render_process_host.h" -#include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/renderer_host/render_widget_host_view.h" -#include "content/common/content_switches.h" -#include "content/common/gpu/gpu_messages.h" -#include "gpu/common/gpu_trace_event.h" - -#if defined(OS_LINUX) -// These two #includes need to come after gpu_messages.h. -#include <gdk/gdkwindow.h> // NOLINT -#include <gdk/gdkx.h> // NOLINT -#include "ui/base/x/x11_util.h" -#include "ui/gfx/gtk_native_view_id_manager.h" -#include "ui/gfx/size.h" -#endif // defined(OS_LINUX) -namespace { - -// One of the linux specific headers defines this as a macro. -#ifdef DestroyAll -#undef DestroyAll -#endif - -IDMap<GpuProcessHostUIShim> g_hosts_by_id; - -class SendOnIOThreadTask : public Task { - public: - SendOnIOThreadTask(int host_id, IPC::Message* msg) - : host_id_(host_id), - msg_(msg) { - } - - private: - void Run() { - GpuProcessHost* host = GpuProcessHost::FromID(host_id_); - if (host) - host->Send(msg_.release()); - } - - int host_id_; - scoped_ptr<IPC::Message> msg_; -}; - -class UIThreadSender : public IPC::Channel::Sender { - public: - virtual bool Send(IPC::Message* msg) { - // The GPU process must never send a synchronous IPC message to the browser - // process. This could result in deadlock. Unfortunately linux does this for - // GpuHostMsg_ResizeXID. TODO(apatrick): fix this before issuing any GL calls - // on the browser process' GPU thread. -#if !defined(OS_LINUX) - DCHECK(!msg->is_sync()); -#endif - - // When the GpuChannelManager sends an IPC, post it to the UI thread without - // using IPC. - bool success = BrowserThread::PostTask( - BrowserThread::UI, - FROM_HERE, - new RouteToGpuProcessHostUIShimTask(0, *msg)); - - delete msg; - return success; - } -}; - -void ForwardMessageToGpuThread(GpuChannelManager* gpu_channel_manager, - IPC::Message* msg) { - bool success = gpu_channel_manager->OnMessageReceived(*msg); - - // If the message was not handled, it is likely it was intended for the - // GpuChildThread, which does not exist in single process and in process GPU - // mode. - DCHECK(success); - - delete msg; -} - -} // namespace - -RouteToGpuProcessHostUIShimTask::RouteToGpuProcessHostUIShimTask( - int host_id, - const IPC::Message& msg) - : host_id_(host_id), - msg_(msg) { -} - -RouteToGpuProcessHostUIShimTask::~RouteToGpuProcessHostUIShimTask() { -} - -void RouteToGpuProcessHostUIShimTask::Run() { - GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(host_id_); - if (ui_shim) - ui_shim->OnMessageReceived(msg_); -} - -GpuProcessHostUIShim::GpuProcessHostUIShim(int host_id) - : host_id_(host_id), - gpu_channel_manager_(NULL), - ui_thread_sender_(NULL) { - g_hosts_by_id.AddWithID(this, host_id_); - if (host_id == 0) { - ui_thread_sender_ = new UIThreadSender; - gpu_channel_manager_ = new GpuChannelManager( - ui_thread_sender_, - NULL, - g_browser_process->io_thread()->message_loop(), - g_browser_process->shutdown_event()); - } -} - -// static -GpuProcessHostUIShim* GpuProcessHostUIShim::Create(int host_id) { - DCHECK(!FromID(host_id)); - return new GpuProcessHostUIShim(host_id); -} - -// static -void GpuProcessHostUIShim::Destroy(int host_id) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - delete FromID(host_id); -} - -// static -void GpuProcessHostUIShim::DestroyAll() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - while (!g_hosts_by_id.IsEmpty()) { - IDMap<GpuProcessHostUIShim>::iterator it(&g_hosts_by_id); - delete it.GetCurrentValue(); - } -} - -// static -GpuProcessHostUIShim* GpuProcessHostUIShim::FromID(int host_id) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - return g_hosts_by_id.Lookup(host_id); -} - -bool GpuProcessHostUIShim::Send(IPC::Message* msg) { - DCHECK(CalledOnValidThread()); - - bool success; - - if (host_id_ == 0) { - success = BrowserThread::PostTask( - BrowserThread::GPU, - FROM_HERE, - NewRunnableFunction(ForwardMessageToGpuThread, - gpu_channel_manager_, - msg)); - } else { - success = BrowserThread::PostTask( - BrowserThread::IO, - FROM_HERE, - new SendOnIOThreadTask(host_id_, msg)); - } - - return success; -} - -bool GpuProcessHostUIShim::OnMessageReceived(const IPC::Message& message) { - DCHECK(CalledOnValidThread()); - - if (message.routing_id() != MSG_ROUTING_CONTROL) - return false; - - return OnControlMessageReceived(message); -} - -#if defined(OS_MACOSX) - -void GpuProcessHostUIShim::DidDestroyAcceleratedSurface(int renderer_id, - int render_view_id) { - // Destroy the command buffer that owns the accelerated surface. - Send(new GpuMsg_DestroyCommandBuffer(renderer_id, render_view_id)); -} - -void GpuProcessHostUIShim::SendToGpuHost(int host_id, IPC::Message* msg) { - GpuProcessHostUIShim* ui_shim = FromID(host_id); - if (!ui_shim) - return; - - ui_shim->Send(msg); -} - -#endif - -GpuProcessHostUIShim::~GpuProcessHostUIShim() { - DCHECK(CalledOnValidThread()); - g_hosts_by_id.Remove(host_id_); - - // Ensure these are destroyed on the GPU thread. - if (gpu_channel_manager_) { - BrowserThread::DeleteSoon(BrowserThread::GPU, - FROM_HERE, - gpu_channel_manager_); - gpu_channel_manager_ = NULL; - } - if (ui_thread_sender_) { - BrowserThread::DeleteSoon(BrowserThread::GPU, - FROM_HERE, - ui_thread_sender_); - ui_thread_sender_ = NULL; - } -} - -bool GpuProcessHostUIShim::OnControlMessageReceived( - const IPC::Message& message) { - DCHECK(CalledOnValidThread()); - - IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message) - IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage, - OnLogMessage) -#if defined(OS_LINUX) && !defined(TOUCH_UI) - IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_ResizeXID, OnResizeXID) -#elif defined(OS_MACOSX) - IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSetIOSurface, - OnAcceleratedSurfaceSetIOSurface) - IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, - OnAcceleratedSurfaceBuffersSwapped) -#elif defined(OS_WIN) - IPC_MESSAGE_HANDLER(GpuHostMsg_ScheduleComposite, OnScheduleComposite); -#endif - IPC_MESSAGE_UNHANDLED_ERROR() - IPC_END_MESSAGE_MAP() - - return true; -} - -void GpuProcessHostUIShim::OnLogMessage( - int level, - const std::string& header, - const std::string& message) { - DictionaryValue* dict = new DictionaryValue(); - dict->SetInteger("level", level); - dict->SetString("header", header); - dict->SetString("message", message); - GpuDataManager::GetInstance()->AddLogMessage(dict); -} - -#if defined(OS_LINUX) && !defined(TOUCH_UI) - -void GpuProcessHostUIShim::OnResizeXID(unsigned long xid, gfx::Size size, - IPC::Message *reply_msg) { - GdkWindow* window = reinterpret_cast<GdkWindow*>(gdk_xid_table_lookup(xid)); - if (window) { - Display* display = GDK_WINDOW_XDISPLAY(window); - gdk_window_resize(window, size.width(), size.height()); - XSync(display, False); - } - - GpuHostMsg_ResizeXID::WriteReplyParams(reply_msg, (window != NULL)); - Send(reply_msg); -} - -#elif defined(OS_MACOSX) - -void GpuProcessHostUIShim::OnAcceleratedSurfaceSetIOSurface( - const GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params& params) { - RenderViewHost* host = RenderViewHost::FromID(params.renderer_id, - params.render_view_id); - if (!host) - return; - RenderWidgetHostView* view = host->view(); - if (!view) - return; - view->AcceleratedSurfaceSetIOSurface(params.window, - params.width, - params.height, - params.identifier); -} - -void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( - const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { - RenderViewHost* host = RenderViewHost::FromID(params.renderer_id, - params.render_view_id); - if (!host) - return; - RenderWidgetHostView* view = host->view(); - if (!view) - return; - view->AcceleratedSurfaceBuffersSwapped( - // Parameters needed to swap the IOSurface. - params.window, - params.surface_id, - // Parameters needed to formulate an acknowledgment. - params.renderer_id, - params.route_id, - host_id_, - params.swap_buffers_count); -} - -#elif defined(OS_WIN) - -void GpuProcessHostUIShim::OnScheduleComposite(int renderer_id, - int render_view_id) { - RenderViewHost* host = RenderViewHost::FromID(renderer_id, - render_view_id); - if (!host) { - return; - } - host->ScheduleComposite(); -} - -#endif diff --git a/chrome/browser/gpu_process_host_ui_shim.h b/chrome/browser/gpu_process_host_ui_shim.h deleted file mode 100644 index 667b34a..0000000 --- a/chrome/browser/gpu_process_host_ui_shim.h +++ /dev/null @@ -1,123 +0,0 @@ -// 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 CHROME_BROWSER_GPU_PROCESS_HOST_UI_SHIM_H_ -#define CHROME_BROWSER_GPU_PROCESS_HOST_UI_SHIM_H_ -#pragma once - -// This class lives on the UI thread and supports classes like the -// BackingStoreProxy, which must live on the UI thread. The IO thread -// 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/memory/linked_ptr.h" -#include "base/memory/ref_counted.h" -#include "base/threading/non_thread_safe.h" -#include "content/common/gpu/gpu_channel_manager.h" -#include "content/common/gpu/gpu_feature_flags.h" -#include "content/common/gpu/gpu_info.h" -#include "content/common/gpu/gpu_process_launch_causes.h" -#include "content/common/message_router.h" - -namespace gfx { -class Size; -} - -struct GPUCreateCommandBufferConfig; -struct GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params; -struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; - -namespace IPC { -struct ChannelHandle; -class Message; -} - -// A task that will forward an IPC message to the UI shim. -class RouteToGpuProcessHostUIShimTask : public Task { - public: - RouteToGpuProcessHostUIShimTask(int host_id, const IPC::Message& msg); - ~RouteToGpuProcessHostUIShimTask(); - - private: - virtual void Run(); - - int host_id_; - IPC::Message msg_; -}; - -class GpuProcessHostUIShim - : public IPC::Channel::Listener, - public IPC::Channel::Sender, - public base::NonThreadSafe { - public: - // Create a GpuProcessHostUIShim with the given ID. The object can be found - // using FromID with the same id. - static GpuProcessHostUIShim* Create(int host_id); - - // Destroy the GpuProcessHostUIShim with the given host ID. This can only - // be called on the UI thread. Only the GpuProcessHost should destroy the - // UI shim. - static void Destroy(int host_id); - - // Destroy all remaining GpuProcessHostUIShims. - static void DestroyAll(); - - static GpuProcessHostUIShim* FromID(int host_id); - - // IPC::Channel::Sender implementation. - virtual bool Send(IPC::Message* msg); - - // 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); - -#if defined(OS_MACOSX) - // Notify the GPU process that an accelerated surface was destroyed. - void DidDestroyAcceleratedSurface(int renderer_id, int32 render_view_id); - - // TODO(apatrick): Remove this when mac does not use AcceleratedSurfaces for - // when running the GPU thread in the browser process. - static void SendToGpuHost(int host_id, IPC::Message* msg); -#endif - - private: - explicit GpuProcessHostUIShim(int host_id); - virtual ~GpuProcessHostUIShim(); - - // Message handlers. - bool OnControlMessageReceived(const IPC::Message& message); - - void OnLogMessage(int level, const std::string& header, - const std::string& message); -#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); -#endif - - // The serial number of the GpuProcessHost / GpuProcessHostUIShim pair. - int host_id_; - - // In single process and in process GPU mode, this references the - // GpuChannelManager or null otherwise. It must be called and deleted on the - // GPU thread. - GpuChannelManager* gpu_channel_manager_; - - // This is likewise single process / in process GPU specific. This is a Sender - // implementation that forwards IPC messages to this UI shim on the UI thread. - IPC::Channel::Sender* ui_thread_sender_; -}; - -#endif // CHROME_BROWSER_GPU_PROCESS_HOST_UI_SHIM_H_ - diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc index 12dc2e9..e18ab51 100644 --- a/chrome/browser/metrics/metrics_log.cc +++ b/chrome/browser/metrics/metrics_log.cc @@ -19,11 +19,11 @@ #include "chrome/browser/autocomplete/autocomplete.h" #include "chrome/browser/autocomplete/autocomplete_match.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/gpu_data_manager.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/common/chrome_version_info.h" #include "chrome/common/logging_chrome.h" #include "chrome/common/pref_names.h" +#include "content/browser/gpu_data_manager.h" #include "googleurl/src/gurl.h" #include "webkit/plugins/npapi/webplugininfo.h" diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm index c53fc2c..3eaab28 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm @@ -18,7 +18,6 @@ #import "chrome/browser/accessibility/browser_accessibility_cocoa.h" #include "chrome/browser/accessibility/browser_accessibility_state.h" #include "chrome/browser/browser_trial.h" -#include "chrome/browser/gpu_process_host_ui_shim.h" #include "chrome/browser/spellchecker_platform_engine.h" #import "chrome/browser/ui/cocoa/rwhvm_editcommand_helper.h" #import "chrome/browser/ui/cocoa/view_id_util.h" @@ -27,6 +26,7 @@ #include "chrome/common/spellcheck_messages.h" #include "content/browser/browser_thread.h" #include "content/browser/gpu_process_host.h" +#include "content/browser/gpu_process_host_ui_shim.h" #include "content/browser/plugin_process_host.h" #include "content/browser/renderer_host/backing_store_mac.h" #include "content/browser/renderer_host/render_process_host.h" diff --git a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc index c6078c9..7a263cd 100644 --- a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc +++ b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc @@ -13,7 +13,6 @@ #include "chrome/browser/background_contents_service_factory.h" #include "chrome/browser/character_encoding.h" #include "chrome/browser/extensions/extension_service.h" -#include "chrome/browser/gpu_data_manager.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/scoped_user_pref_update.h" #include "chrome/browser/profiles/profile.h" @@ -21,6 +20,7 @@ #include "chrome/browser/user_style_sheet_watcher.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" +#include "content/browser/gpu_data_manager.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_process_host.h" #include "content/browser/renderer_host/render_widget_fullscreen_host.h" diff --git a/chrome/browser/ui/webui/gpu_internals_ui.cc b/chrome/browser/ui/webui/gpu_internals_ui.cc index 97d2d58..05117f0 100644 --- a/chrome/browser/ui/webui/gpu_internals_ui.cc +++ b/chrome/browser/ui/webui/gpu_internals_ui.cc @@ -20,7 +20,6 @@ #include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/gpu_data_manager.h" #include "chrome/browser/io_thread.h" #include "chrome/browser/net/chrome_net_log.h" #include "chrome/browser/net/connection_tester.h" @@ -35,6 +34,7 @@ #include "chrome/common/jstemplate_builder.h" #include "chrome/common/url_constants.h" #include "content/browser/browser_thread.h" +#include "content/browser/gpu_data_manager.h" #include "content/browser/gpu_process_host.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/tab_contents.h" diff --git a/chrome/browser/web_resource/gpu_blacklist_updater.cc b/chrome/browser/web_resource/gpu_blacklist_updater.cc index 800bb38..5f31e4d 100644 --- a/chrome/browser/web_resource/gpu_blacklist_updater.cc +++ b/chrome/browser/web_resource/gpu_blacklist_updater.cc @@ -7,7 +7,6 @@ #include "base/logging.h" #include "base/values.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/gpu_data_manager.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/scoped_user_pref_update.h" #include "chrome/browser/profiles/profile.h" @@ -16,6 +15,7 @@ #include "chrome/common/pref_names.h" #include "content/browser/browser_thread.h" #include "content/browser/gpu_blacklist.h" +#include "content/browser/gpu_data_manager.h" #include "content/common/notification_type.h" #include "grit/browser_resources.h" #include "ui/base/resource/resource_bundle.h" |