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 // Necessary since BindInterface() is a template and can't be bound directly. | |
ncarter (slow)
2017/05/04 21:26:14
This comment seems inaccurate, since the PostTask
DaleCurtis
2017/05/04 21:31:08
Done.
| |
399 void CreateSingleSampleMetricsProvider( | |
400 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | |
401 service_manager::Connector* connector, | |
402 metrics::mojom::SingleSampleMetricsProviderRequest request) { | |
403 if (task_runner->BelongsToCurrentThread()) { | |
404 connector->BindInterface(mojom::kBrowserServiceName, std::move(request)); | |
405 return; | |
406 } | |
407 | |
408 task_runner->PostTask( | |
409 FROM_HERE, | |
410 base::Bind(&CreateSingleSampleMetricsProvider, std::move(task_runner), | |
411 connector, base::Passed(&request))); | |
412 } | |
413 | |
396 } // namespace | 414 } // namespace |
397 | 415 |
398 // For measuring memory usage after each task. Behind a command line flag. | 416 // For measuring memory usage after each task. Behind a command line flag. |
399 class MemoryObserver : public base::MessageLoop::TaskObserver { | 417 class MemoryObserver : public base::MessageLoop::TaskObserver { |
400 public: | 418 public: |
401 MemoryObserver() {} | 419 MemoryObserver() {} |
402 ~MemoryObserver() override {} | 420 ~MemoryObserver() override {} |
403 | 421 |
404 void WillProcessTask(const base::PendingTask& pending_task) override {} | 422 void WillProcessTask(const base::PendingTask& pending_task) override {} |
405 | 423 |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
607 #if BUILDFLAG(USE_EXTERNAL_POPUP_MENU) | 625 #if BUILDFLAG(USE_EXTERNAL_POPUP_MENU) |
608 // On Mac and Android Java UI, the select popups are rendered by the browser. | 626 // On Mac and Android Java UI, the select popups are rendered by the browser. |
609 blink::WebView::SetUseExternalPopupMenus(true); | 627 blink::WebView::SetUseExternalPopupMenus(true); |
610 #endif | 628 #endif |
611 | 629 |
612 lazy_tls.Pointer()->Set(this); | 630 lazy_tls.Pointer()->Set(this); |
613 | 631 |
614 // Register this object as the main thread. | 632 // Register this object as the main thread. |
615 ChildProcess::current()->set_main_thread(this); | 633 ChildProcess::current()->set_main_thread(this); |
616 | 634 |
635 metrics::InitializeSingleSampleMetricsFactory( | |
636 base::BindRepeating(&CreateSingleSampleMetricsProvider, | |
637 message_loop()->task_runner(), GetConnector())); | |
638 | |
617 gpu_ = ui::Gpu::Create( | 639 gpu_ = ui::Gpu::Create( |
618 GetConnector(), | 640 GetConnector(), |
619 IsRunningInMash() ? ui::mojom::kServiceName : mojom::kBrowserServiceName, | 641 IsRunningInMash() ? ui::mojom::kServiceName : mojom::kBrowserServiceName, |
620 GetIOTaskRunner()); | 642 GetIOTaskRunner()); |
621 | 643 |
622 cc::mojom::SharedBitmapManagerAssociatedPtr shared_bitmap_manager_ptr; | 644 cc::mojom::SharedBitmapManagerAssociatedPtr shared_bitmap_manager_ptr; |
623 render_message_filter()->GetSharedBitmapManager( | 645 render_message_filter()->GetSharedBitmapManager( |
624 mojo::MakeRequest(&shared_bitmap_manager_ptr)); | 646 mojo::MakeRequest(&shared_bitmap_manager_ptr)); |
625 shared_bitmap_manager_.reset(new ui::ChildSharedBitmapManager( | 647 shared_bitmap_manager_.reset(new ui::ChildSharedBitmapManager( |
626 cc::mojom::ThreadSafeSharedBitmapManagerAssociatedPtr::Create( | 648 cc::mojom::ThreadSafeSharedBitmapManagerAssociatedPtr::Create( |
(...skipping 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2412 } | 2434 } |
2413 } | 2435 } |
2414 | 2436 |
2415 void RenderThreadImpl::OnRendererInterfaceRequest( | 2437 void RenderThreadImpl::OnRendererInterfaceRequest( |
2416 mojom::RendererAssociatedRequest request) { | 2438 mojom::RendererAssociatedRequest request) { |
2417 DCHECK(!renderer_binding_.is_bound()); | 2439 DCHECK(!renderer_binding_.is_bound()); |
2418 renderer_binding_.Bind(std::move(request)); | 2440 renderer_binding_.Bind(std::move(request)); |
2419 } | 2441 } |
2420 | 2442 |
2421 } // namespace content | 2443 } // namespace content |
OLD | NEW |