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

Side by Side Diff: content/browser/compositor/gpu_process_transport_factory.cc

Issue 2422923002: Reduce usage of FOR_EACH_OBSERVER macro in content/browser (Closed)
Patch Set: skip cases in 2418143004 and 2418373002 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/compositor/gpu_process_transport_factory.h" 5 #include "content/browser/compositor/gpu_process_transport_factory.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 // Destroying the GLHelper may cause some async actions to be cancelled, 606 // Destroying the GLHelper may cause some async actions to be cancelled,
607 // causing things to request a new GLHelper. Due to crbug.com/176091 the 607 // causing things to request a new GLHelper. Due to crbug.com/176091 the
608 // GLHelper created in this case would be lost/leaked if we just reset() 608 // GLHelper created in this case would be lost/leaked if we just reset()
609 // on the |gl_helper_| variable directly. So instead we call reset() on a 609 // on the |gl_helper_| variable directly. So instead we call reset() on a
610 // local std::unique_ptr. 610 // local std::unique_ptr.
611 std::unique_ptr<display_compositor::GLHelper> helper = 611 std::unique_ptr<display_compositor::GLHelper> helper =
612 std::move(gl_helper_); 612 std::move(gl_helper_);
613 613
614 // If there are any observer left at this point, make sure they clean up 614 // If there are any observer left at this point, make sure they clean up
615 // before we destroy the GLHelper. 615 // before we destroy the GLHelper.
616 FOR_EACH_OBSERVER(ui::ContextFactoryObserver, observer_list_, 616 for (auto& observer : observer_list_)
617 OnLostResources()); 617 observer.OnLostResources();
618 618
619 helper.reset(); 619 helper.reset();
620 DCHECK(!gl_helper_) << "Destroying the GLHelper should not cause a new " 620 DCHECK(!gl_helper_) << "Destroying the GLHelper should not cause a new "
621 "GLHelper to be created."; 621 "GLHelper to be created.";
622 } 622 }
623 #if defined(OS_WIN) 623 #if defined(OS_WIN)
624 gfx::RenderingWindowManager::GetInstance()->UnregisterParent( 624 gfx::RenderingWindowManager::GetInstance()->UnregisterParent(
625 compositor->widget()); 625 compositor->widget());
626 #endif 626 #endif
627 } 627 }
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 // new resources are created if needed. 849 // new resources are created if needed.
850 // Kill shared contexts for both threads in tandem so they are always in 850 // Kill shared contexts for both threads in tandem so they are always in
851 // the same share group. 851 // the same share group.
852 scoped_refptr<cc::ContextProvider> lost_shared_main_thread_contexts = 852 scoped_refptr<cc::ContextProvider> lost_shared_main_thread_contexts =
853 shared_main_thread_contexts_; 853 shared_main_thread_contexts_;
854 shared_main_thread_contexts_ = NULL; 854 shared_main_thread_contexts_ = NULL;
855 855
856 std::unique_ptr<display_compositor::GLHelper> lost_gl_helper = 856 std::unique_ptr<display_compositor::GLHelper> lost_gl_helper =
857 std::move(gl_helper_); 857 std::move(gl_helper_);
858 858
859 FOR_EACH_OBSERVER(ui::ContextFactoryObserver, observer_list_, 859 for (auto& observer : observer_list_)
860 OnLostResources()); 860 observer.OnLostResources();
861 861
862 // Kill things that use the shared context before killing the shared context. 862 // Kill things that use the shared context before killing the shared context.
863 lost_gl_helper.reset(); 863 lost_gl_helper.reset();
864 lost_shared_main_thread_contexts = NULL; 864 lost_shared_main_thread_contexts = NULL;
865 } 865 }
866 866
867 scoped_refptr<cc::VulkanInProcessContextProvider> 867 scoped_refptr<cc::VulkanInProcessContextProvider>
868 GpuProcessTransportFactory::SharedVulkanContextProvider() { 868 GpuProcessTransportFactory::SharedVulkanContextProvider() {
869 if (!shared_vulkan_context_provider_initialized_) { 869 if (!shared_vulkan_context_provider_initialized_) {
870 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 870 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
871 switches::kEnableVulkan)) { 871 switches::kEnableVulkan)) {
872 shared_vulkan_context_provider_ = 872 shared_vulkan_context_provider_ =
873 cc::VulkanInProcessContextProvider::Create(); 873 cc::VulkanInProcessContextProvider::Create();
874 } 874 }
875 875
876 shared_vulkan_context_provider_initialized_ = true; 876 shared_vulkan_context_provider_initialized_ = true;
877 } 877 }
878 return shared_vulkan_context_provider_; 878 return shared_vulkan_context_provider_;
879 } 879 }
880 880
881 } // namespace content 881 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_child_process_host_impl.cc ('k') | content/browser/devtools/service_worker_devtools_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698