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

Side by Side Diff: net/base/file_path_watcher_callback.h

Issue 9540011: [net] Add DNS-related signals and NetLog to NetworkChangeNotifier. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved DNS watch to a separate IO thread on mac. 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | net/base/file_path_watcher_callback.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef NET_FILE_PATH_WATCHER_CALLBACK_H_
6 #define NET_FILE_PATH_WATCHER_CALLBACK_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/file_path.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/threading/non_thread_safe.h"
17
18 namespace base {
19 namespace files {
20 class FilePathWatcher;
21 }
22 }
23
24 namespace net {
25
26 // Convenience wrapper which holds a FilePathWatcher and a
27 // FilePathWatcher::Delegate which forwards its calls to a Callback.
28 class FilePathWatcherCallback : public base::NonThreadSafe {
29 public:
30 FilePathWatcherCallback();
31 // When deleted, automatically cancels the FilePathWatcher.
32 virtual ~FilePathWatcherCallback();
33
34 // Starts watching the file at |path|. Returns true if Watch succeeds.
35 // If so, the delegate will call callback.Run(true) from OnFilePathChanged and
36 // callback.Run(false) from OnFilePathError. After failure the watch is
37 // cancelled and will have to be restarted. If called again, the previous
38 // watch is cancelled.
39 bool Watch(const FilePath& path,
40 const base::Callback<void(bool succeeded)>& callback);
41
42 // Cancels the current watch.
43 void Cancel();
44
45 private:
46 class WatcherDelegate;
47
48 void OnFilePathChanged();
49 void OnFilePathError();
50
51 base::Callback<void(bool succeeded)> callback_;
52 scoped_ptr<base::files::FilePathWatcher> watcher_;
53 scoped_refptr<WatcherDelegate> delegate_;
54 DISALLOW_COPY_AND_ASSIGN(FilePathWatcherCallback);
55 };
56
57 } // namespace net
58
59 #endif // NET_FILE_PATH_WATCHER_CALLBACK_H_
60
OLDNEW
« no previous file with comments | « no previous file | net/base/file_path_watcher_callback.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698