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

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

Issue 8677015: base::Bind: Convert FilePathWatcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 <errno.h> 7 #include <errno.h>
8 #include <string.h> 8 #include <string.h>
9 #include <sys/inotify.h> 9 #include <sys/inotify.h>
10 #include <sys/ioctl.h> 10 #include <sys/ioctl.h>
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 void FilePathWatcherImpl::Cancel() { 400 void FilePathWatcherImpl::Cancel() {
401 if (!delegate_) { 401 if (!delegate_) {
402 // Watch was never called, or the |message_loop_| thread is already gone. 402 // Watch was never called, or the |message_loop_| thread is already gone.
403 set_cancelled(); 403 set_cancelled();
404 return; 404 return;
405 } 405 }
406 406
407 // Switch to the message_loop_ if necessary so we can access |watches_|. 407 // Switch to the message_loop_ if necessary so we can access |watches_|.
408 if (!message_loop()->BelongsToCurrentThread()) { 408 if (!message_loop()->BelongsToCurrentThread()) {
409 message_loop()->PostTask(FROM_HERE, 409 message_loop()->PostTask(FROM_HERE,
410 new FilePathWatcher::CancelTask(this)); 410 base::Bind(&FilePathWatcher::CancelWatch,
411 make_scoped_refptr(this)));
411 } else { 412 } else {
412 CancelOnMessageLoopThread(); 413 CancelOnMessageLoopThread();
413 } 414 }
414 } 415 }
415 416
416 void FilePathWatcherImpl::CancelOnMessageLoopThread() { 417 void FilePathWatcherImpl::CancelOnMessageLoopThread() {
417 if (!is_cancelled()) 418 if (!is_cancelled())
418 set_cancelled(); 419 set_cancelled();
419 420
420 if (delegate_) { 421 if (delegate_) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 } 488 }
488 489
489 } // namespace 490 } // namespace
490 491
491 FilePathWatcher::FilePathWatcher() { 492 FilePathWatcher::FilePathWatcher() {
492 impl_ = new FilePathWatcherImpl(); 493 impl_ = new FilePathWatcherImpl();
493 } 494 }
494 495
495 } // namespace files 496 } // namespace files
496 } // namespace base 497 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698