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

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

Issue 2516353003: Stop checking that FilePathWatcher is used from a MessageLoopForIO. (Closed)
Patch Set: remove patch dependency Created 4 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
« no previous file with comments | « base/files/file_path_watcher_fsevents.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) 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 #include "base/files/file_path_watcher.h" 5 #include "base/files/file_path_watcher.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <string.h> 9 #include <string.h>
10 #include <sys/inotify.h> 10 #include <sys/inotify.h>
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 return; 328 return;
329 } 329 }
330 330
331 // Check to see if CancelOnMessageLoopThreadOrInDestructor() has already been 331 // Check to see if CancelOnMessageLoopThreadOrInDestructor() has already been
332 // called. May happen when code flow reaches here from the PostTask() above. 332 // called. May happen when code flow reaches here from the PostTask() above.
333 if (watches_.empty()) { 333 if (watches_.empty()) {
334 DCHECK(target_.empty()); 334 DCHECK(target_.empty());
335 return; 335 return;
336 } 336 }
337 337
338 DCHECK(MessageLoopForIO::current()); 338 DCHECK(task_runner()->BelongsToCurrentThread());
339 DCHECK(HasValidWatchVector()); 339 DCHECK(HasValidWatchVector());
340 340
341 // Used below to avoid multiple recursive updates. 341 // Used below to avoid multiple recursive updates.
342 bool did_update = false; 342 bool did_update = false;
343 343
344 // Find the entry in |watches_| that corresponds to |fired_watch|. 344 // Find the entry in |watches_| that corresponds to |fired_watch|.
345 for (size_t i = 0; i < watches_.size(); ++i) { 345 for (size_t i = 0; i < watches_.size(); ++i) {
346 const WatchEntry& watch_entry = watches_[i]; 346 const WatchEntry& watch_entry = watches_[i];
347 if (fired_watch != watch_entry.watch) 347 if (fired_watch != watch_entry.watch)
348 continue; 348 continue;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 if (!did_update) 413 if (!did_update)
414 UpdateRecursiveWatches(fired_watch, is_dir); 414 UpdateRecursiveWatches(fired_watch, is_dir);
415 callback_.Run(target_, false /* error */); 415 callback_.Run(target_, false /* error */);
416 } 416 }
417 } 417 }
418 418
419 bool FilePathWatcherImpl::Watch(const FilePath& path, 419 bool FilePathWatcherImpl::Watch(const FilePath& path,
420 bool recursive, 420 bool recursive,
421 const FilePathWatcher::Callback& callback) { 421 const FilePathWatcher::Callback& callback) {
422 DCHECK(target_.empty()); 422 DCHECK(target_.empty());
423 DCHECK(MessageLoopForIO::current());
424 423
425 set_task_runner(ThreadTaskRunnerHandle::Get()); 424 set_task_runner(ThreadTaskRunnerHandle::Get());
426 callback_ = callback; 425 callback_ = callback;
427 target_ = path; 426 target_ = path;
428 recursive_ = recursive; 427 recursive_ = recursive;
429 428
430 std::vector<FilePath::StringType> comps; 429 std::vector<FilePath::StringType> comps;
431 target_.GetComponents(&comps); 430 target_.GetComponents(&comps);
432 DCHECK(!comps.empty()); 431 DCHECK(!comps.empty());
433 for (size_t i = 1; i < comps.size(); ++i) 432 for (size_t i = 1; i < comps.size(); ++i)
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 } 654 }
656 655
657 } // namespace 656 } // namespace
658 657
659 FilePathWatcher::FilePathWatcher() { 658 FilePathWatcher::FilePathWatcher() {
660 sequence_checker_.DetachFromSequence(); 659 sequence_checker_.DetachFromSequence();
661 impl_ = new FilePathWatcherImpl(); 660 impl_ = new FilePathWatcherImpl();
662 } 661 }
663 662
664 } // namespace base 663 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file_path_watcher_fsevents.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698