Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
|
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.
| |
| 5 #ifndef REMOTING_HOST_PLUGIN_POLICY_HACK_NAT_POLICY_LINUX_H_ | |
| 6 #define REMOTING_HOST_PLUGIN_POLICY_HACK_NAT_POLICY_LINUX_H_ | |
| 7 | |
| 8 #include "base/file_path.h" | |
| 9 #include "base/file_util.h" | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "base/scoped_ptr.h" | |
| 12 #include "base/time.h" | |
| 13 #include "base/values.h" | |
| 14 #include "remoting/host/plugin/policy_hack/nat_policy.h" | |
| 15 | |
| 16 namespace base { | |
| 17 | |
| 18 class MessageLoopProxy; | |
| 19 class WaitableEvent; | |
| 20 | |
| 21 namespace files { | |
| 22 class FilePathWatcher; | |
| 23 } // namespace base | |
| 24 | |
| 25 } // namespace files | |
| 26 | |
| 27 namespace remoting { | |
| 28 namespace policy_hack { | |
| 29 | |
| 30 class NatPolicyLinux : public NatPolicy { | |
| 31 public: | |
| 32 NatPolicyLinux(const FilePath& config_dir, | |
| 33 const NatPolicy::NatEnabledCallback& nat_enabled_cb); | |
| 34 ~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.
| |
| 35 | |
| 36 virtual void StartWatching() OVERRIDE; | |
| 37 virtual void StopWatching(base::WaitableEvent* done) OVERRIDE; | |
| 38 | |
| 39 // For use by the FileWatcherDelegate. | |
| 40 void OnFilePathError(const FilePath& path); | |
| 41 void OnFilePathChanged(const FilePath& path); | |
| 42 | |
| 43 private: | |
| 44 friend class FileWatcherDelegate; | |
| 45 | |
| 46 void ScheduleFallbackReloadTask(); | |
| 47 void ScheduleReloadTask(const base::TimeDelta& delay); | |
| 48 void Reload(); | |
| 49 bool IsSafeToReloadPolicy(const base::Time& now, base::TimeDelta* delay); | |
| 50 base::Time GetLastModification(); | |
| 51 | |
| 52 // Caller owns the value. | |
| 53 DictionaryValue* Load(); | |
| 54 | |
| 55 // Managed with a scoped_ptr rather than being declared as an inline member to | |
| 56 // decouple the watcher's life cycle from the loader's. This decoupling makes | |
| 57 // it possible to destroy the watcher before the loader's destructor is called | |
| 58 // (e.g. during Stop), since |watcher_| internally holds a reference to the | |
| 59 // loader and keeps it alive. | |
| 60 scoped_ptr<base::files::FilePathWatcher> watcher_; | |
| 61 | |
| 62 // Records last known modification timestamp of |config_file_path_|. | |
| 63 base::Time last_modification_file_; | |
| 64 | |
| 65 // The wall clock time at which the last modification timestamp was | |
| 66 // recorded. It's better to not assume the file notification time and the | |
| 67 // wall clock times come from the same source, just in case there is some | |
| 68 // non-local filesystem involved. | |
| 69 base::Time last_modification_clock_; | |
| 70 | |
| 71 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | |
| 72 const FilePath config_dir_; | |
| 73 NatEnabledCallback nat_enabled_cb_; | |
| 74 | |
| 75 bool current_nat_enabled_state_; | |
| 76 bool first_state_published_; | |
| 77 | |
| 78 base::WeakPtrFactory<NatPolicyLinux> weak_factory_; | |
| 79 }; | |
| 80 | |
| 81 } // namespace policy_hack | |
| 82 } // namespace remoting | |
| 83 | |
| 84 #endif // REMOTING_HOST_PLUGIN_POLICY_HACK_NAT_POLICY_LINUX_H_ | |
| OLD | NEW |