OLD | NEW |
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 // Most of this code is copied from various classes in | 5 // Most of this code is copied from various classes in |
6 // src/chrome/browser/policy. In particular, look at | 6 // src/chrome/browser/policy. In particular, look at |
7 // | 7 // |
8 // file_based_policy_loader.{h,cc} | 8 // file_based_policy_loader.{h,cc} |
9 // config_dir_policy_provider.{h,cc} | 9 // config_dir_policy_provider.{h,cc} |
10 // | 10 // |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 else | 96 else |
97 LOG(ERROR) << "PolicyWatcherLinux on " << path.value() << " failed."; | 97 LOG(ERROR) << "PolicyWatcherLinux on " << path.value() << " failed."; |
98 } | 98 } |
99 | 99 |
100 base::Time GetLastModification() { | 100 base::Time GetLastModification() { |
101 DCHECK(OnPolicyWatcherThread()); | 101 DCHECK(OnPolicyWatcherThread()); |
102 base::Time last_modification = base::Time(); | 102 base::Time last_modification = base::Time(); |
103 base::PlatformFileInfo file_info; | 103 base::PlatformFileInfo file_info; |
104 | 104 |
105 // If the path does not exist or points to a directory, it's safe to load. | 105 // If the path does not exist or points to a directory, it's safe to load. |
106 if (!file_util::GetFileInfo(config_dir_, &file_info) || | 106 if (!base::GetFileInfo(config_dir_, &file_info) || |
107 !file_info.is_directory) { | 107 !file_info.is_directory) { |
108 return last_modification; | 108 return last_modification; |
109 } | 109 } |
110 | 110 |
111 // Enumerate the files and find the most recent modification timestamp. | 111 // Enumerate the files and find the most recent modification timestamp. |
112 base::FileEnumerator file_enumerator(config_dir_, | 112 base::FileEnumerator file_enumerator(config_dir_, |
113 false, | 113 false, |
114 base::FileEnumerator::FILES); | 114 base::FileEnumerator::FILES); |
115 for (base::FilePath config_file = file_enumerator.Next(); | 115 for (base::FilePath config_file = file_enumerator.Next(); |
116 !config_file.empty(); | 116 !config_file.empty(); |
117 config_file = file_enumerator.Next()) { | 117 config_file = file_enumerator.Next()) { |
118 if (file_util::GetFileInfo(config_file, &file_info) && | 118 if (base::GetFileInfo(config_file, &file_info) && |
119 !file_info.is_directory) { | 119 !file_info.is_directory) { |
120 last_modification = std::max(last_modification, | 120 last_modification = std::max(last_modification, |
121 file_info.last_modified); | 121 file_info.last_modified); |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 return last_modification; | 125 return last_modification; |
126 } | 126 } |
127 | 127 |
128 // Returns NULL if the policy dictionary couldn't be read. | 128 // Returns NULL if the policy dictionary couldn't be read. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 }; | 245 }; |
246 | 246 |
247 PolicyWatcher* PolicyWatcher::Create( | 247 PolicyWatcher* PolicyWatcher::Create( |
248 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | 248 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
249 base::FilePath policy_dir(kPolicyDir); | 249 base::FilePath policy_dir(kPolicyDir); |
250 return new PolicyWatcherLinux(task_runner, policy_dir); | 250 return new PolicyWatcherLinux(task_runner, policy_dir); |
251 } | 251 } |
252 | 252 |
253 } // namespace policy_hack | 253 } // namespace policy_hack |
254 } // namespace remoting | 254 } // namespace remoting |
OLD | NEW |