Index: remoting/host/plugin/policy_hack/nat_policy_linux.h |
diff --git a/remoting/host/plugin/policy_hack/nat_policy_linux.h b/remoting/host/plugin/policy_hack/nat_policy_linux.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bc4302d758d519f3f247923233721bf1aae1665e |
--- /dev/null |
+++ b/remoting/host/plugin/policy_hack/nat_policy_linux.h |
@@ -0,0 +1,84 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
dmac
2011/08/10 21:39:00
why do we have a header for this as opposed to put
awong
2011/08/11 01:23:29
hmm...good point. collapsed.
|
+#ifndef REMOTING_HOST_PLUGIN_POLICY_HACK_NAT_POLICY_LINUX_H_ |
+#define REMOTING_HOST_PLUGIN_POLICY_HACK_NAT_POLICY_LINUX_H_ |
+ |
+#include "base/file_path.h" |
+#include "base/file_util.h" |
+#include "base/memory/weak_ptr.h" |
+#include "base/scoped_ptr.h" |
+#include "base/time.h" |
+#include "base/values.h" |
+#include "remoting/host/plugin/policy_hack/nat_policy.h" |
+ |
+namespace base { |
+ |
+class MessageLoopProxy; |
+class WaitableEvent; |
+ |
+namespace files { |
+class FilePathWatcher; |
+} // namespace base |
+ |
+} // namespace files |
+ |
+namespace remoting { |
+namespace policy_hack { |
+ |
+class NatPolicyLinux : public NatPolicy { |
+ public: |
+ NatPolicyLinux(const FilePath& config_dir, |
+ const NatPolicy::NatEnabledCallback& nat_enabled_cb); |
+ ~NatPolicyLinux(); |
dmac
2011/08/10 21:39:00
I know you get this virtual by default (having inh
awong
2011/08/11 01:23:29
Yes. Good catch. Fixed.
|
+ |
+ virtual void StartWatching() OVERRIDE; |
+ virtual void StopWatching(base::WaitableEvent* done) OVERRIDE; |
+ |
+ // For use by the FileWatcherDelegate. |
+ void OnFilePathError(const FilePath& path); |
+ void OnFilePathChanged(const FilePath& path); |
+ |
+ private: |
+ friend class FileWatcherDelegate; |
+ |
+ void ScheduleFallbackReloadTask(); |
+ void ScheduleReloadTask(const base::TimeDelta& delay); |
+ void Reload(); |
+ bool IsSafeToReloadPolicy(const base::Time& now, base::TimeDelta* delay); |
+ base::Time GetLastModification(); |
+ |
+ // Caller owns the value. |
+ DictionaryValue* Load(); |
+ |
+ // Managed with a scoped_ptr rather than being declared as an inline member to |
+ // decouple the watcher's life cycle from the loader's. This decoupling makes |
+ // it possible to destroy the watcher before the loader's destructor is called |
+ // (e.g. during Stop), since |watcher_| internally holds a reference to the |
+ // loader and keeps it alive. |
+ scoped_ptr<base::files::FilePathWatcher> watcher_; |
+ |
+ // Records last known modification timestamp of |config_file_path_|. |
+ base::Time last_modification_file_; |
+ |
+ // The wall clock time at which the last modification timestamp was |
+ // recorded. It's better to not assume the file notification time and the |
+ // wall clock times come from the same source, just in case there is some |
+ // non-local filesystem involved. |
+ base::Time last_modification_clock_; |
+ |
+ scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
+ const FilePath config_dir_; |
+ NatEnabledCallback nat_enabled_cb_; |
+ |
+ bool current_nat_enabled_state_; |
+ bool first_state_published_; |
+ |
+ base::WeakPtrFactory<NatPolicyLinux> weak_factory_; |
+}; |
+ |
+} // namespace policy_hack |
+} // namespace remoting |
+ |
+#endif // REMOTING_HOST_PLUGIN_POLICY_HACK_NAT_POLICY_LINUX_H_ |