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

Unified Diff: remoting/host/plugin/policy_hack/nat_policy_linux.h

Issue 7599017: Framework to allow Chromoting host to respect NAT traversal policy in linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: silly compiler. Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698