| OLD | NEW |
| 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/renderer/render_thread_impl.h" | 5 #include "content/renderer/render_thread_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "cc/base/switches.h" | 44 #include "cc/base/switches.h" |
| 45 #include "cc/blink/web_layer_impl.h" | 45 #include "cc/blink/web_layer_impl.h" |
| 46 #include "cc/output/buffer_to_texture_target_map.h" | 46 #include "cc/output/buffer_to_texture_target_map.h" |
| 47 #include "cc/output/compositor_frame_sink.h" | 47 #include "cc/output/compositor_frame_sink.h" |
| 48 #include "cc/output/copy_output_request.h" | 48 #include "cc/output/copy_output_request.h" |
| 49 #include "cc/output/vulkan_in_process_context_provider.h" | 49 #include "cc/output/vulkan_in_process_context_provider.h" |
| 50 #include "cc/raster/task_graph_runner.h" | 50 #include "cc/raster/task_graph_runner.h" |
| 51 #include "cc/trees/layer_tree_host_common.h" | 51 #include "cc/trees/layer_tree_host_common.h" |
| 52 #include "cc/trees/layer_tree_settings.h" | 52 #include "cc/trees/layer_tree_settings.h" |
| 53 #include "components/discardable_memory/client/client_discardable_shared_memory_
manager.h" | 53 #include "components/discardable_memory/client/client_discardable_shared_memory_
manager.h" |
| 54 #include "components/metrics/public/interfaces/single_sample_metrics.mojom.h" | |
| 55 #include "components/metrics/single_sample_metrics.h" | |
| 56 #include "content/child/appcache/appcache_dispatcher.h" | 54 #include "content/child/appcache/appcache_dispatcher.h" |
| 57 #include "content/child/appcache/appcache_frontend_impl.h" | 55 #include "content/child/appcache/appcache_frontend_impl.h" |
| 58 #include "content/child/blob_storage/blob_message_filter.h" | 56 #include "content/child/blob_storage/blob_message_filter.h" |
| 59 #include "content/child/child_histogram_message_filter.h" | 57 #include "content/child/child_histogram_message_filter.h" |
| 60 #include "content/child/child_resource_message_filter.h" | 58 #include "content/child/child_resource_message_filter.h" |
| 61 #include "content/child/content_child_helpers.h" | 59 #include "content/child/content_child_helpers.h" |
| 62 #include "content/child/db_message_filter.h" | 60 #include "content/child/db_message_filter.h" |
| 63 #include "content/child/indexed_db/indexed_db_dispatcher.h" | 61 #include "content/child/indexed_db/indexed_db_dispatcher.h" |
| 64 #include "content/child/memory/child_memory_coordinator_impl.h" | 62 #include "content/child/memory/child_memory_coordinator_impl.h" |
| 65 #include "content/child/resource_dispatcher.h" | 63 #include "content/child/resource_dispatcher.h" |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext/" + | 386 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext/" + |
| 389 ui::command_buffer_metrics::ContextTypeToString(type)), | 387 ui::command_buffer_metrics::ContextTypeToString(type)), |
| 390 automatic_flushes, support_locking, limits, attributes, nullptr, type)); | 388 automatic_flushes, support_locking, limits, attributes, nullptr, type)); |
| 391 } | 389 } |
| 392 | 390 |
| 393 bool IsRunningInMash() { | 391 bool IsRunningInMash() { |
| 394 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); | 392 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| 395 return cmdline->HasSwitch(switches::kIsRunningInMash); | 393 return cmdline->HasSwitch(switches::kIsRunningInMash); |
| 396 } | 394 } |
| 397 | 395 |
| 398 // Hook that allows single-sample metric code from //components/metrics to | |
| 399 // connect from the renderer process to the browser process. | |
| 400 void CreateSingleSampleMetricsProvider( | |
| 401 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | |
| 402 service_manager::Connector* connector, | |
| 403 metrics::mojom::SingleSampleMetricsProviderRequest request) { | |
| 404 if (task_runner->BelongsToCurrentThread()) { | |
| 405 connector->BindInterface(mojom::kBrowserServiceName, std::move(request)); | |
| 406 return; | |
| 407 } | |
| 408 | |
| 409 task_runner->PostTask( | |
| 410 FROM_HERE, | |
| 411 base::Bind(&CreateSingleSampleMetricsProvider, std::move(task_runner), | |
| 412 connector, base::Passed(&request))); | |
| 413 } | |
| 414 | |
| 415 } // namespace | 396 } // namespace |
| 416 | 397 |
| 417 // For measuring memory usage after each task. Behind a command line flag. | 398 // For measuring memory usage after each task. Behind a command line flag. |
| 418 class MemoryObserver : public base::MessageLoop::TaskObserver { | 399 class MemoryObserver : public base::MessageLoop::TaskObserver { |
| 419 public: | 400 public: |
| 420 MemoryObserver() {} | 401 MemoryObserver() {} |
| 421 ~MemoryObserver() override {} | 402 ~MemoryObserver() override {} |
| 422 | 403 |
| 423 void WillProcessTask(const base::PendingTask& pending_task) override {} | 404 void WillProcessTask(const base::PendingTask& pending_task) override {} |
| 424 | 405 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 #if BUILDFLAG(USE_EXTERNAL_POPUP_MENU) | 607 #if BUILDFLAG(USE_EXTERNAL_POPUP_MENU) |
| 627 // On Mac and Android Java UI, the select popups are rendered by the browser. | 608 // On Mac and Android Java UI, the select popups are rendered by the browser. |
| 628 blink::WebView::SetUseExternalPopupMenus(true); | 609 blink::WebView::SetUseExternalPopupMenus(true); |
| 629 #endif | 610 #endif |
| 630 | 611 |
| 631 lazy_tls.Pointer()->Set(this); | 612 lazy_tls.Pointer()->Set(this); |
| 632 | 613 |
| 633 // Register this object as the main thread. | 614 // Register this object as the main thread. |
| 634 ChildProcess::current()->set_main_thread(this); | 615 ChildProcess::current()->set_main_thread(this); |
| 635 | 616 |
| 636 metrics::InitializeSingleSampleMetricsFactory( | |
| 637 base::BindRepeating(&CreateSingleSampleMetricsProvider, | |
| 638 message_loop()->task_runner(), GetConnector())); | |
| 639 | |
| 640 gpu_ = ui::Gpu::Create( | 617 gpu_ = ui::Gpu::Create( |
| 641 GetConnector(), | 618 GetConnector(), |
| 642 IsRunningInMash() ? ui::mojom::kServiceName : mojom::kBrowserServiceName, | 619 IsRunningInMash() ? ui::mojom::kServiceName : mojom::kBrowserServiceName, |
| 643 GetIOTaskRunner()); | 620 GetIOTaskRunner()); |
| 644 | 621 |
| 645 cc::mojom::SharedBitmapManagerAssociatedPtr shared_bitmap_manager_ptr; | 622 cc::mojom::SharedBitmapManagerAssociatedPtr shared_bitmap_manager_ptr; |
| 646 render_message_filter()->GetSharedBitmapManager( | 623 render_message_filter()->GetSharedBitmapManager( |
| 647 mojo::MakeRequest(&shared_bitmap_manager_ptr)); | 624 mojo::MakeRequest(&shared_bitmap_manager_ptr)); |
| 648 shared_bitmap_manager_.reset(new ui::ChildSharedBitmapManager( | 625 shared_bitmap_manager_.reset(new ui::ChildSharedBitmapManager( |
| 649 cc::mojom::ThreadSafeSharedBitmapManagerAssociatedPtr::Create( | 626 cc::mojom::ThreadSafeSharedBitmapManagerAssociatedPtr::Create( |
| (...skipping 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2435 } | 2412 } |
| 2436 } | 2413 } |
| 2437 | 2414 |
| 2438 void RenderThreadImpl::OnRendererInterfaceRequest( | 2415 void RenderThreadImpl::OnRendererInterfaceRequest( |
| 2439 mojom::RendererAssociatedRequest request) { | 2416 mojom::RendererAssociatedRequest request) { |
| 2440 DCHECK(!renderer_binding_.is_bound()); | 2417 DCHECK(!renderer_binding_.is_bound()); |
| 2441 renderer_binding_.Bind(std::move(request)); | 2418 renderer_binding_.Bind(std::move(request)); |
| 2442 } | 2419 } |
| 2443 | 2420 |
| 2444 } // namespace content | 2421 } // namespace content |
| OLD | NEW |