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

Side by Side Diff: net/dns/file_path_watcher_wrapper.h

Issue 9721002: [net/dns] Removes locking from DnsConfigServiceWin and adds local computer name. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Move lowercasing to ServeFromHosts, add test. Reorganize OnHostsRead. Created 8 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
« no previous file with comments | « net/dns/dns_hosts_unittest.cc ('k') | net/dns/serial_worker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef NET_FILE_PATH_WATCHER_CALLBACK_H_ 5 #ifndef NET_FILE_PATH_WATCHER_CALLBACK_H_
6 #define NET_FILE_PATH_WATCHER_WRAPPER_H_ 6 #define NET_FILE_PATH_WATCHER_WRAPPER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 16 matching lines...) Expand all
27 // Convenience wrapper which holds a FilePathWatcher and a 27 // Convenience wrapper which holds a FilePathWatcher and a
28 // FilePathWatcher::Delegate which forwards its calls to a Callback. 28 // FilePathWatcher::Delegate which forwards its calls to a Callback.
29 class NET_EXPORT FilePathWatcherWrapper 29 class NET_EXPORT FilePathWatcherWrapper
30 : NON_EXPORTED_BASE(public base::NonThreadSafe) { 30 : NON_EXPORTED_BASE(public base::NonThreadSafe) {
31 public: 31 public:
32 FilePathWatcherWrapper(); 32 FilePathWatcherWrapper();
33 // When deleted, automatically cancels the FilePathWatcher. 33 // When deleted, automatically cancels the FilePathWatcher.
34 virtual ~FilePathWatcherWrapper(); 34 virtual ~FilePathWatcherWrapper();
35 35
36 // Starts watching the file at |path|. Returns true if Watch succeeds. 36 // Starts watching the file at |path|. Returns true if Watch succeeds.
37 // If so, the delegate will call callback.Run(true) from OnFilePathChanged and 37 // If so, |callback| will be called with true on change and false on error.
38 // callback.Run(false) from OnFilePathError. After failure the watch is 38 // After failure the watch is cancelled and will have to be restarted.
39 // cancelled and will have to be restarted. If called again, the previous
40 // watch is cancelled.
41 bool Watch(const FilePath& path, 39 bool Watch(const FilePath& path,
42 const base::Callback<void(bool succeeded)>& callback); 40 const base::Callback<void(bool succeeded)>& callback);
43 41
44 bool IsWatching() const; 42 bool IsWatching() const;
45 43
46 // Cancels the current watch. 44 // Cancels the current watch.
47 void Cancel(); 45 void Cancel();
48 46
49 protected: 47 protected:
50 // Creates a FilePathWatcher. Override to provide a different implementation. 48 // Creates a FilePathWatcher. Override to provide a different implementation.
51 virtual scoped_ptr<base::files::FilePathWatcher> CreateFilePathWatcher(); 49 virtual scoped_ptr<base::files::FilePathWatcher> CreateFilePathWatcher();
52 50
53 private: 51 private:
54 class WatcherDelegate; 52 class WatcherDelegate;
55 53
56 void OnFilePathChanged(); 54 void OnFilePathChanged();
57 void OnFilePathError(); 55 void OnFilePathError();
58 56
59 base::Callback<void(bool succeeded)> callback_; 57 base::Callback<void(bool succeeded)> callback_;
60 scoped_ptr<base::files::FilePathWatcher> watcher_; 58 scoped_ptr<base::files::FilePathWatcher> watcher_;
61 scoped_refptr<WatcherDelegate> delegate_; 59 scoped_refptr<WatcherDelegate> delegate_;
62 DISALLOW_COPY_AND_ASSIGN(FilePathWatcherWrapper); 60 DISALLOW_COPY_AND_ASSIGN(FilePathWatcherWrapper);
63 }; 61 };
64 62
65 } // namespace net 63 } // namespace net
66 64
67 #endif // NET_FILE_PATH_WATCHER_CALLBACK_H_ 65 #endif // NET_FILE_PATH_WATCHER_CALLBACK_H_
68 66
OLDNEW
« no previous file with comments | « net/dns/dns_hosts_unittest.cc ('k') | net/dns/serial_worker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698