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

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

Issue 6670081: Move FilePathWatcher class from browser/... to common/... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix up linux clang issue, and clean up bad commented block Created 9 years, 9 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) 2010 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 "content/browser/browser_thread.h"
8
7 namespace { 9 namespace {
8 10
9 // Amount of time we wait for the files on disk to settle before trying to load 11 // 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 12 // them. This alleviates the problem of reading partially written files and
11 // makes it possible to batch quasi-simultaneous changes. 13 // makes it possible to batch quasi-simultaneous changes.
12 const int kSettleIntervalSeconds = 5; 14 const int kSettleIntervalSeconds = 5;
13 15
14 // The time interval for rechecking policy. This is our fallback in case the 16 // The time interval for rechecking policy. This is our fallback in case the
15 // delegate never reports a change to the ReloadObserver. 17 // delegate never reports a change to the ReloadObserver.
16 const int kReloadIntervalMinutes = 15; 18 const int kReloadIntervalMinutes = 15;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 88
87 PostUpdatePolicyTask(new_policy.release()); 89 PostUpdatePolicyTask(new_policy.release());
88 90
89 ScheduleFallbackReloadTask(); 91 ScheduleFallbackReloadTask();
90 } 92 }
91 93
92 void FileBasedPolicyLoader::InitOnFileThread() { 94 void FileBasedPolicyLoader::InitOnFileThread() {
93 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
94 watcher_.reset(new FilePathWatcher); 96 watcher_.reset(new FilePathWatcher);
95 if (!config_file_path().empty() && 97 if (!config_file_path().empty() &&
96 !watcher_->Watch(config_file_path(), 98 !watcher_->Watch(
97 new FileBasedPolicyWatcherDelegate(this))) { 99 config_file_path(),
100 new FileBasedPolicyWatcherDelegate(this),
101 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI))) {
98 OnError(); 102 OnError();
99 } 103 }
100 104
101 // 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
102 // construction of the loader and initialization of the watcher. Call reload 106 // construction of the loader and initialization of the watcher. Call reload
103 // to detect if that is the case. 107 // to detect if that is the case.
104 Reload(); 108 Reload();
105 109
106 ScheduleFallbackReloadTask(); 110 ScheduleFallbackReloadTask();
107 } 111 }
(...skipping 27 matching lines...) Expand all
135 base::TimeDelta age = now - last_modification_clock_; 139 base::TimeDelta age = now - last_modification_clock_;
136 if (age < settle_interval_) { 140 if (age < settle_interval_) {
137 *delay = settle_interval_ - age; 141 *delay = settle_interval_ - age;
138 return false; 142 return false;
139 } 143 }
140 144
141 return true; 145 return true;
142 } 146 }
143 147
144 } // namespace policy 148 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/file_based_policy_loader.h ('k') | chrome/browser/user_style_sheet_watcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698