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

Side by Side Diff: content/browser/browser_main_loop.cc

Issue 2347383002: X11: Use better visuals for OpenGL (Closed)
Patch Set: Shutdown a misbehaving GPU process Created 4 years, 2 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
« no previous file with comments | « content/browser/browser_main_loop.h ('k') | content/browser/gpu/gpu_internals_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "content/browser/browser_main_loop.h" 5 #include "content/browser/browser_main_loop.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 #include "content/browser/startup_task_runner.h" 64 #include "content/browser/startup_task_runner.h"
65 #include "content/browser/utility_process_host_impl.h" 65 #include "content/browser/utility_process_host_impl.h"
66 #include "content/browser/webui/content_web_ui_controller_factory.h" 66 #include "content/browser/webui/content_web_ui_controller_factory.h"
67 #include "content/browser/webui/url_data_manager.h" 67 #include "content/browser/webui/url_data_manager.h"
68 #include "content/common/content_switches_internal.h" 68 #include "content/common/content_switches_internal.h"
69 #include "content/common/host_discardable_shared_memory_manager.h" 69 #include "content/common/host_discardable_shared_memory_manager.h"
70 #include "content/common/host_shared_bitmap_manager.h" 70 #include "content/common/host_shared_bitmap_manager.h"
71 #include "content/common/mojo/mojo_shell_connection_impl.h" 71 #include "content/common/mojo/mojo_shell_connection_impl.h"
72 #include "content/public/browser/browser_main_parts.h" 72 #include "content/public/browser/browser_main_parts.h"
73 #include "content/public/browser/content_browser_client.h" 73 #include "content/public/browser/content_browser_client.h"
74 #include "content/public/browser/gpu_data_manager_observer.h"
74 #include "content/public/browser/render_process_host.h" 75 #include "content/public/browser/render_process_host.h"
75 #include "content/public/browser/tracing_controller.h" 76 #include "content/public/browser/tracing_controller.h"
76 #include "content/public/common/content_client.h" 77 #include "content/public/common/content_client.h"
77 #include "content/public/common/content_switches.h" 78 #include "content/public/common/content_switches.h"
78 #include "content/public/common/main_function_params.h" 79 #include "content/public/common/main_function_params.h"
79 #include "content/public/common/result_codes.h" 80 #include "content/public/common/result_codes.h"
80 #include "device/battery/battery_status_service.h" 81 #include "device/battery/battery_status_service.h"
81 #include "device/time_zone_monitor/time_zone_monitor.h" 82 #include "device/time_zone_monitor/time_zone_monitor.h"
82 #include "media/base/media.h" 83 #include "media/base/media.h"
83 #include "media/base/user_input_monitor.h" 84 #include "media/base/user_input_monitor.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 #endif 178 #endif
178 179
179 #if defined(ENABLE_MOJO_CDM) && defined(ENABLE_PEPPER_CDMS) 180 #if defined(ENABLE_MOJO_CDM) && defined(ENABLE_PEPPER_CDMS)
180 #include "content/browser/media/cdm_service_impl.h" 181 #include "content/browser/media/cdm_service_impl.h"
181 #endif 182 #endif
182 183
183 #if defined(USE_X11) 184 #if defined(USE_X11)
184 #include "gpu/config/gpu_driver_bug_workaround_type.h" 185 #include "gpu/config/gpu_driver_bug_workaround_type.h"
185 #include "ui/base/x/x11_util_internal.h" // nogncheck 186 #include "ui/base/x/x11_util_internal.h" // nogncheck
186 #include "ui/gfx/x/x11_connection.h" // nogncheck 187 #include "ui/gfx/x/x11_connection.h" // nogncheck
187 #include "ui/gfx/x/x11_switches.h" // nogncheck
188 #include "ui/gfx/x/x11_types.h" // nogncheck 188 #include "ui/gfx/x/x11_types.h" // nogncheck
189 #endif 189 #endif
190 190
191 #if defined(USE_NSS_CERTS) 191 #if defined(USE_NSS_CERTS)
192 #include "crypto/nss_util.h" 192 #include "crypto/nss_util.h"
193 #endif 193 #endif
194 194
195 #if defined(ENABLE_VULKAN) 195 #if defined(ENABLE_VULKAN)
196 #include "gpu/vulkan/vulkan_implementation.h" 196 #include "gpu/vulkan/vulkan_implementation.h"
197 #endif 197 #endif
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 critical_threshold_mb); 358 critical_threshold_mb);
359 } 359 }
360 360
361 // In absence of valid switches use the automatic defaults. 361 // In absence of valid switches use the automatic defaults.
362 return new base::win::MemoryPressureMonitor(); 362 return new base::win::MemoryPressureMonitor();
363 } 363 }
364 #endif // defined(OS_WIN) 364 #endif // defined(OS_WIN)
365 365
366 } // namespace 366 } // namespace
367 367
368 #if defined(USE_X11) && !defined(OS_CHROMEOS)
369 namespace internal {
370
371 // Forwards GPUInfo updates to ui::XVisualManager
372 class GpuDataManagerVisualProxy : public GpuDataManagerObserver {
373 public:
374 explicit GpuDataManagerVisualProxy(GpuDataManagerImpl* gpu_data_manager)
375 : gpu_data_manager_(gpu_data_manager) {
376 gpu_data_manager_->AddObserver(this);
377 }
378
379 ~GpuDataManagerVisualProxy() override {
380 gpu_data_manager_->RemoveObserver(this);
381 }
382
383 void OnGpuInfoUpdate() override {
384 gpu::GPUInfo gpu_info = gpu_data_manager_->GetGPUInfo();
385 if (!ui::XVisualManager::GetInstance()->OnGPUInfoChanged(
386 gpu_info.software_rendering ||
387 !gpu_data_manager_->GpuAccessAllowed(nullptr),
388 gpu_info.system_visual, gpu_info.rgba_visual)) {
389 // The GPU process sent back bad visuals, which should never happen.
390 auto gpu_process_host = GpuProcessHost::Get(
dcheng 2016/09/30 02:40:49 Nit: auto*
391 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, false);
392 if (gpu_process_host)
393 gpu_process_host->ForceShutdown();
394 }
395 }
396
397 private:
398 GpuDataManagerImpl* gpu_data_manager_;
399
400 DISALLOW_COPY_AND_ASSIGN(GpuDataManagerVisualProxy);
401 };
402
403 } // namespace internal
404 #endif
405
368 // The currently-running BrowserMainLoop. There can be one or zero. 406 // The currently-running BrowserMainLoop. There can be one or zero.
369 BrowserMainLoop* g_current_browser_main_loop = NULL; 407 BrowserMainLoop* g_current_browser_main_loop = NULL;
370 408
371 #if defined(OS_ANDROID) 409 #if defined(OS_ANDROID)
372 bool g_browser_main_loop_shutting_down = false; 410 bool g_browser_main_loop_shutting_down = false;
373 #endif 411 #endif
374 412
375 // For measuring memory usage after each task. Behind a command line flag. 413 // For measuring memory usage after each task. Behind a command line flag.
376 class BrowserMainLoop::MemoryObserver : public base::MessageLoop::TaskObserver { 414 class BrowserMainLoop::MemoryObserver : public base::MessageLoop::TaskObserver {
377 public: 415 public:
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 // The WindowResizeHelper allows the UI thread to wait on specific renderer 777 // The WindowResizeHelper allows the UI thread to wait on specific renderer
740 // and GPU messages from the IO thread. Initializing it before the IO thread 778 // and GPU messages from the IO thread. Initializing it before the IO thread
741 // starts ensures the affected IO thread messages always have somewhere to go. 779 // starts ensures the affected IO thread messages always have somewhere to go.
742 ui::WindowResizeHelperMac::Get()->Init(base::ThreadTaskRunnerHandle::Get()); 780 ui::WindowResizeHelperMac::Get()->Init(base::ThreadTaskRunnerHandle::Get());
743 #endif 781 #endif
744 782
745 // 1) Need to initialize in-process GpuDataManager before creating threads. 783 // 1) Need to initialize in-process GpuDataManager before creating threads.
746 // It's unsafe to append the gpu command line switches to the global 784 // It's unsafe to append the gpu command line switches to the global
747 // CommandLine::ForCurrentProcess object after threads are created. 785 // CommandLine::ForCurrentProcess object after threads are created.
748 // 2) Must be after parts_->PreCreateThreads to pick up chrome://flags. 786 // 2) Must be after parts_->PreCreateThreads to pick up chrome://flags.
749 GpuDataManagerImpl::GetInstance()->Initialize(); 787 GpuDataManagerImpl* gpu_data_manager = GpuDataManagerImpl::GetInstance();
788 gpu_data_manager->Initialize();
750 789
751 #if defined(USE_X11) && !defined(OS_CHROMEOS) 790 #if defined(USE_X11) && !defined(OS_CHROMEOS)
752 // PreCreateThreads is called before CreateStartupTasks which starts the gpu 791 gpu_data_manager_visual_proxy_.reset(
753 // process. 792 new internal::GpuDataManagerVisualProxy(gpu_data_manager));
754 bool enable_transparent_visuals =
755 !GpuDataManagerImpl::GetInstance()->IsDriverBugWorkaroundActive(
756 gpu::DISABLE_TRANSPARENT_VISUALS);
757
758 // Prevent this flag to be turned off later since it is only used here.
759 if (!enable_transparent_visuals &&
760 !GpuDataManagerImpl::GetInstance()->IsCompleteGpuInfoAvailable()) {
761 base::CommandLine::ForCurrentProcess()->AppendSwitch(
762 "disable_transparent_visuals");
763 }
764
765 Visual* visual = NULL;
766 int depth = 0;
767 ui::ChooseVisualForWindow(enable_transparent_visuals, &visual, &depth);
768 DCHECK(depth > 0);
769 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
770 switches::kWindowDepth, base::IntToString(depth));
771 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
772 switches::kX11VisualID, base::UintToString(visual->visualid));
773 #endif 793 #endif
774 794
775 #if !defined(GOOGLE_CHROME_BUILD) || defined(OS_ANDROID) 795 #if !defined(GOOGLE_CHROME_BUILD) || defined(OS_ANDROID)
776 // Single-process is an unsupported and not fully tested mode, so 796 // Single-process is an unsupported and not fully tested mode, so
777 // don't enable it for official Chrome builds (except on Android). 797 // don't enable it for official Chrome builds (except on Android).
778 if (parsed_command_line_.HasSwitch(switches::kSingleProcess)) 798 if (parsed_command_line_.HasSwitch(switches::kSingleProcess))
779 RenderProcessHost::SetRunRendererInProcess(true); 799 RenderProcessHost::SetRunRendererInProcess(true);
780 #endif 800 #endif
781 801
782 return result_code_; 802 return result_code_;
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
1550 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner = 1570 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner =
1551 audio_thread_->task_runner(); 1571 audio_thread_->task_runner();
1552 audio_manager_ = media::AudioManager::Create(std::move(audio_task_runner), 1572 audio_manager_ = media::AudioManager::Create(std::move(audio_task_runner),
1553 std::move(worker_task_runner), 1573 std::move(worker_task_runner),
1554 MediaInternals::GetInstance()); 1574 MediaInternals::GetInstance());
1555 } 1575 }
1556 CHECK(audio_manager_); 1576 CHECK(audio_manager_);
1557 } 1577 }
1558 1578
1559 } // namespace content 1579 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_main_loop.h ('k') | content/browser/gpu/gpu_internals_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698