OLD | NEW |
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 "content/common/file_path_watcher/file_path_watcher.h" | 5 #include "base/files/file_path_watcher.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/message_loop_proxy.h" | 11 #include "base/message_loop_proxy.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "base/win/object_watcher.h" | 13 #include "base/win/object_watcher.h" |
14 | 14 |
| 15 namespace base { |
| 16 namespace files { |
| 17 |
15 namespace { | 18 namespace { |
16 | 19 |
17 class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate, | 20 class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate, |
18 public base::win::ObjectWatcher::Delegate, | 21 public base::win::ObjectWatcher::Delegate, |
19 public MessageLoop::DestructionObserver { | 22 public MessageLoop::DestructionObserver { |
20 public: | 23 public: |
21 FilePathWatcherImpl() : delegate_(NULL), handle_(INVALID_HANDLE_VALUE) {} | 24 FilePathWatcherImpl() : delegate_(NULL), handle_(INVALID_HANDLE_VALUE) {} |
22 | 25 |
23 // FilePathWatcher::PlatformDelegate overrides. | 26 // FilePathWatcher::PlatformDelegate overrides. |
24 virtual bool Watch(const FilePath& path, | 27 virtual bool Watch(const FilePath& path, |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 // If FindFirstChangeNotification failed because the target directory | 198 // If FindFirstChangeNotification failed because the target directory |
196 // doesn't exist, access is denied (happens if the file is already gone but | 199 // doesn't exist, access is denied (happens if the file is already gone but |
197 // there are still handles open), or the target is not a directory, try the | 200 // there are still handles open), or the target is not a directory, try the |
198 // immediate parent directory instead. | 201 // immediate parent directory instead. |
199 DWORD error_code = GetLastError(); | 202 DWORD error_code = GetLastError(); |
200 if (error_code != ERROR_FILE_NOT_FOUND && | 203 if (error_code != ERROR_FILE_NOT_FOUND && |
201 error_code != ERROR_PATH_NOT_FOUND && | 204 error_code != ERROR_PATH_NOT_FOUND && |
202 error_code != ERROR_ACCESS_DENIED && | 205 error_code != ERROR_ACCESS_DENIED && |
203 error_code != ERROR_SHARING_VIOLATION && | 206 error_code != ERROR_SHARING_VIOLATION && |
204 error_code != ERROR_DIRECTORY) { | 207 error_code != ERROR_DIRECTORY) { |
| 208 using ::operator<<; // Pick the right operator<< below. |
205 PLOG(ERROR) << "FindFirstChangeNotification failed for " | 209 PLOG(ERROR) << "FindFirstChangeNotification failed for " |
206 << dir.value(); | 210 << dir.value(); |
207 return false; | 211 return false; |
208 } | 212 } |
209 | 213 |
210 return true; | 214 return true; |
211 } | 215 } |
212 | 216 |
213 bool FilePathWatcherImpl::UpdateWatch() { | 217 bool FilePathWatcherImpl::UpdateWatch() { |
214 if (handle_ != INVALID_HANDLE_VALUE) | 218 if (handle_ != INVALID_HANDLE_VALUE) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 watcher_.StopWatching(); | 269 watcher_.StopWatching(); |
266 FindCloseChangeNotification(handle_); | 270 FindCloseChangeNotification(handle_); |
267 handle_ = INVALID_HANDLE_VALUE; | 271 handle_ = INVALID_HANDLE_VALUE; |
268 } | 272 } |
269 | 273 |
270 } // namespace | 274 } // namespace |
271 | 275 |
272 FilePathWatcher::FilePathWatcher() { | 276 FilePathWatcher::FilePathWatcher() { |
273 impl_ = new FilePathWatcherImpl(); | 277 impl_ = new FilePathWatcherImpl(); |
274 } | 278 } |
| 279 |
| 280 } // namespace files |
| 281 } // namespace base |
OLD | NEW |