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

Side by Side Diff: chrome/browser/performance_monitor/performance_monitor.cc

Issue 2479593006: Move enable extensions define to a build flag. (Closed)
Patch Set: Merge Created 4 years, 1 month 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 "chrome/browser/performance_monitor/performance_monitor.h" 5 #include "chrome/browser/performance_monitor/performance_monitor.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/process/process_iterator.h" 11 #include "base/process/process_iterator.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "content/public/browser/browser_child_process_host.h" 14 #include "content/public/browser/browser_child_process_host.h"
15 #include "content/public/browser/browser_child_process_host_iterator.h" 15 #include "content/public/browser/browser_child_process_host_iterator.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/child_process_data.h" 17 #include "content/public/browser/child_process_data.h"
18 #include "content/public/browser/render_process_host.h" 18 #include "content/public/browser/render_process_host.h"
19 #include "content/public/common/content_constants.h" 19 #include "content/public/common/content_constants.h"
20 #include "extensions/features/features.h"
20 21
21 #if defined(ENABLE_EXTENSIONS) 22 #if BUILDFLAG(ENABLE_EXTENSIONS)
22 #include "extensions/browser/extension_host.h" 23 #include "extensions/browser/extension_host.h"
23 #include "extensions/browser/extension_registry.h" 24 #include "extensions/browser/extension_registry.h"
24 #include "extensions/common/manifest_handlers/background_info.h" 25 #include "extensions/common/manifest_handlers/background_info.h"
25 #endif 26 #endif
26 27
27 using content::BrowserThread; 28 using content::BrowserThread;
28 29
29 namespace performance_monitor { 30 namespace performance_monitor {
30 31
31 namespace { 32 namespace {
32 33
33 // The default interval at which PerformanceMonitor performs its timed 34 // The default interval at which PerformanceMonitor performs its timed
34 // collections. 35 // collections.
35 const int kGatherIntervalInSeconds = 120; 36 const int kGatherIntervalInSeconds = 120;
36 37
37 base::LazyInstance<PerformanceMonitor> g_monitor = LAZY_INSTANCE_INITIALIZER; 38 base::LazyInstance<PerformanceMonitor> g_monitor = LAZY_INSTANCE_INITIALIZER;
38 39
39 void GatherMetricsForRenderProcess(content::RenderProcessHost* host, 40 void GatherMetricsForRenderProcess(content::RenderProcessHost* host,
40 ProcessMetricsMetadata* data) { 41 ProcessMetricsMetadata* data) {
41 DCHECK_CURRENTLY_ON(BrowserThread::UI); 42 DCHECK_CURRENTLY_ON(BrowserThread::UI);
42 #if defined(ENABLE_EXTENSIONS) 43 #if BUILDFLAG(ENABLE_EXTENSIONS)
43 content::BrowserContext* browser_context = host->GetBrowserContext(); 44 content::BrowserContext* browser_context = host->GetBrowserContext();
44 extensions::ProcessMap* extension_process_map = 45 extensions::ProcessMap* extension_process_map =
45 extensions::ProcessMap::Get(browser_context); 46 extensions::ProcessMap::Get(browser_context);
46 47
47 std::set<std::string> extension_ids = 48 std::set<std::string> extension_ids =
48 extension_process_map->GetExtensionsInProcess(host->GetID()); 49 extension_process_map->GetExtensionsInProcess(host->GetID());
49 50
50 // We only collect more granular metrics when there's only one extension 51 // We only collect more granular metrics when there's only one extension
51 // running in a given renderer, to reduce noise. 52 // running in a given renderer, to reduce noise.
52 if (extension_ids.size() != 1) 53 if (extension_ids.size() != 1)
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 207
207 void PerformanceMonitor::RunTriggersUIThread() { 208 void PerformanceMonitor::RunTriggersUIThread() {
208 DCHECK_CURRENTLY_ON(BrowserThread::UI); 209 DCHECK_CURRENTLY_ON(BrowserThread::UI);
209 for (auto& metrics : metrics_map_) 210 for (auto& metrics : metrics_map_)
210 metrics.second->RunPerformanceTriggers(); 211 metrics.second->RunPerformanceTriggers();
211 212
212 StartGatherCycle(); 213 StartGatherCycle();
213 } 214 }
214 215
215 } // namespace performance_monitor 216 } // namespace performance_monitor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698