| 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 #include "chrome/browser/policy/file_based_policy_loader.h" | 5 #include "chrome/browser/policy/file_based_policy_loader.h" |
| 6 | 6 |
| 7 #include "base/files/file_path_watcher.h" | 7 #include "base/files/file_path_watcher.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "chrome/browser/policy/policy_map.h" | 9 #include "chrome/browser/policy/policy_map.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 settle_interval_(base::TimeDelta::FromSeconds(kSettleIntervalSeconds)) { | 35 settle_interval_(base::TimeDelta::FromSeconds(kSettleIntervalSeconds)) { |
| 36 } | 36 } |
| 37 | 37 |
| 38 FileBasedPolicyLoader::~FileBasedPolicyLoader() {} | 38 FileBasedPolicyLoader::~FileBasedPolicyLoader() {} |
| 39 | 39 |
| 40 class FileBasedPolicyWatcherDelegate : public FilePathWatcher::Delegate { | 40 class FileBasedPolicyWatcherDelegate : public FilePathWatcher::Delegate { |
| 41 public: | 41 public: |
| 42 explicit FileBasedPolicyWatcherDelegate( | 42 explicit FileBasedPolicyWatcherDelegate( |
| 43 scoped_refptr<FileBasedPolicyLoader> loader) | 43 scoped_refptr<FileBasedPolicyLoader> loader) |
| 44 : loader_(loader) {} | 44 : loader_(loader) {} |
| 45 virtual ~FileBasedPolicyWatcherDelegate() {} | |
| 46 | 45 |
| 47 // FilePathWatcher::Delegate implementation: | 46 // FilePathWatcher::Delegate implementation: |
| 48 virtual void OnFilePathChanged(const FilePath& path) OVERRIDE { | 47 virtual void OnFilePathChanged(const FilePath& path) OVERRIDE { |
| 49 loader_->OnFilePathChanged(path); | 48 loader_->OnFilePathChanged(path); |
| 50 } | 49 } |
| 51 | 50 |
| 52 virtual void OnFilePathError(const FilePath& path) OVERRIDE { | 51 virtual void OnFilePathError(const FilePath& path) OVERRIDE { |
| 53 loader_->OnFilePathError(path); | 52 loader_->OnFilePathError(path); |
| 54 } | 53 } |
| 55 | 54 |
| 56 private: | 55 private: |
| 56 virtual ~FileBasedPolicyWatcherDelegate() {} |
| 57 |
| 57 scoped_refptr<FileBasedPolicyLoader> loader_; | 58 scoped_refptr<FileBasedPolicyLoader> loader_; |
| 58 DISALLOW_COPY_AND_ASSIGN(FileBasedPolicyWatcherDelegate); | 59 DISALLOW_COPY_AND_ASSIGN(FileBasedPolicyWatcherDelegate); |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 void FileBasedPolicyLoader::OnFilePathChanged( | 62 void FileBasedPolicyLoader::OnFilePathChanged( |
| 62 const FilePath& path) { | 63 const FilePath& path) { |
| 63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 64 Reload(false); | 65 Reload(false); |
| 65 } | 66 } |
| 66 | 67 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 base::TimeDelta age = now - last_modification_clock_; | 146 base::TimeDelta age = now - last_modification_clock_; |
| 146 if (age < settle_interval_) { | 147 if (age < settle_interval_) { |
| 147 *delay = settle_interval_ - age; | 148 *delay = settle_interval_ - age; |
| 148 return false; | 149 return false; |
| 149 } | 150 } |
| 150 | 151 |
| 151 return true; | 152 return true; |
| 152 } | 153 } |
| 153 | 154 |
| 154 } // namespace policy | 155 } // namespace policy |
| OLD | NEW |