| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/file_watcher.h" | 5 #include "chrome/browser/file_watcher.h" |
| 6 | 6 |
| 7 #include <CoreServices/CoreServices.h> | 7 #include <CoreServices/CoreServices.h> |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // much rather than miss a notification. | 69 // much rather than miss a notification. |
| 70 delegate_->OnFileChanged(path_); | 70 delegate_->OnFileChanged(path_); |
| 71 } else if (!file_exists && !last_modified_.is_null()) { | 71 } else if (!file_exists && !last_modified_.is_null()) { |
| 72 last_modified_ = base::Time(); | 72 last_modified_ = base::Time(); |
| 73 delegate_->OnFileChanged(path_); | 73 delegate_->OnFileChanged(path_); |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 // Delegate to notify upon changes. | 78 // Delegate to notify upon changes. |
| 79 FileWatcher::Delegate* delegate_; | 79 scoped_refptr<FileWatcher::Delegate> delegate_; |
| 80 | 80 |
| 81 // Path we're watching (passed to delegate). | 81 // Path we're watching (passed to delegate). |
| 82 FilePath path_; | 82 FilePath path_; |
| 83 | 83 |
| 84 // Backend stream we receive event callbacks from (strong reference). | 84 // Backend stream we receive event callbacks from (strong reference). |
| 85 FSEventStreamRef fsevent_stream_; | 85 FSEventStreamRef fsevent_stream_; |
| 86 | 86 |
| 87 // Keep track of the last modified time of the file. We use nulltime | 87 // Keep track of the last modified time of the file. We use nulltime |
| 88 // to represent the file not existing. | 88 // to represent the file not existing. |
| 89 base::Time last_modified_; | 89 base::Time last_modified_; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 FSEventStreamStart(fsevent_stream_); | 148 FSEventStreamStart(fsevent_stream_); |
| 149 | 149 |
| 150 return true; | 150 return true; |
| 151 } | 151 } |
| 152 | 152 |
| 153 } // namespace | 153 } // namespace |
| 154 | 154 |
| 155 FileWatcher::FileWatcher() { | 155 FileWatcher::FileWatcher() { |
| 156 impl_ = new FileWatcherImpl(); | 156 impl_ = new FileWatcherImpl(); |
| 157 } | 157 } |
| OLD | NEW |