OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/policy/file_based_policy_loader.h" | 5 #include "chrome/browser/policy/file_based_policy_loader.h" |
6 | 6 |
7 namespace { | 7 namespace { |
8 | 8 |
9 // Amount of time we wait for the files on disk to settle before trying to load | 9 // Amount of time we wait for the files on disk to settle before trying to load |
10 // them. This alleviates the problem of reading partially written files and | 10 // them. This alleviates the problem of reading partially written files and |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 const FilePath& path) { | 74 const FilePath& path) { |
75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
76 Reload(); | 76 Reload(); |
77 } | 77 } |
78 | 78 |
79 void FileBasedPolicyLoader::OnError() { | 79 void FileBasedPolicyLoader::OnError() { |
80 LOG(ERROR) << "FilePathWatcher on " << config_file_path().value() | 80 LOG(ERROR) << "FilePathWatcher on " << config_file_path().value() |
81 << " failed."; | 81 << " failed."; |
82 } | 82 } |
83 | 83 |
| 84 FileBasedPolicyLoader::~FileBasedPolicyLoader() {} |
| 85 |
84 void FileBasedPolicyLoader::Reload() { | 86 void FileBasedPolicyLoader::Reload() { |
85 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 87 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
86 | 88 |
87 if (!delegate()) | 89 if (!delegate()) |
88 return; | 90 return; |
89 | 91 |
90 // Check the directory time in order to see whether a reload is required. | 92 // Check the directory time in order to see whether a reload is required. |
91 base::TimeDelta delay; | 93 base::TimeDelta delay; |
92 base::Time now = base::Time::Now(); | 94 base::Time now = base::Time::Now(); |
93 if (!IsSafeToReloadPolicy(now, &delay)) { | 95 if (!IsSafeToReloadPolicy(now, &delay)) { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 base::TimeDelta age = now - last_modification_clock_; | 198 base::TimeDelta age = now - last_modification_clock_; |
197 if (age < settle_interval_) { | 199 if (age < settle_interval_) { |
198 *delay = settle_interval_ - age; | 200 *delay = settle_interval_ - age; |
199 return false; | 201 return false; |
200 } | 202 } |
201 | 203 |
202 return true; | 204 return true; |
203 } | 205 } |
204 | 206 |
205 } // namespace policy | 207 } // namespace policy |
OLD | NEW |