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/public/browser/browser_main_runner.h" | 5 #include "content/public/browser/browser_main_runner.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/leak_annotations.h" | 9 #include "base/debug/leak_annotations.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 14 #include "base/metrics/persistent_histogram_allocator.h" |
14 #include "base/metrics/statistics_recorder.h" | 15 #include "base/metrics/statistics_recorder.h" |
15 #include "base/profiler/scoped_profile.h" | 16 #include "base/profiler/scoped_profile.h" |
16 #include "base/profiler/scoped_tracker.h" | 17 #include "base/profiler/scoped_tracker.h" |
17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
18 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" | 19 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" |
19 #include "base/trace_event/trace_event.h" | 20 #include "base/trace_event/trace_event.h" |
20 #include "base/tracked_objects.h" | 21 #include "base/tracked_objects.h" |
21 #include "build/build_config.h" | 22 #include "build/build_config.h" |
22 #include "components/tracing/trace_config_file.h" | 23 #include "components/tracing/trace_config_file.h" |
23 #include "components/tracing/tracing_switches.h" | 24 #include "components/tracing/tracing_switches.h" |
(...skipping 29 matching lines...) Expand all Loading... |
53 public: | 54 public: |
54 BrowserMainRunnerImpl() | 55 BrowserMainRunnerImpl() |
55 : initialization_started_(false), is_shutdown_(false) {} | 56 : initialization_started_(false), is_shutdown_(false) {} |
56 | 57 |
57 ~BrowserMainRunnerImpl() override { | 58 ~BrowserMainRunnerImpl() override { |
58 if (initialization_started_ && !is_shutdown_) | 59 if (initialization_started_ && !is_shutdown_) |
59 Shutdown(); | 60 Shutdown(); |
60 } | 61 } |
61 | 62 |
62 int Initialize(const MainFunctionParams& parameters) override { | 63 int Initialize(const MainFunctionParams& parameters) override { |
| 64 // Create persistent/shared memory and allow histograms to be stored in it. |
| 65 // Memory that is not actualy used won't be physically mapped by the system. |
| 66 // BrowserMetrics usage, as reported in UMA, peaked around 1.9MiB as of |
| 67 // 2016-02-20. |
| 68 base::GlobalHistogramAllocator::CreateWithLocalMemory( |
| 69 3 << 20, // 3 MiB |
| 70 0x935DDD43, // SHA1(BrowserMetrics) |
| 71 "BrowserMetrics"); |
| 72 base::GlobalHistogramAllocator::Disable(); // Enabled by experiment only. |
| 73 |
63 SCOPED_UMA_HISTOGRAM_LONG_TIMER( | 74 SCOPED_UMA_HISTOGRAM_LONG_TIMER( |
64 "Startup.BrowserMainRunnerImplInitializeLongTime"); | 75 "Startup.BrowserMainRunnerImplInitializeLongTime"); |
65 | 76 |
66 // TODO(vadimt, yiyaoliu): Remove all tracked_objects references below once | 77 // TODO(vadimt, yiyaoliu): Remove all tracked_objects references below once |
67 // crbug.com/453640 is fixed. | 78 // crbug.com/453640 is fixed. |
68 tracked_objects::ThreadData::InitializeThreadContext(kMainThreadName); | 79 tracked_objects::ThreadData::InitializeThreadContext(kMainThreadName); |
69 base::trace_event::AllocationContextTracker::SetCurrentThreadName( | 80 base::trace_event::AllocationContextTracker::SetCurrentThreadName( |
70 kMainThreadName); | 81 kMainThreadName); |
71 TRACK_SCOPED_REGION( | 82 TRACK_SCOPED_REGION( |
72 "Startup", "BrowserMainRunnerImpl::Initialize"); | 83 "Startup", "BrowserMainRunnerImpl::Initialize"); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 BrowserMainRunner* BrowserMainRunner::Create() { | 260 BrowserMainRunner* BrowserMainRunner::Create() { |
250 return new BrowserMainRunnerImpl(); | 261 return new BrowserMainRunnerImpl(); |
251 } | 262 } |
252 | 263 |
253 // static | 264 // static |
254 bool BrowserMainRunner::ExitedMainMessageLoop() { | 265 bool BrowserMainRunner::ExitedMainMessageLoop() { |
255 return g_exited_main_message_loop; | 266 return g_exited_main_message_loop; |
256 } | 267 } |
257 | 268 |
258 } // namespace content | 269 } // namespace content |
OLD | NEW |