Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(560)

Side by Side Diff: chrome/browser/policy/file_based_policy_loader.cc

Issue 6793020: Move FilePathWatcher to base/files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move OWNERS file and rebase to pick up latest changes Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/policy/file_based_policy_loader.h" 5 #include "chrome/browser/policy/file_based_policy_loader.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "content/browser/browser_thread.h" 8 #include "content/browser/browser_thread.h"
9 9
10 namespace { 10 namespace {
(...skipping 14 matching lines...) Expand all
25 FileBasedPolicyLoader::FileBasedPolicyLoader( 25 FileBasedPolicyLoader::FileBasedPolicyLoader(
26 FileBasedPolicyProvider::ProviderDelegate* provider_delegate) 26 FileBasedPolicyProvider::ProviderDelegate* provider_delegate)
27 : AsynchronousPolicyLoader(provider_delegate, 27 : AsynchronousPolicyLoader(provider_delegate,
28 kReloadIntervalMinutes), 28 kReloadIntervalMinutes),
29 config_file_path_(provider_delegate->config_file_path()), 29 config_file_path_(provider_delegate->config_file_path()),
30 settle_interval_(base::TimeDelta::FromSeconds(kSettleIntervalSeconds)) { 30 settle_interval_(base::TimeDelta::FromSeconds(kSettleIntervalSeconds)) {
31 } 31 }
32 32
33 FileBasedPolicyLoader::~FileBasedPolicyLoader() {} 33 FileBasedPolicyLoader::~FileBasedPolicyLoader() {}
34 34
35 class FileBasedPolicyWatcherDelegate : public FilePathWatcher::Delegate { 35 class FileBasedPolicyWatcherDelegate
36 : public base::files::FilePathWatcher::Delegate {
36 public: 37 public:
37 explicit FileBasedPolicyWatcherDelegate( 38 explicit FileBasedPolicyWatcherDelegate(
38 scoped_refptr<FileBasedPolicyLoader> loader) 39 scoped_refptr<FileBasedPolicyLoader> loader)
39 : loader_(loader) {} 40 : loader_(loader) {}
40 virtual ~FileBasedPolicyWatcherDelegate() {} 41 virtual ~FileBasedPolicyWatcherDelegate() {}
41 42
42 // FilePathWatcher::Delegate implementation: 43 // FilePathWatcher::Delegate implementation:
43 virtual void OnFilePathChanged(const FilePath& path) OVERRIDE { 44 virtual void OnFilePathChanged(const FilePath& path) OVERRIDE {
44 loader_->OnFilePathChanged(path); 45 loader_->OnFilePathChanged(path);
45 } 46 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 return; 88 return;
88 } 89 }
89 90
90 PostUpdatePolicyTask(new_policy.release()); 91 PostUpdatePolicyTask(new_policy.release());
91 92
92 ScheduleFallbackReloadTask(); 93 ScheduleFallbackReloadTask();
93 } 94 }
94 95
95 void FileBasedPolicyLoader::InitOnFileThread() { 96 void FileBasedPolicyLoader::InitOnFileThread() {
96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
97 watcher_.reset(new FilePathWatcher); 98 watcher_.reset(new base::files::FilePathWatcher);
98 const FilePath& path = config_file_path(); 99 const FilePath& path = config_file_path();
99 if (!path.empty() && 100 if (!path.empty() &&
100 !watcher_->Watch(path, new FileBasedPolicyWatcherDelegate(this))) { 101 !watcher_->Watch(path, new FileBasedPolicyWatcherDelegate(this))) {
101 OnFilePathError(path); 102 OnFilePathError(path);
102 } 103 }
103 104
104 // There might have been changes to the directory in the time between 105 // There might have been changes to the directory in the time between
105 // construction of the loader and initialization of the watcher. Call reload 106 // construction of the loader and initialization of the watcher. Call reload
106 // to detect if that is the case. 107 // to detect if that is the case.
107 Reload(); 108 Reload();
(...skipping 30 matching lines...) Expand all
138 base::TimeDelta age = now - last_modification_clock_; 139 base::TimeDelta age = now - last_modification_clock_;
139 if (age < settle_interval_) { 140 if (age < settle_interval_) {
140 *delay = settle_interval_ - age; 141 *delay = settle_interval_ - age;
141 return false; 142 return false;
142 } 143 }
143 144
144 return true; 145 return true;
145 } 146 }
146 147
147 } // namespace policy 148 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698