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

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

Issue 2372513005: Remove FilePathWatcher::PlatformDelegate::CancelOnMessageLoopThread(). (Closed)
Patch Set: self-review Created 4 years, 2 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 | « base/files/file_path_watcher_stub.cc ('k') | no next file » | 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) 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/bind.h"
8 #include "base/files/file.h" 8 #include "base/files/file.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 bool recursive, 52 bool recursive,
53 HANDLE* handle) WARN_UNUSED_RESULT; 53 HANDLE* handle) WARN_UNUSED_RESULT;
54 54
55 // (Re-)Initialize the watch handle. 55 // (Re-)Initialize the watch handle.
56 bool UpdateWatch() WARN_UNUSED_RESULT; 56 bool UpdateWatch() WARN_UNUSED_RESULT;
57 57
58 // Destroy the watch handle. 58 // Destroy the watch handle.
59 void DestroyWatch(); 59 void DestroyWatch();
60 60
61 // Cleans up and stops observing the |task_runner_| thread. 61 // Cleans up and stops observing the |task_runner_| thread.
62 void CancelOnMessageLoopThread() override; 62 void CancelOnMessageLoopThread();
63 63
64 // Callback to notify upon changes. 64 // Callback to notify upon changes.
65 FilePathWatcher::Callback callback_; 65 FilePathWatcher::Callback callback_;
66 66
67 // Path we're supposed to watch (passed to callback). 67 // Path we're supposed to watch (passed to callback).
68 FilePath target_; 68 FilePath target_;
69 69
70 // Handle for FindFirstChangeNotification. 70 // Handle for FindFirstChangeNotification.
71 HANDLE handle_; 71 HANDLE handle_;
72 72
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 void FilePathWatcherImpl::Cancel() { 115 void FilePathWatcherImpl::Cancel() {
116 if (callback_.is_null()) { 116 if (callback_.is_null()) {
117 // Watch was never called, or the |task_runner_| has already quit. 117 // Watch was never called, or the |task_runner_| has already quit.
118 set_cancelled(); 118 set_cancelled();
119 return; 119 return;
120 } 120 }
121 121
122 // Switch to the file thread if necessary so we can stop |watcher_|. 122 // Switch to the file thread if necessary so we can stop |watcher_|.
123 if (!task_runner()->BelongsToCurrentThread()) { 123 if (!task_runner()->BelongsToCurrentThread()) {
124 task_runner()->PostTask(FROM_HERE, Bind(&FilePathWatcher::CancelWatch, 124 task_runner()->PostTask(
125 make_scoped_refptr(this))); 125 FROM_HERE, Bind(&FilePathWatcherImpl::CancelOnMessageLoopThread, this));
126 } else { 126 } else {
127 CancelOnMessageLoopThread(); 127 CancelOnMessageLoopThread();
128 } 128 }
129 } 129 }
130 130
131 void FilePathWatcherImpl::CancelOnMessageLoopThread() { 131 void FilePathWatcherImpl::CancelOnMessageLoopThread() {
132 DCHECK(task_runner()->BelongsToCurrentThread()); 132 DCHECK(task_runner()->BelongsToCurrentThread());
133 set_cancelled(); 133 set_cancelled();
134 134
135 if (handle_ != INVALID_HANDLE_VALUE) 135 if (handle_ != INVALID_HANDLE_VALUE)
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 handle_ = INVALID_HANDLE_VALUE; 292 handle_ = INVALID_HANDLE_VALUE;
293 } 293 }
294 294
295 } // namespace 295 } // namespace
296 296
297 FilePathWatcher::FilePathWatcher() { 297 FilePathWatcher::FilePathWatcher() {
298 impl_ = new FilePathWatcherImpl(); 298 impl_ = new FilePathWatcherImpl();
299 } 299 }
300 300
301 } // namespace base 301 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file_path_watcher_stub.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698