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

Side by Side Diff: base/process/process_linux.cc

Issue 189333004: Move more file_util functions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « base/files/file_path.h ('k') | chrome/browser/download/download_path_reservation_tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/process/process.h" 5 #include "base/process/process.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <sys/resource.h> 8 #include <sys/resource.h>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/strings/string_split.h" 13 #include "base/strings/string_split.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
16 16
17 namespace base {
18
17 namespace { 19 namespace {
18 const int kForegroundPriority = 0; 20 const int kForegroundPriority = 0;
19 21
20 #if defined(OS_CHROMEOS) 22 #if defined(OS_CHROMEOS)
21 // We are more aggressive in our lowering of background process priority 23 // We are more aggressive in our lowering of background process priority
22 // for chromeos as we have much more control over other processes running 24 // for chromeos as we have much more control over other processes running
23 // on the machine. 25 // on the machine.
24 // 26 //
25 // TODO(davemoore) Refactor this by adding support for higher levels to set 27 // TODO(davemoore) Refactor this by adding support for higher levels to set
26 // the foregrounding / backgrounding process so we don't have to keep 28 // the foregrounding / backgrounding process so we don't have to keep
(...skipping 12 matching lines...) Expand all
39 // renderers on foreground ones to a greater level than simple renicing. 41 // renderers on foreground ones to a greater level than simple renicing.
40 bool enabled; 42 bool enabled;
41 base::FilePath foreground_file; 43 base::FilePath foreground_file;
42 base::FilePath background_file; 44 base::FilePath background_file;
43 45
44 CGroups() { 46 CGroups() {
45 foreground_file = 47 foreground_file =
46 base::FilePath(base::StringPrintf(kControlPath, kForeground)); 48 base::FilePath(base::StringPrintf(kControlPath, kForeground));
47 background_file = 49 background_file =
48 base::FilePath(base::StringPrintf(kControlPath, kBackground)); 50 base::FilePath(base::StringPrintf(kControlPath, kBackground));
49 file_util::FileSystemType foreground_type; 51 base::FileSystemType foreground_type;
50 file_util::FileSystemType background_type; 52 base::FileSystemType background_type;
51 enabled = 53 enabled =
52 file_util::GetFileSystemType(foreground_file, &foreground_type) && 54 base::GetFileSystemType(foreground_file, &foreground_type) &&
53 file_util::GetFileSystemType(background_file, &background_type) && 55 base::GetFileSystemType(background_file, &background_type) &&
54 foreground_type == file_util::FILE_SYSTEM_CGROUP && 56 foreground_type == FILE_SYSTEM_CGROUP &&
55 background_type == file_util::FILE_SYSTEM_CGROUP; 57 background_type == FILE_SYSTEM_CGROUP;
56 } 58 }
57 }; 59 };
58 60
59 base::LazyInstance<CGroups> cgroups = LAZY_INSTANCE_INITIALIZER; 61 base::LazyInstance<CGroups> cgroups = LAZY_INSTANCE_INITIALIZER;
60 #else 62 #else
61 const int kBackgroundPriority = 5; 63 const int kBackgroundPriority = 5;
62 #endif 64 #endif
63 } 65 }
64 66
65 namespace base {
66
67 bool Process::IsProcessBackgrounded() const { 67 bool Process::IsProcessBackgrounded() const {
68 DCHECK(process_); 68 DCHECK(process_);
69 69
70 #if defined(OS_CHROMEOS) 70 #if defined(OS_CHROMEOS)
71 if (cgroups.Get().enabled) { 71 if (cgroups.Get().enabled) {
72 std::string proc; 72 std::string proc;
73 if (base::ReadFileToString( 73 if (base::ReadFileToString(
74 base::FilePath(StringPrintf(kProcPath, process_)), 74 base::FilePath(StringPrintf(kProcPath, process_)),
75 &proc)) { 75 &proc)) {
76 std::vector<std::string> proc_parts; 76 std::vector<std::string> proc_parts;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 if (cgroups.Get().enabled) 128 if (cgroups.Get().enabled)
129 return true; 129 return true;
130 #endif 130 #endif
131 131
132 static LazyInstance<CheckForNicePermission> check_for_nice_permission = 132 static LazyInstance<CheckForNicePermission> check_for_nice_permission =
133 LAZY_INSTANCE_INITIALIZER; 133 LAZY_INSTANCE_INITIALIZER;
134 return check_for_nice_permission.Get().can_reraise_priority; 134 return check_for_nice_permission.Get().can_reraise_priority;
135 } 135 }
136 136
137 } // namespace base 137 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file_path.h ('k') | chrome/browser/download/download_path_reservation_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698