Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 366 DCHECK(MessageLoopForIO::current()); | 366 DCHECK(MessageLoopForIO::current()); |
| 367 | 367 |
| 368 set_message_loop(base::MessageLoopProxy::current()); | 368 set_message_loop(base::MessageLoopProxy::current()); |
| 369 delegate_ = delegate; | 369 delegate_ = delegate; |
| 370 target_ = path; | 370 target_ = path; |
| 371 MessageLoop::current()->AddDestructionObserver(this); | 371 MessageLoop::current()->AddDestructionObserver(this); |
| 372 | 372 |
| 373 std::vector<FilePath::StringType> comps; | 373 std::vector<FilePath::StringType> comps; |
| 374 target_.GetComponents(&comps); | 374 target_.GetComponents(&comps); |
| 375 DCHECK(!comps.empty()); | 375 DCHECK(!comps.empty()); |
| 376 for (std::vector<FilePath::StringType>::const_iterator comp(++comps.begin()); | 376 std::vector<FilePath::StringType>::const_iterator comp = comps.begin(); |
| 377 comp != comps.end(); ++comp) { | 377 for (comp++; comp != comps.end(); comp++) { |
|
Mattias Nissler (ping if slow)
2012/08/27 12:53:02
Style guide says to use preincrement: http://googl
| |
| 378 watches_.push_back(WatchEntry(InotifyReader::kInvalidWatch, *comp)); | 378 watches_.push_back(WatchEntry(InotifyReader::kInvalidWatch, *comp)); |
| 379 } | 379 } |
| 380 watches_.push_back(WatchEntry(InotifyReader::kInvalidWatch, | 380 watches_.push_back(WatchEntry(InotifyReader::kInvalidWatch, |
| 381 FilePath::StringType())); | 381 FilePath::StringType())); |
| 382 return UpdateWatches(); | 382 return UpdateWatches(); |
| 383 } | 383 } |
| 384 | 384 |
| 385 void FilePathWatcherImpl::Cancel() { | 385 void FilePathWatcherImpl::Cancel() { |
| 386 if (!delegate_) { | 386 if (!delegate_) { |
| 387 // Watch was never called, or the |message_loop_| thread is already gone. | 387 // Watch was never called, or the |message_loop_| thread is already gone. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 474 } | 474 } |
| 475 | 475 |
| 476 } // namespace | 476 } // namespace |
| 477 | 477 |
| 478 FilePathWatcher::FilePathWatcher() { | 478 FilePathWatcher::FilePathWatcher() { |
| 479 impl_ = new FilePathWatcherImpl(); | 479 impl_ = new FilePathWatcherImpl(); |
| 480 } | 480 } |
| 481 | 481 |
| 482 } // namespace files | 482 } // namespace files |
| 483 } // namespace base | 483 } // namespace base |
| OLD | NEW |