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

Side by Side Diff: base/files/file_path_watcher_win.cc

Issue 8677015: base::Bind: Convert FilePathWatcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 #include "base/files/file_path_watcher.h" 5 #include "base/files/file_path_watcher.h"
6 6
7 #include "base/bind.h"
7 #include "base/file_path.h" 8 #include "base/file_path.h"
8 #include "base/file_util.h" 9 #include "base/file_util.h"
9 #include "base/logging.h" 10 #include "base/logging.h"
10 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
11 #include "base/message_loop_proxy.h" 12 #include "base/message_loop_proxy.h"
12 #include "base/time.h" 13 #include "base/time.h"
13 #include "base/win/object_watcher.h" 14 #include "base/win/object_watcher.h"
14 15
15 namespace base { 16 namespace base {
16 namespace files { 17 namespace files {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 void FilePathWatcherImpl::Cancel() { 98 void FilePathWatcherImpl::Cancel() {
98 if (!delegate_) { 99 if (!delegate_) {
99 // Watch was never called, or the |message_loop_| has already quit. 100 // Watch was never called, or the |message_loop_| has already quit.
100 set_cancelled(); 101 set_cancelled();
101 return; 102 return;
102 } 103 }
103 104
104 // Switch to the file thread if necessary so we can stop |watcher_|. 105 // Switch to the file thread if necessary so we can stop |watcher_|.
105 if (!message_loop()->BelongsToCurrentThread()) { 106 if (!message_loop()->BelongsToCurrentThread()) {
106 message_loop()->PostTask(FROM_HERE, 107 message_loop()->PostTask(FROM_HERE,
107 new FilePathWatcher::CancelTask(this)); 108 base::Bind(&FilePathWatcher::CancelWatch,
109 make_scoped_refptr(this)));
108 } else { 110 } else {
109 CancelOnMessageLoopThread(); 111 CancelOnMessageLoopThread();
110 } 112 }
111 } 113 }
112 114
113 void FilePathWatcherImpl::CancelOnMessageLoopThread() { 115 void FilePathWatcherImpl::CancelOnMessageLoopThread() {
114 set_cancelled(); 116 set_cancelled();
115 117
116 if (handle_ != INVALID_HANDLE_VALUE) 118 if (handle_ != INVALID_HANDLE_VALUE)
117 DestroyWatch(); 119 DestroyWatch();
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 } 274 }
273 275
274 } // namespace 276 } // namespace
275 277
276 FilePathWatcher::FilePathWatcher() { 278 FilePathWatcher::FilePathWatcher() {
277 impl_ = new FilePathWatcherImpl(); 279 impl_ = new FilePathWatcherImpl();
278 } 280 }
279 281
280 } // namespace files 282 } // namespace files
281 } // namespace base 283 } // namespace base
OLDNEW
« base/files/file_path_watcher.h ('K') | « base/files/file_path_watcher_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698