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

Side by Side Diff: content/browser/browser_main_loop.cc

Issue 2703743002: Refactor MemoryCoordinatorProxy (Closed)
Patch Set: Remove atomics Created 3 years, 10 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/browser/browser_main_loop.h" 5 #include "content/browser/browser_main_loop.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after
1611 memory_pressure_monitor_ = 1611 memory_pressure_monitor_ =
1612 base::MakeUnique<base::mac::MemoryPressureMonitor>(); 1612 base::MakeUnique<base::mac::MemoryPressureMonitor>();
1613 #elif defined(OS_WIN) 1613 #elif defined(OS_WIN)
1614 memory_pressure_monitor_ = 1614 memory_pressure_monitor_ =
1615 CreateWinMemoryPressureMonitor(parsed_command_line_); 1615 CreateWinMemoryPressureMonitor(parsed_command_line_);
1616 #endif 1616 #endif
1617 1617
1618 if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) { 1618 if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) {
1619 // Disable MemoryPressureListener when memory coordinator is enabled. 1619 // Disable MemoryPressureListener when memory coordinator is enabled.
1620 base::MemoryPressureListener::SetNotificationsSuppressed(true); 1620 base::MemoryPressureListener::SetNotificationsSuppressed(true);
1621 // base::Unretained is safe because the lifetime of MemoryCoordinator is 1621 auto* coordinator = MemoryCoordinatorImpl::GetInstance();
1622 // tied to the lifetime of the browser process.
1623 base::MemoryCoordinatorProxy::GetInstance()->
1624 SetGetCurrentMemoryStateCallback(base::Bind(
1625 &MemoryCoordinatorImpl::GetCurrentMemoryState,
1626 base::Unretained(MemoryCoordinatorImpl::GetInstance())));
1627 base::MemoryCoordinatorProxy::GetInstance()->
1628 SetSetCurrentMemoryStateForTestingCallback(base::Bind(
1629 &MemoryCoordinatorImpl::SetCurrentMemoryStateForTesting,
1630 base::Unretained(MemoryCoordinatorImpl::GetInstance())));
1631
1632 if (memory_pressure_monitor_) { 1622 if (memory_pressure_monitor_) {
1633 memory_pressure_monitor_->SetDispatchCallback( 1623 memory_pressure_monitor_->SetDispatchCallback(
1634 base::Bind(&MemoryCoordinatorImpl::RecordMemoryPressure, 1624 base::Bind(&MemoryCoordinatorImpl::RecordMemoryPressure,
1635 base::Unretained(MemoryCoordinatorImpl::GetInstance()))); 1625 base::Unretained(coordinator)));
1636 } 1626 }
1637 } 1627 }
1638 } 1628 }
1639 1629
1640 bool BrowserMainLoop::InitializeToolkit() { 1630 bool BrowserMainLoop::InitializeToolkit() {
1641 TRACE_EVENT0("startup", "BrowserMainLoop::InitializeToolkit"); 1631 TRACE_EVENT0("startup", "BrowserMainLoop::InitializeToolkit");
1642 1632
1643 // TODO(evan): this function is rather subtle, due to the variety 1633 // TODO(evan): this function is rather subtle, due to the variety
1644 // of intersecting ifdefs we have. To keep it easy to follow, there 1634 // of intersecting ifdefs we have. To keep it easy to follow, there
1645 // are no #else branches on any #ifs. 1635 // are no #else branches on any #ifs.
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 audio_thread_->task_runner(), audio_thread_->worker_task_runner(), 1786 audio_thread_->task_runner(), audio_thread_->worker_task_runner(),
1797 MediaInternals::GetInstance()); 1787 MediaInternals::GetInstance());
1798 } 1788 }
1799 CHECK(audio_manager_); 1789 CHECK(audio_manager_);
1800 1790
1801 audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get()); 1791 audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get());
1802 CHECK(audio_system_); 1792 CHECK(audio_system_);
1803 } 1793 }
1804 1794
1805 } // namespace content 1795 } // namespace content
OLDNEW
« no previous file with comments | « base/memory/memory_coordinator_proxy.cc ('k') | content/browser/memory/memory_coordinator_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698