| 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 <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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 // change. Returns kInvalidWatch on failure. | 56 // change. Returns kInvalidWatch on failure. |
| 57 Watch AddWatch(const FilePath& path, FilePathWatcherImpl* watcher); | 57 Watch AddWatch(const FilePath& path, FilePathWatcherImpl* watcher); |
| 58 | 58 |
| 59 // Remove |watch| if it's valid. | 59 // Remove |watch| if it's valid. |
| 60 void RemoveWatch(Watch watch, FilePathWatcherImpl* watcher); | 60 void RemoveWatch(Watch watch, FilePathWatcherImpl* watcher); |
| 61 | 61 |
| 62 // Callback for InotifyReaderTask. | 62 // Callback for InotifyReaderTask. |
| 63 void OnInotifyEvent(const inotify_event* event); | 63 void OnInotifyEvent(const inotify_event* event); |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 friend struct DefaultLazyInstanceTraits<InotifyReader>; | 66 friend struct LazyInstanceTraitsBase<InotifyReader>; |
| 67 | 67 |
| 68 typedef std::set<FilePathWatcherImpl*> WatcherSet; | 68 typedef std::set<FilePathWatcherImpl*> WatcherSet; |
| 69 | 69 |
| 70 InotifyReader(); | 70 InotifyReader(); |
| 71 // There is no destructor because |g_inotify_reader| is a | 71 // There is no destructor because |g_inotify_reader| is a |
| 72 // base::LazyInstace::Leaky object. Having a destructor causes build | 72 // base::LazyInstace::Leaky object. Having a destructor causes build |
| 73 // issues with GCC 6 (http://crbug.com/636346). | 73 // issues with GCC 6 (http://crbug.com/636346). |
| 74 | 74 |
| 75 // We keep track of which delegates want to be notified on which watches. | 75 // We keep track of which delegates want to be notified on which watches. |
| 76 hash_map<Watch, WatcherSet> watchers_; | 76 hash_map<Watch, WatcherSet> watchers_; |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 } | 644 } |
| 645 | 645 |
| 646 } // namespace | 646 } // namespace |
| 647 | 647 |
| 648 FilePathWatcher::FilePathWatcher() { | 648 FilePathWatcher::FilePathWatcher() { |
| 649 sequence_checker_.DetachFromSequence(); | 649 sequence_checker_.DetachFromSequence(); |
| 650 impl_ = MakeUnique<FilePathWatcherImpl>(); | 650 impl_ = MakeUnique<FilePathWatcherImpl>(); |
| 651 } | 651 } |
| 652 | 652 |
| 653 } // namespace base | 653 } // namespace base |
| OLD | NEW |