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 "base/compiler_specific.h" |
10 #include "base/file_path.h" | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/time.h" | |
10 #include "chrome/browser/policy/asynchronous_policy_loader.h" | 13 #include "chrome/browser/policy/asynchronous_policy_loader.h" |
11 #include "chrome/browser/policy/file_based_policy_provider.h" | 14 #include "chrome/browser/policy/file_based_policy_provider.h" |
12 | 15 |
16 namespace base { | |
17 namespace files { | |
18 class FilePathWatcher; | |
pastarmovj
2011/09/20 13:14:08
To be consistent with the rest why don't you put a
Joao da Silva
2011/09/20 18:51:17
Done.
| |
19 } // namespace files | |
20 } // namespace base | |
21 | |
13 namespace policy { | 22 namespace policy { |
14 | 23 |
15 // A customized asynchronous policy loader that handles loading policy from a | 24 // A customized asynchronous policy loader that handles loading policy from a |
16 // file using a FilePathWatcher. The loader creates a fallback task to load | 25 // 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 | 26 // policy periodically in case the watcher fails and retries policy loads when |
18 // the watched file is in flux. | 27 // the watched file is in flux. |
19 class FileBasedPolicyLoader : public AsynchronousPolicyLoader { | 28 class FileBasedPolicyLoader : public AsynchronousPolicyLoader { |
20 public: | 29 public: |
21 FileBasedPolicyLoader( | 30 explicit FileBasedPolicyLoader( |
22 FileBasedPolicyProvider::ProviderDelegate* provider_delegate); | 31 FileBasedPolicyProvider::ProviderDelegate* provider_delegate); |
23 | 32 |
24 // AsynchronousPolicyLoader overrides: | 33 // AsynchronousPolicyLoader overrides: |
25 virtual void Reload(); | 34 virtual void Reload() OVERRIDE; |
26 | 35 |
27 void OnFilePathChanged(const FilePath& path); | 36 void OnFilePathChanged(const FilePath& path); |
28 void OnFilePathError(const FilePath& path); | 37 void OnFilePathError(const FilePath& path); |
29 | 38 |
30 protected: | 39 protected: |
31 // FileBasedPolicyLoader objects should only be deleted by | 40 // FileBasedPolicyLoader objects should only be deleted by |
32 // RefCountedThreadSafe. | 41 // RefCountedThreadSafe. |
33 friend class base::RefCountedThreadSafe<AsynchronousPolicyLoader>; | 42 friend class base::RefCountedThreadSafe<AsynchronousPolicyLoader>; |
34 virtual ~FileBasedPolicyLoader(); | 43 virtual ~FileBasedPolicyLoader(); |
35 | 44 |
36 const FilePath& config_file_path() { return config_file_path_; } | 45 const FilePath& config_file_path() { return config_file_path_; } |
37 | 46 |
38 // AsynchronousPolicyLoader overrides: | 47 // AsynchronousPolicyLoader overrides: |
39 | 48 |
40 // Creates the file path watcher and configures it to watch | 49 // Creates the file path watcher and configures it to watch |
41 // |config_file_path_|. Must be called on the file thread. | 50 // |config_file_path_|. Must be called on the file thread. |
42 virtual void InitOnFileThread(); | 51 virtual void InitOnFileThread() OVERRIDE; |
43 virtual void StopOnFileThread(); | 52 virtual void StopOnFileThread() OVERRIDE; |
44 | 53 |
45 private: | 54 private: |
46 // Checks whether policy information is safe to read. If not, returns false | 55 // Checks whether policy information is safe to read. If not, returns false |
47 // and then delays until it is considered safe to reload in |delay|. | 56 // and then delays until it is considered safe to reload in |delay|. |
48 // Must be called on the file thread. | 57 // Must be called on the file thread. |
49 bool IsSafeToReloadPolicy(const base::Time& now, base::TimeDelta* delay); | 58 bool IsSafeToReloadPolicy(const base::Time& now, base::TimeDelta* delay); |
50 | 59 |
51 // The path at which we look for configuration files. | 60 // The path at which we look for configuration files. |
52 const FilePath config_file_path_; | 61 const FilePath config_file_path_; |
53 | 62 |
(...skipping 15 matching lines...) Expand all Loading... | |
69 // wall clock times come from the same source, just in case there is some | 78 // wall clock times come from the same source, just in case there is some |
70 // non-local filesystem involved. | 79 // non-local filesystem involved. |
71 base::Time last_modification_clock_; | 80 base::Time last_modification_clock_; |
72 | 81 |
73 DISALLOW_COPY_AND_ASSIGN(FileBasedPolicyLoader); | 82 DISALLOW_COPY_AND_ASSIGN(FileBasedPolicyLoader); |
74 }; | 83 }; |
75 | 84 |
76 } // namespace policy | 85 } // namespace policy |
77 | 86 |
78 #endif // CHROME_BROWSER_POLICY_FILE_BASED_POLICY_LOADER_H_ | 87 #endif // CHROME_BROWSER_POLICY_FILE_BASED_POLICY_LOADER_H_ |
OLD | NEW |