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

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

Issue 2482783002: Add StateOn{Moderate,Critical}NotificationReceived metrics (Closed)
Patch Set: histograms.xml 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 "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 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 1392
1393 return result_code_; 1393 return result_code_;
1394 } 1394 }
1395 1395
1396 bool BrowserMainLoop::UsingInProcessGpu() const { 1396 bool BrowserMainLoop::UsingInProcessGpu() const {
1397 return parsed_command_line_.HasSwitch(switches::kSingleProcess) || 1397 return parsed_command_line_.HasSwitch(switches::kSingleProcess) ||
1398 parsed_command_line_.HasSwitch(switches::kInProcessGPU); 1398 parsed_command_line_.HasSwitch(switches::kInProcessGPU);
1399 } 1399 }
1400 1400
1401 void BrowserMainLoop::InitializeMemoryManagementComponent() { 1401 void BrowserMainLoop::InitializeMemoryManagementComponent() {
1402 // TODO(chrisha): Abstract away this construction mess to a helper function,
1403 // once MemoryPressureMonitor is made a concrete class.
1404 #if defined(OS_CHROMEOS)
1405 if (chromeos::switches::MemoryPressureHandlingEnabled()) {
1406 memory_pressure_monitor_.reset(new base::chromeos::MemoryPressureMonitor(
Avi (use Gerrit) 2016/11/07 04:32:01 memory_pressure_monitor_ = base::MakeUnique<base::
bashi 2016/11/07 05:53:39 Done.
1407 chromeos::switches::GetMemoryPressureThresholds()));
1408 }
1409 #elif defined(OS_MACOSX)
1410 memory_pressure_monitor_.reset(new base::mac::MemoryPressureMonitor());
Avi (use Gerrit) 2016/11/07 04:32:01 memory_pressure_monitor_ = base::MakeUnique<base::
bashi 2016/11/07 05:53:39 Done.
1411 #elif defined(OS_WIN)
1412 memory_pressure_monitor_.reset(CreateWinMemoryPressureMonitor(
Avi (use Gerrit) 2016/11/07 04:32:01 Fix CreateWinMemoryPressureMonitor so that it retu
bashi 2016/11/07 05:53:39 Done.
1413 parsed_command_line_));
1414 #endif
1415
1402 if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) { 1416 if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) {
1403 // Disable MemoryPressureListener when memory coordinator is enabled. 1417 // Disable MemoryPressureListener when memory coordinator is enabled.
1404 base::MemoryPressureListener::SetNotificationsSuppressed(true); 1418 base::MemoryPressureListener::SetNotificationsSuppressed(true);
1405 // base::Unretained is safe because the lifetime of MemoryCoordinator is 1419 // base::Unretained is safe because the lifetime of MemoryCoordinator is
1406 // tied to the lifetime of the browser process. 1420 // tied to the lifetime of the browser process.
1407 base::MemoryCoordinatorProxy::GetInstance()-> 1421 base::MemoryCoordinatorProxy::GetInstance()->
1408 SetGetCurrentMemoryStateCallback(base::Bind( 1422 SetGetCurrentMemoryStateCallback(base::Bind(
1409 &MemoryCoordinator::GetCurrentMemoryState, 1423 &MemoryCoordinator::GetCurrentMemoryState,
1410 base::Unretained(MemoryCoordinator::GetInstance()))); 1424 base::Unretained(MemoryCoordinator::GetInstance())));
1411 base::MemoryCoordinatorProxy::GetInstance()-> 1425 base::MemoryCoordinatorProxy::GetInstance()->
1412 SetSetCurrentMemoryStateForTestingCallback(base::Bind( 1426 SetSetCurrentMemoryStateForTestingCallback(base::Bind(
1413 &MemoryCoordinator::SetCurrentMemoryStateForTesting, 1427 &MemoryCoordinator::SetCurrentMemoryStateForTesting,
1414 base::Unretained(MemoryCoordinator::GetInstance()))); 1428 base::Unretained(MemoryCoordinator::GetInstance())));
1415 return; 1429
1430 if (memory_pressure_monitor_) {
1431 memory_pressure_monitor_->SetDispatchCallback(
1432 base::Bind(&MemoryCoordinator::RecordMemoryPressure,
1433 base::Unretained(MemoryCoordinator::GetInstance())));
1434 }
1416 } 1435 }
1417
1418 // TODO(chrisha): Abstract away this construction mess to a helper function,
1419 // once MemoryPressureMonitor is made a concrete class.
1420 #if defined(OS_CHROMEOS)
1421 if (chromeos::switches::MemoryPressureHandlingEnabled()) {
1422 memory_pressure_monitor_.reset(new base::chromeos::MemoryPressureMonitor(
1423 chromeos::switches::GetMemoryPressureThresholds()));
1424 }
1425 #elif defined(OS_MACOSX)
1426 memory_pressure_monitor_.reset(new base::mac::MemoryPressureMonitor());
1427 #elif defined(OS_WIN)
1428 memory_pressure_monitor_.reset(CreateWinMemoryPressureMonitor(
1429 parsed_command_line_));
1430 #endif
1431 } 1436 }
1432 1437
1433 bool BrowserMainLoop::InitializeToolkit() { 1438 bool BrowserMainLoop::InitializeToolkit() {
1434 TRACE_EVENT0("startup", "BrowserMainLoop::InitializeToolkit"); 1439 TRACE_EVENT0("startup", "BrowserMainLoop::InitializeToolkit");
1435 1440
1436 // TODO(evan): this function is rather subtle, due to the variety 1441 // TODO(evan): this function is rather subtle, due to the variety
1437 // of intersecting ifdefs we have. To keep it easy to follow, there 1442 // of intersecting ifdefs we have. To keep it easy to follow, there
1438 // are no #else branches on any #ifs. 1443 // are no #else branches on any #ifs.
1439 // TODO(stevenjb): Move platform specific code into platform specific Parts 1444 // TODO(stevenjb): Move platform specific code into platform specific Parts
1440 // (Need to add InitializeToolkit stage to BrowserParts). 1445 // (Need to add InitializeToolkit stage to BrowserParts).
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1599 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner = 1604 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner =
1600 audio_thread_->task_runner(); 1605 audio_thread_->task_runner();
1601 audio_manager_ = media::AudioManager::Create(std::move(audio_task_runner), 1606 audio_manager_ = media::AudioManager::Create(std::move(audio_task_runner),
1602 std::move(worker_task_runner), 1607 std::move(worker_task_runner),
1603 MediaInternals::GetInstance()); 1608 MediaInternals::GetInstance());
1604 } 1609 }
1605 CHECK(audio_manager_); 1610 CHECK(audio_manager_);
1606 } 1611 }
1607 1612
1608 } // namespace content 1613 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698