OLD | NEW |
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 #ifndef CHROME_BROWSER_POLICY_FILE_BASED_POLICY_LOADER_H_ | 5 #ifndef CHROME_BROWSER_POLICY_FILE_BASED_POLICY_LOADER_H_ |
6 #define CHROME_BROWSER_POLICY_FILE_BASED_POLICY_LOADER_H_ | 6 #define CHROME_BROWSER_POLICY_FILE_BASED_POLICY_LOADER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include "base/files/file_path_watcher.h" |
9 #include "chrome/browser/policy/asynchronous_policy_loader.h" | 10 #include "chrome/browser/policy/asynchronous_policy_loader.h" |
10 #include "chrome/browser/policy/file_based_policy_provider.h" | 11 #include "chrome/browser/policy/file_based_policy_provider.h" |
11 #include "content/common/file_path_watcher/file_path_watcher.h" | |
12 | 12 |
13 namespace policy { | 13 namespace policy { |
14 | 14 |
15 // A customized asynchronous policy loader that handles loading policy from a | 15 // A customized asynchronous policy loader that handles loading policy from a |
16 // file using a FilePathWatcher. The loader creates a fallback task to load | 16 // file using a FilePathWatcher. The loader creates a fallback task to load |
17 // policy periodically in case the watcher fails and retries policy loads when | 17 // policy periodically in case the watcher fails and retries policy loads when |
18 // the watched file is in flux. | 18 // the watched file is in flux. |
19 class FileBasedPolicyLoader : public AsynchronousPolicyLoader { | 19 class FileBasedPolicyLoader : public AsynchronousPolicyLoader { |
20 public: | 20 public: |
21 FileBasedPolicyLoader( | 21 FileBasedPolicyLoader( |
(...skipping 27 matching lines...) Expand all Loading... |
49 bool IsSafeToReloadPolicy(const base::Time& now, base::TimeDelta* delay); | 49 bool IsSafeToReloadPolicy(const base::Time& now, base::TimeDelta* delay); |
50 | 50 |
51 // The path at which we look for configuration files. | 51 // The path at which we look for configuration files. |
52 const FilePath config_file_path_; | 52 const FilePath config_file_path_; |
53 | 53 |
54 // Managed with a scoped_ptr rather than being declared as an inline member to | 54 // Managed with a scoped_ptr rather than being declared as an inline member to |
55 // decouple the watcher's life cycle from the loader's. This decoupling makes | 55 // decouple the watcher's life cycle from the loader's. This decoupling makes |
56 // it possible to destroy the watcher before the loader's destructor is called | 56 // it possible to destroy the watcher before the loader's destructor is called |
57 // (e.g. during Stop), since |watcher_| internally holds a reference to the | 57 // (e.g. during Stop), since |watcher_| internally holds a reference to the |
58 // loader and keeps it alive. | 58 // loader and keeps it alive. |
59 scoped_ptr<FilePathWatcher> watcher_; | 59 scoped_ptr<base::files::FilePathWatcher> watcher_; |
60 | 60 |
61 // Settle interval. | 61 // Settle interval. |
62 const base::TimeDelta settle_interval_; | 62 const base::TimeDelta settle_interval_; |
63 | 63 |
64 // Records last known modification timestamp of |config_file_path_|. | 64 // Records last known modification timestamp of |config_file_path_|. |
65 base::Time last_modification_file_; | 65 base::Time last_modification_file_; |
66 | 66 |
67 // The wall clock time at which the last modification timestamp was | 67 // The wall clock time at which the last modification timestamp was |
68 // recorded. It's better to not assume the file notification time and the | 68 // recorded. It's better to not assume the file notification time and the |
69 // wall clock times come from the same source, just in case there is some | 69 // wall clock times come from the same source, just in case there is some |
70 // non-local filesystem involved. | 70 // non-local filesystem involved. |
71 base::Time last_modification_clock_; | 71 base::Time last_modification_clock_; |
72 | 72 |
73 DISALLOW_COPY_AND_ASSIGN(FileBasedPolicyLoader); | 73 DISALLOW_COPY_AND_ASSIGN(FileBasedPolicyLoader); |
74 }; | 74 }; |
75 | 75 |
76 } // namespace policy | 76 } // namespace policy |
77 | 77 |
78 #endif // CHROME_BROWSER_POLICY_FILE_BASED_POLICY_LOADER_H_ | 78 #endif // CHROME_BROWSER_POLICY_FILE_BASED_POLICY_LOADER_H_ |
OLD | NEW |