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

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 2687583002: Add support for single sample metrics. (Closed)
Patch Set: Fix linker errors. Created 3 years, 7 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 (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
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/single_sample_metrics.h"
54 #include "content/child/appcache/appcache_dispatcher.h" 55 #include "content/child/appcache/appcache_dispatcher.h"
55 #include "content/child/appcache/appcache_frontend_impl.h" 56 #include "content/child/appcache/appcache_frontend_impl.h"
56 #include "content/child/blob_storage/blob_message_filter.h" 57 #include "content/child/blob_storage/blob_message_filter.h"
57 #include "content/child/child_histogram_message_filter.h" 58 #include "content/child/child_histogram_message_filter.h"
58 #include "content/child/child_resource_message_filter.h" 59 #include "content/child/child_resource_message_filter.h"
59 #include "content/child/content_child_helpers.h" 60 #include "content/child/content_child_helpers.h"
60 #include "content/child/db_message_filter.h" 61 #include "content/child/db_message_filter.h"
61 #include "content/child/indexed_db/indexed_db_dispatcher.h" 62 #include "content/child/indexed_db/indexed_db_dispatcher.h"
62 #include "content/child/memory/child_memory_coordinator_impl.h" 63 #include "content/child/memory/child_memory_coordinator_impl.h"
63 #include "content/child/resource_dispatcher.h" 64 #include "content/child/resource_dispatcher.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext/" + 387 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext/" +
387 ui::command_buffer_metrics::ContextTypeToString(type)), 388 ui::command_buffer_metrics::ContextTypeToString(type)),
388 automatic_flushes, support_locking, limits, attributes, nullptr, type)); 389 automatic_flushes, support_locking, limits, attributes, nullptr, type));
389 } 390 }
390 391
391 bool IsRunningInMash() { 392 bool IsRunningInMash() {
392 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); 393 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
393 return cmdline->HasSwitch(switches::kIsRunningInMash); 394 return cmdline->HasSwitch(switches::kIsRunningInMash);
394 } 395 }
395 396
397 // Necessary since BindInterface() is a template and can't be bound directly.
398 void CreateSingleSampleMetricsProvider(
399 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
400 service_manager::Connector* connector,
401 metrics::mojom::SingleSampleMetricsProviderRequest request) {
402 if (task_runner->BelongsToCurrentThread()) {
403 connector->BindInterface(mojom::kBrowserServiceName, std::move(request));
404 return;
405 }
406
407 task_runner->PostTask(
408 FROM_HERE,
409 base::Bind(&CreateSingleSampleMetricsProvider, std::move(task_runner),
410 connector, base::Passed(&request)));
411 }
412
396 } // namespace 413 } // namespace
397 414
398 // For measuring memory usage after each task. Behind a command line flag. 415 // For measuring memory usage after each task. Behind a command line flag.
399 class MemoryObserver : public base::MessageLoop::TaskObserver { 416 class MemoryObserver : public base::MessageLoop::TaskObserver {
400 public: 417 public:
401 MemoryObserver() {} 418 MemoryObserver() {}
402 ~MemoryObserver() override {} 419 ~MemoryObserver() override {}
403 420
404 void WillProcessTask(const base::PendingTask& pending_task) override {} 421 void WillProcessTask(const base::PendingTask& pending_task) override {}
405 422
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 #if BUILDFLAG(USE_EXTERNAL_POPUP_MENU) 624 #if BUILDFLAG(USE_EXTERNAL_POPUP_MENU)
608 // On Mac and Android Java UI, the select popups are rendered by the browser. 625 // On Mac and Android Java UI, the select popups are rendered by the browser.
609 blink::WebView::SetUseExternalPopupMenus(true); 626 blink::WebView::SetUseExternalPopupMenus(true);
610 #endif 627 #endif
611 628
612 lazy_tls.Pointer()->Set(this); 629 lazy_tls.Pointer()->Set(this);
613 630
614 // Register this object as the main thread. 631 // Register this object as the main thread.
615 ChildProcess::current()->set_main_thread(this); 632 ChildProcess::current()->set_main_thread(this);
616 633
634 metrics::InitializeSingleSampleMetricsFactory(
635 base::BindRepeating(&CreateSingleSampleMetricsProvider,
636 message_loop()->task_runner(), GetConnector()));
637
617 gpu_ = ui::Gpu::Create( 638 gpu_ = ui::Gpu::Create(
618 GetConnector(), 639 GetConnector(),
619 IsRunningInMash() ? ui::mojom::kServiceName : mojom::kBrowserServiceName, 640 IsRunningInMash() ? ui::mojom::kServiceName : mojom::kBrowserServiceName,
620 GetIOTaskRunner()); 641 GetIOTaskRunner());
621 642
622 cc::mojom::SharedBitmapManagerAssociatedPtr shared_bitmap_manager_ptr; 643 cc::mojom::SharedBitmapManagerAssociatedPtr shared_bitmap_manager_ptr;
623 render_message_filter()->GetSharedBitmapManager( 644 render_message_filter()->GetSharedBitmapManager(
624 mojo::MakeRequest(&shared_bitmap_manager_ptr)); 645 mojo::MakeRequest(&shared_bitmap_manager_ptr));
625 shared_bitmap_manager_.reset(new ui::ChildSharedBitmapManager( 646 shared_bitmap_manager_.reset(new ui::ChildSharedBitmapManager(
626 cc::mojom::ThreadSafeSharedBitmapManagerAssociatedPtr::Create( 647 cc::mojom::ThreadSafeSharedBitmapManagerAssociatedPtr::Create(
(...skipping 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after
2412 } 2433 }
2413 } 2434 }
2414 2435
2415 void RenderThreadImpl::OnRendererInterfaceRequest( 2436 void RenderThreadImpl::OnRendererInterfaceRequest(
2416 mojom::RendererAssociatedRequest request) { 2437 mojom::RendererAssociatedRequest request) {
2417 DCHECK(!renderer_binding_.is_bound()); 2438 DCHECK(!renderer_binding_.is_bound());
2418 renderer_binding_.Bind(std::move(request)); 2439 renderer_binding_.Bind(std::move(request));
2419 } 2440 }
2420 2441
2421 } // namespace content 2442 } // namespace content
OLDNEW
« components/metrics/single_sample_metrics.cc ('K') | « content/renderer/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698