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

Side by Side Diff: chrome/browser/memory/tab_manager_delegate_chromeos.cc

Issue 2127373006: Use base::StartWith() in more places when appropriate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, resolve conflict Created 4 years, 5 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 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 <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 if (!ash::Shell::HasInstance()) 65 if (!ash::Shell::HasInstance())
66 return nullptr; 66 return nullptr;
67 return aura::client::GetActivationClient(ash::Shell::GetPrimaryRootWindow()); 67 return aura::client::GetActivationClient(ash::Shell::GetPrimaryRootWindow());
68 } 68 }
69 69
70 // Checks if a window renders ARC apps. 70 // Checks if a window renders ARC apps.
71 bool IsArcWindow(aura::Window* window) { 71 bool IsArcWindow(aura::Window* window) {
72 if (!window || window->name() != kExoShellSurfaceWindowName) 72 if (!window || window->name() != kExoShellSurfaceWindowName)
73 return false; 73 return false;
74 std::string application_id = exo::ShellSurface::GetApplicationId(window); 74 std::string application_id = exo::ShellSurface::GetApplicationId(window);
75 return application_id.find(kArcProcessNamePrefix) == 0; 75 return base::StartsWith(application_id, kArcProcessNamePrefix,
76 base::CompareCase::SENSITIVE);
76 } 77 }
77 78
78 bool IsArcWindowInForeground() { 79 bool IsArcWindowInForeground() {
79 auto activation_client = GetActivationClient(); 80 auto activation_client = GetActivationClient();
80 return activation_client && IsArcWindow(activation_client->GetActiveWindow()); 81 return activation_client && IsArcWindow(activation_client->GetActiveWindow());
81 } 82 }
82 83
83 int AppStateToPriority( 84 int AppStateToPriority(
84 const arc::mojom::ProcessState& process_state) { 85 const arc::mojom::ProcessState& process_state) {
85 // Logic copied from Android: 86 // Logic copied from Android:
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 base::ProcessHandle pid) { 279 base::ProcessHandle pid) {
279 std::unique_ptr<base::ProcessMetrics> process_metrics( 280 std::unique_ptr<base::ProcessMetrics> process_metrics(
280 base::ProcessMetrics::CreateProcessMetrics(pid)); 281 base::ProcessMetrics::CreateProcessMetrics(pid));
281 base::WorkingSetKBytes mem_usage; 282 base::WorkingSetKBytes mem_usage;
282 process_metrics->GetWorkingSetKBytes(&mem_usage); 283 process_metrics->GetWorkingSetKBytes(&mem_usage);
283 return mem_usage.priv; 284 return mem_usage.priv;
284 } 285 }
285 286
286 class TabManagerDelegate::UmaReporter { 287 class TabManagerDelegate::UmaReporter {
287 public: 288 public:
288 UmaReporter() : last_kill_time_(), total_kills_(0) {} 289 UmaReporter() : total_kills_(0) {}
289 ~UmaReporter() {} 290 ~UmaReporter() {}
291
290 void ReportKill(const int memory_freed); 292 void ReportKill(const int memory_freed);
291 293
292 private: 294 private:
293 base::Time last_kill_time_; 295 base::Time last_kill_time_;
294 int total_kills_; 296 int total_kills_;
295 }; 297 };
296 298
297 void TabManagerDelegate::UmaReporter::ReportKill(const int memory_freed) { 299 void TabManagerDelegate::UmaReporter::ReportKill(const int memory_freed) {
298 base::Time now = base::Time::Now(); 300 base::Time now = base::Time::Now();
299 const TimeDelta time_delta = 301 const TimeDelta time_delta =
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 } 817 }
816 } 818 }
817 priority += priority_increment; 819 priority += priority_increment;
818 } 820 }
819 821
820 if (oom_score_for_tabs.size()) 822 if (oom_score_for_tabs.size())
821 SetOomScoreAdjForTabs(oom_score_for_tabs); 823 SetOomScoreAdjForTabs(oom_score_for_tabs);
822 } 824 }
823 825
824 } // namespace memory 826 } // namespace memory
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/proxy/proxy_api_helpers.cc ('k') | chrome/browser/shell_integration_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698