OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/memory/tab_manager_delegate_chromeos.h" | 5 #include "chrome/browser/memory/tab_manager_delegate_chromeos.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <map> | 10 #include <map> |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 } | 358 } |
359 | 359 |
360 void TabManagerDelegate::OnInstanceReady() { | 360 void TabManagerDelegate::OnInstanceReady() { |
361 auto* arc_bridge_service = arc::ArcBridgeService::Get(); | 361 auto* arc_bridge_service = arc::ArcBridgeService::Get(); |
362 DCHECK(arc_bridge_service); | 362 DCHECK(arc_bridge_service); |
363 | 363 |
364 arc_process_instance_ = arc_bridge_service->process()->instance(); | 364 arc_process_instance_ = arc_bridge_service->process()->instance(); |
365 arc_process_instance_version_ = arc_bridge_service->process()->version(); | 365 arc_process_instance_version_ = arc_bridge_service->process()->version(); |
366 | 366 |
367 DCHECK(arc_process_instance_); | 367 DCHECK(arc_process_instance_); |
368 | |
369 if (!IsArcMemoryManagementEnabled()) | |
370 return; | |
371 | |
372 if (arc_process_instance_version_ < 2) { | |
373 VLOG(1) << "ProcessInstance version < 2 does not " | |
374 "support DisableBuiltinOomAdjustment() yet."; | |
375 return; | |
376 } | |
377 // Stop Android system-wide oom_adj adjustment since this class will | |
378 // take over oom_score_adj settings. | |
379 arc_process_instance_->DisableBuiltinOomAdjustment(); | |
380 | |
381 if (arc_process_instance_version_ < 3) { | |
382 VLOG(1) << "arc::ProcessInstance version < 3 does not " | |
383 "support DisableLowMemoryKiller() yet."; | |
384 return; | |
385 } | |
386 VLOG(2) << "Disable LowMemoryKiller"; | |
387 arc_process_instance_->DisableLowMemoryKiller(); | |
388 } | 368 } |
389 | 369 |
390 void TabManagerDelegate::OnInstanceClosed() { | 370 void TabManagerDelegate::OnInstanceClosed() { |
391 arc_process_instance_ = nullptr; | 371 arc_process_instance_ = nullptr; |
392 arc_process_instance_version_ = 0; | 372 arc_process_instance_version_ = 0; |
393 } | 373 } |
394 | 374 |
395 // TODO(cylee): Remove this function if Android process OOM score settings | 375 // TODO(cylee): Remove this function if Android process OOM score settings |
396 // is moved back to Android. | 376 // is moved back to Android. |
397 // For example, negotiate non-overlapping OOM score ranges so Chrome and Android | 377 // For example, negotiate non-overlapping OOM score ranges so Chrome and Android |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 } | 760 } |
781 priority += priority_increment; | 761 priority += priority_increment; |
782 } | 762 } |
783 | 763 |
784 if (oom_scores_to_change.size()) | 764 if (oom_scores_to_change.size()) |
785 GetDebugDaemonClient()->SetOomScoreAdj( | 765 GetDebugDaemonClient()->SetOomScoreAdj( |
786 oom_scores_to_change, base::Bind(&OnSetOomScoreAdj)); | 766 oom_scores_to_change, base::Bind(&OnSetOomScoreAdj)); |
787 } | 767 } |
788 | 768 |
789 } // namespace memory | 769 } // namespace memory |
OLD | NEW |