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