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

Side by Side Diff: chrome/browser/file_path_watcher_mac.cc

Issue 3347005: Moving file_util::FileInfo to base::PlatformFileInfo, and adding the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 3 months 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) 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_path_watcher.h" 5 #include "chrome/browser/file_path_watcher.h"
6 6
7 #include <CoreServices/CoreServices.h> 7 #include <CoreServices/CoreServices.h>
8 #include <set> 8 #include <set>
9 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 FilePathWatcherImpl::FilePathWatcherImpl() 101 FilePathWatcherImpl::FilePathWatcherImpl()
102 : fsevent_stream_(NULL), 102 : fsevent_stream_(NULL),
103 canceled_(false) { 103 canceled_(false) {
104 } 104 }
105 105
106 void FilePathWatcherImpl::OnFilePathChanged() { 106 void FilePathWatcherImpl::OnFilePathChanged() {
107 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); 107 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
108 DCHECK(!target_.empty()); 108 DCHECK(!target_.empty());
109 109
110 file_util::FileInfo file_info; 110 base::PlatformFileInfo file_info;
111 bool file_exists = file_util::GetFileInfo(target_, &file_info); 111 bool file_exists = file_util::GetFileInfo(target_, &file_info);
112 if (file_exists && (last_modified_.is_null() || 112 if (file_exists && (last_modified_.is_null() ||
113 last_modified_ != file_info.last_modified)) { 113 last_modified_ != file_info.last_modified)) {
114 last_modified_ = file_info.last_modified; 114 last_modified_ = file_info.last_modified;
115 first_notification_ = base::Time::Now(); 115 first_notification_ = base::Time::Now();
116 delegate_->OnFilePathChanged(target_); 116 delegate_->OnFilePathChanged(target_);
117 } else if (file_exists && !first_notification_.is_null()) { 117 } else if (file_exists && !first_notification_.is_null()) {
118 // The target's last modification time is equal to what's on record. This 118 // The target's last modification time is equal to what's on record. This
119 // means that either an unrelated event occurred, or the target changed 119 // means that either an unrelated event occurred, or the target changed
120 // again (file modification times only have a resolution of 1s). Comparing 120 // again (file modification times only have a resolution of 1s). Comparing
(...skipping 22 matching lines...) Expand all
143 143
144 bool FilePathWatcherImpl::Watch(const FilePath& path, 144 bool FilePathWatcherImpl::Watch(const FilePath& path,
145 FilePathWatcher::Delegate* delegate) { 145 FilePathWatcher::Delegate* delegate) {
146 DCHECK(target_.value().empty()); 146 DCHECK(target_.value().empty());
147 147
148 target_ = path; 148 target_ = path;
149 delegate_ = delegate; 149 delegate_ = delegate;
150 150
151 FSEventStreamEventId start_event = FSEventsGetCurrentEventId(); 151 FSEventStreamEventId start_event = FSEventsGetCurrentEventId();
152 152
153 file_util::FileInfo file_info; 153 base::PlatformFileInfo file_info;
154 if (file_util::GetFileInfo(target_, &file_info)) { 154 if (file_util::GetFileInfo(target_, &file_info)) {
155 last_modified_ = file_info.last_modified; 155 last_modified_ = file_info.last_modified;
156 first_notification_ = base::Time::Now(); 156 first_notification_ = base::Time::Now();
157 } 157 }
158 158
159 ChromeThread::PostTask(ChromeThread::UI, FROM_HERE, 159 ChromeThread::PostTask(ChromeThread::UI, FROM_HERE,
160 NewRunnableMethod(this, &FilePathWatcherImpl::UpdateEventStream, 160 NewRunnableMethod(this, &FilePathWatcherImpl::UpdateEventStream,
161 start_event)); 161 start_event));
162 162
163 return true; 163 return true;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 FSEventStreamInvalidate(fsevent_stream_); 223 FSEventStreamInvalidate(fsevent_stream_);
224 FSEventStreamRelease(fsevent_stream_); 224 FSEventStreamRelease(fsevent_stream_);
225 fsevent_stream_ = NULL; 225 fsevent_stream_ = NULL;
226 } 226 }
227 227
228 } // namespace 228 } // namespace
229 229
230 FilePathWatcher::FilePathWatcher() { 230 FilePathWatcher::FilePathWatcher() {
231 impl_ = new FilePathWatcherImpl(); 231 impl_ = new FilePathWatcherImpl();
232 } 232 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698