file_path_watcher_linux.cc revision cedac228d2dd51db4b79ea1e72c7f249408ee061
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 3// found in the LICENSE file. 4 5#include "base/files/file_path_watcher.h" 6 7#include <errno.h> 8#include <string.h> 9#include <sys/inotify.h> 10#include <sys/ioctl.h> 11#include <sys/select.h> 12#include <unistd.h> 13 14#include <algorithm> 15#include <map> 16#include <set> 17#include <utility> 18#include <vector> 19 20#include "base/bind.h" 21#include "base/containers/hash_tables.h" 22#include "base/debug/trace_event.h" 23#include "base/file_util.h" 24#include "base/files/file_enumerator.h" 25#include "base/files/file_path.h" 26#include "base/lazy_instance.h" 27#include "base/location.h" 28#include "base/logging.h" 29#include "base/memory/scoped_ptr.h" 30#include "base/message_loop/message_loop.h" 31#include "base/message_loop/message_loop_proxy.h" 32#include "base/posix/eintr_wrapper.h" 33#include "base/synchronization/lock.h" 34#include "base/threading/thread.h" 35 36namespace base { 37 38namespace { 39 40class FilePathWatcherImpl; 41 42// Singleton to manage all inotify watches. 43// TODO(tony): It would be nice if this wasn't a singleton. 44// http://crbug.com/38174 45class InotifyReader { 46 public: 47 typedef int Watch; // Watch descriptor used by AddWatch and RemoveWatch. 48 static const Watch kInvalidWatch = -1; 49 50 // Watch directory |path| for changes. |watcher| will be notified on each 51 // change. Returns kInvalidWatch on failure. 52 Watch AddWatch(const FilePath& path, FilePathWatcherImpl* watcher); 53 54 // Remove |watch| if it's valid. 55 void RemoveWatch(Watch watch, FilePathWatcherImpl* watcher); 56 57 // Callback for InotifyReaderTask. 58 void OnInotifyEvent(const inotify_event* event); 59 60 private: 61 friend struct DefaultLazyInstanceTraits<InotifyReader>; 62 63 typedef std::set<FilePathWatcherImpl*> WatcherSet; 64 65 InotifyReader(); 66 ~InotifyReader(); 67 68 // We keep track of which delegates want to be notified on which watches. 69 hash_map<Watch, WatcherSet> watchers_; 70 71 // Lock to protect watchers_. 72 Lock lock_; 73 74 // Separate thread on which we run blocking read for inotify events. 75 Thread thread_; 76 77 // File descriptor returned by inotify_init. 78 const int inotify_fd_; 79 80 // Use self-pipe trick to unblock select during shutdown. 81 int shutdown_pipe_[2]; 82 83 // Flag set to true when startup was successful. 84 bool valid_; 85 86 DISALLOW_COPY_AND_ASSIGN(InotifyReader); 87}; 88 89class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate, 90 public MessageLoop::DestructionObserver { 91 public: 92 FilePathWatcherImpl(); 93 94 // Called for each event coming from the watch. |fired_watch| identifies the 95 // watch that fired, |child| indicates what has changed, and is relative to 96 // the currently watched path for |fired_watch|. 97 // 98 // |created| is true if the object appears. 99 // |deleted| is true if the object disappears. 100 // |is_dir| is true if the object is a directory. 101 void OnFilePathChanged(InotifyReader::Watch fired_watch, 102 const FilePath::StringType& child, 103 bool created, 104 bool deleted, 105 bool is_dir); 106 107 protected: 108 virtual ~FilePathWatcherImpl() {} 109 110 private: 111 // Start watching |path| for changes and notify |delegate| on each change. 112 // Returns true if watch for |path| has been added successfully. 113 virtual bool Watch(const FilePath& path, 114 bool recursive, 115 const FilePathWatcher::Callback& callback) OVERRIDE; 116 117 // Cancel the watch. This unregisters the instance with InotifyReader. 118 virtual void Cancel() OVERRIDE; 119 120 // Cleans up and stops observing the message_loop() thread. 121 virtual void CancelOnMessageLoopThread() OVERRIDE; 122 123 // Deletion of the FilePathWatcher will call Cancel() to dispose of this 124 // object in the right thread. This also observes destruction of the required 125 // cleanup thread, in case it quits before Cancel() is called. 126 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; 127 128 // Inotify watches are installed for all directory components of |target_|. A 129 // WatchEntry instance holds the watch descriptor for a component and the 130 // subdirectory for that identifies the next component. If a symbolic link 131 // is being watched, the target of the link is also kept. 132 struct WatchEntry { 133 explicit WatchEntry(const FilePath::StringType& dirname) 134 : watch(InotifyReader::kInvalidWatch), 135 subdir(dirname) {} 136 137 InotifyReader::Watch watch; 138 FilePath::StringType subdir; 139 FilePath::StringType linkname; 140 }; 141 typedef std::vector<WatchEntry> WatchVector; 142 143 // Reconfigure to watch for the most specific parent directory of |target_| 144 // that exists. Also calls UpdateRecursiveWatches() below. 145 void UpdateWatches(); 146 147 // Reconfigure to recursively watch |target_| and all its sub-directories. 148 // - This is a no-op if the watch is not recursive. 149 // - If |target_| does not exist, then clear all the recursive watches. 150 // - Assuming |target_| exists, passing kInvalidWatch as |fired_watch| forces 151 // addition of recursive watches for |target_|. 152 // - Otherwise, only the directory associated with |fired_watch| and its 153 // sub-directories will be reconfigured. 154 void UpdateRecursiveWatches(InotifyReader::Watch fired_watch, bool is_dir); 155 156 // Enumerate recursively through |path| and add / update watches. 157 void UpdateRecursiveWatchesForPath(const FilePath& path); 158 159 // Do internal bookkeeping to update mappings between |watch| and its 160 // associated full path |path|. 161 void TrackWatchForRecursion(InotifyReader::Watch watch, const FilePath& path); 162 163 // Remove all the recursive watches. 164 void RemoveRecursiveWatches(); 165 166 // |path| is a symlink to a non-existent target. Attempt to add a watch to 167 // the link target's parent directory. Returns true and update |watch_entry| 168 // on success. 169 bool AddWatchForBrokenSymlink(const FilePath& path, WatchEntry* watch_entry); 170 171 bool HasValidWatchVector() const; 172 173 // Callback to notify upon changes. 174 FilePathWatcher::Callback callback_; 175 176 // The file or directory we're supposed to watch. 177 FilePath target_; 178 179 bool recursive_; 180 181 // The vector of watches and next component names for all path components, 182 // starting at the root directory. The last entry corresponds to the watch for 183 // |target_| and always stores an empty next component name in |subdir|. 184 WatchVector watches_; 185 186 hash_map<InotifyReader::Watch, FilePath> recursive_paths_by_watch_; 187 std::map<FilePath, InotifyReader::Watch> recursive_watches_by_path_; 188 189 DISALLOW_COPY_AND_ASSIGN(FilePathWatcherImpl); 190}; 191 192void InotifyReaderCallback(InotifyReader* reader, int inotify_fd, 193 int shutdown_fd) { 194 // Make sure the file descriptors are good for use with select(). 195 CHECK_LE(0, inotify_fd); 196 CHECK_GT(FD_SETSIZE, inotify_fd); 197 CHECK_LE(0, shutdown_fd); 198 CHECK_GT(FD_SETSIZE, shutdown_fd); 199 200 debug::TraceLog::GetInstance()->SetCurrentThreadBlocksMessageLoop(); 201 202 while (true) { 203 fd_set rfds; 204 FD_ZERO(&rfds); 205 FD_SET(inotify_fd, &rfds); 206 FD_SET(shutdown_fd, &rfds); 207 208 // Wait until some inotify events are available. 209 int select_result = 210 HANDLE_EINTR(select(std::max(inotify_fd, shutdown_fd) + 1, 211 &rfds, NULL, NULL, NULL)); 212 if (select_result < 0) { 213 DPLOG(WARNING) << "select failed"; 214 return; 215 } 216 217 if (FD_ISSET(shutdown_fd, &rfds)) 218 return; 219 220 // Adjust buffer size to current event queue size. 221 int buffer_size; 222 int ioctl_result = HANDLE_EINTR(ioctl(inotify_fd, FIONREAD, 223 &buffer_size)); 224 225 if (ioctl_result != 0) { 226 DPLOG(WARNING) << "ioctl failed"; 227 return; 228 } 229 230 std::vector<char> buffer(buffer_size); 231 232 ssize_t bytes_read = HANDLE_EINTR(read(inotify_fd, &buffer[0], 233 buffer_size)); 234 235 if (bytes_read < 0) { 236 DPLOG(WARNING) << "read from inotify fd failed"; 237 return; 238 } 239 240 ssize_t i = 0; 241 while (i < bytes_read) { 242 inotify_event* event = reinterpret_cast<inotify_event*>(&buffer[i]); 243 size_t event_size = sizeof(inotify_event) + event->len; 244 DCHECK(i + event_size <= static_cast<size_t>(bytes_read)); 245 reader->OnInotifyEvent(event); 246 i += event_size; 247 } 248 } 249} 250 251static LazyInstance<InotifyReader>::Leaky g_inotify_reader = 252 LAZY_INSTANCE_INITIALIZER; 253 254InotifyReader::InotifyReader() 255 : thread_("inotify_reader"), 256 inotify_fd_(inotify_init()), 257 valid_(false) { 258 if (inotify_fd_ < 0) 259 PLOG(ERROR) << "inotify_init() failed"; 260 261 shutdown_pipe_[0] = -1; 262 shutdown_pipe_[1] = -1; 263 if (inotify_fd_ >= 0 && pipe(shutdown_pipe_) == 0 && thread_.Start()) { 264 thread_.message_loop()->PostTask( 265 FROM_HERE, 266 Bind(&InotifyReaderCallback, this, inotify_fd_, shutdown_pipe_[0])); 267 valid_ = true; 268 } 269} 270 271InotifyReader::~InotifyReader() { 272 if (valid_) { 273 // Write to the self-pipe so that the select call in InotifyReaderTask 274 // returns. 275 ssize_t ret = HANDLE_EINTR(write(shutdown_pipe_[1], "", 1)); 276 DPCHECK(ret > 0); 277 DCHECK_EQ(ret, 1); 278 thread_.Stop(); 279 } 280 if (inotify_fd_ >= 0) 281 close(inotify_fd_); 282 if (shutdown_pipe_[0] >= 0) 283 close(shutdown_pipe_[0]); 284 if (shutdown_pipe_[1] >= 0) 285 close(shutdown_pipe_[1]); 286} 287 288InotifyReader::Watch InotifyReader::AddWatch( 289 const FilePath& path, FilePathWatcherImpl* watcher) { 290 if (!valid_) 291 return kInvalidWatch; 292 293 AutoLock auto_lock(lock_); 294 295 Watch watch = inotify_add_watch(inotify_fd_, path.value().c_str(), 296 IN_ATTRIB | IN_CREATE | IN_DELETE | 297 IN_CLOSE_WRITE | IN_MOVE | 298 IN_ONLYDIR); 299 300 if (watch == kInvalidWatch) 301 return kInvalidWatch; 302 303 watchers_[watch].insert(watcher); 304 305 return watch; 306} 307 308void InotifyReader::RemoveWatch(Watch watch, FilePathWatcherImpl* watcher) { 309 if (!valid_ || (watch == kInvalidWatch)) 310 return; 311 312 AutoLock auto_lock(lock_); 313 314 watchers_[watch].erase(watcher); 315 316 if (watchers_[watch].empty()) { 317 watchers_.erase(watch); 318 inotify_rm_watch(inotify_fd_, watch); 319 } 320} 321 322void InotifyReader::OnInotifyEvent(const inotify_event* event) { 323 if (event->mask & IN_IGNORED) 324 return; 325 326 FilePath::StringType child(event->len ? event->name : FILE_PATH_LITERAL("")); 327 AutoLock auto_lock(lock_); 328 329 for (WatcherSet::iterator watcher = watchers_[event->wd].begin(); 330 watcher != watchers_[event->wd].end(); 331 ++watcher) { 332 (*watcher)->OnFilePathChanged(event->wd, 333 child, 334 event->mask & (IN_CREATE | IN_MOVED_TO), 335 event->mask & (IN_DELETE | IN_MOVED_FROM), 336 event->mask & IN_ISDIR); 337 } 338} 339 340FilePathWatcherImpl::FilePathWatcherImpl() 341 : recursive_(false) { 342} 343 344void FilePathWatcherImpl::OnFilePathChanged(InotifyReader::Watch fired_watch, 345 const FilePath::StringType& child, 346 bool created, 347 bool deleted, 348 bool is_dir) { 349 if (!message_loop()->BelongsToCurrentThread()) { 350 // Switch to message_loop() to access |watches_| safely. 351 message_loop()->PostTask( 352 FROM_HERE, 353 Bind(&FilePathWatcherImpl::OnFilePathChanged, this, 354 fired_watch, child, created, deleted, is_dir)); 355 return; 356 } 357 358 // Check to see if CancelOnMessageLoopThread() has already been called. 359 // May happen when code flow reaches here from the PostTask() above. 360 if (watches_.empty()) { 361 DCHECK(target_.empty()); 362 return; 363 } 364 365 DCHECK(MessageLoopForIO::current()); 366 DCHECK(HasValidWatchVector()); 367 368 // Used below to avoid multiple recursive updates. 369 bool did_update = false; 370 371 // Find the entry in |watches_| that corresponds to |fired_watch|. 372 for (size_t i = 0; i < watches_.size(); ++i) { 373 const WatchEntry& watch_entry = watches_[i]; 374 if (fired_watch != watch_entry.watch) 375 continue; 376 377 // Check whether a path component of |target_| changed. 378 bool change_on_target_path = 379 child.empty() || 380 (child == watch_entry.linkname) || 381 (child == watch_entry.subdir); 382 383 // Check if the change references |target_| or a direct child of |target_|. 384 bool is_watch_for_target = watch_entry.subdir.empty(); 385 bool target_changed = 386 (is_watch_for_target && (child == watch_entry.linkname)) || 387 (is_watch_for_target && watch_entry.linkname.empty()) || 388 (watch_entry.subdir == child && watches_[i + 1].subdir.empty()); 389 390 // Update watches if a directory component of the |target_| path 391 // (dis)appears. Note that we don't add the additional restriction of 392 // checking the event mask to see if it is for a directory here as changes 393 // to symlinks on the target path will not have IN_ISDIR set in the event 394 // masks. As a result we may sometimes call UpdateWatches() unnecessarily. 395 if (change_on_target_path && (created || deleted) && !did_update) { 396 UpdateWatches(); 397 did_update = true; 398 } 399 400 // Report the following events: 401 // - The target or a direct child of the target got changed (in case the 402 // watched path refers to a directory). 403 // - One of the parent directories got moved or deleted, since the target 404 // disappears in this case. 405 // - One of the parent directories appears. The event corresponding to 406 // the target appearing might have been missed in this case, so recheck. 407 if (target_changed || 408 (change_on_target_path && deleted) || 409 (change_on_target_path && created && PathExists(target_))) { 410 if (!did_update) { 411 UpdateRecursiveWatches(fired_watch, is_dir); 412 did_update = true; 413 } 414 callback_.Run(target_, false /* error */); 415 return; 416 } 417 } 418 419 if (ContainsKey(recursive_paths_by_watch_, fired_watch)) { 420 if (!did_update) 421 UpdateRecursiveWatches(fired_watch, is_dir); 422 callback_.Run(target_, false /* error */); 423 } 424} 425 426bool FilePathWatcherImpl::Watch(const FilePath& path, 427 bool recursive, 428 const FilePathWatcher::Callback& callback) { 429 DCHECK(target_.empty()); 430 DCHECK(MessageLoopForIO::current()); 431 432 set_message_loop(MessageLoopProxy::current().get()); 433 callback_ = callback; 434 target_ = path; 435 recursive_ = recursive; 436 MessageLoop::current()->AddDestructionObserver(this); 437 438 std::vector<FilePath::StringType> comps; 439 target_.GetComponents(&comps); 440 DCHECK(!comps.empty()); 441 for (size_t i = 1; i < comps.size(); ++i) 442 watches_.push_back(WatchEntry(comps[i])); 443 watches_.push_back(WatchEntry(FilePath::StringType())); 444 UpdateWatches(); 445 return true; 446} 447 448void FilePathWatcherImpl::Cancel() { 449 if (callback_.is_null()) { 450 // Watch was never called, or the message_loop() thread is already gone. 451 set_cancelled(); 452 return; 453 } 454 455 // Switch to the message_loop() if necessary so we can access |watches_|. 456 if (!message_loop()->BelongsToCurrentThread()) { 457 message_loop()->PostTask(FROM_HERE, 458 Bind(&FilePathWatcher::CancelWatch, 459 make_scoped_refptr(this))); 460 } else { 461 CancelOnMessageLoopThread(); 462 } 463} 464 465void FilePathWatcherImpl::CancelOnMessageLoopThread() { 466 set_cancelled(); 467 468 if (!callback_.is_null()) { 469 MessageLoop::current()->RemoveDestructionObserver(this); 470 callback_.Reset(); 471 } 472 473 for (size_t i = 0; i < watches_.size(); ++i) 474 g_inotify_reader.Get().RemoveWatch(watches_[i].watch, this); 475 watches_.clear(); 476 target_.clear(); 477 478 if (recursive_) 479 RemoveRecursiveWatches(); 480} 481 482void FilePathWatcherImpl::WillDestroyCurrentMessageLoop() { 483 CancelOnMessageLoopThread(); 484} 485 486void FilePathWatcherImpl::UpdateWatches() { 487 // Ensure this runs on the message_loop() exclusively in order to avoid 488 // concurrency issues. 489 DCHECK(message_loop()->BelongsToCurrentThread()); 490 DCHECK(HasValidWatchVector()); 491 492 // Walk the list of watches and update them as we go. 493 FilePath path(FILE_PATH_LITERAL("/")); 494 bool path_valid = true; 495 for (size_t i = 0; i < watches_.size(); ++i) { 496 WatchEntry& watch_entry = watches_[i]; 497 InotifyReader::Watch old_watch = watch_entry.watch; 498 watch_entry.watch = InotifyReader::kInvalidWatch; 499 watch_entry.linkname.clear(); 500 if (path_valid) { 501 watch_entry.watch = g_inotify_reader.Get().AddWatch(path, this); 502 if (watch_entry.watch == InotifyReader::kInvalidWatch) { 503 if (IsLink(path)) { 504 path_valid = AddWatchForBrokenSymlink(path, &watch_entry); 505 } else { 506 path_valid = false; 507 } 508 } 509 } 510 if (old_watch != watch_entry.watch) 511 g_inotify_reader.Get().RemoveWatch(old_watch, this); 512 path = path.Append(watch_entry.subdir); 513 } 514 515 UpdateRecursiveWatches(InotifyReader::kInvalidWatch, 516 false /* is directory? */); 517} 518 519void FilePathWatcherImpl::UpdateRecursiveWatches( 520 InotifyReader::Watch fired_watch, 521 bool is_dir) { 522 if (!recursive_) 523 return; 524 525 if (!DirectoryExists(target_)) { 526 RemoveRecursiveWatches(); 527 return; 528 } 529 530 // Check to see if this is a forced update or if some component of |target_| 531 // has changed. For these cases, redo the watches for |target_| and below. 532 if (!ContainsKey(recursive_paths_by_watch_, fired_watch)) { 533 UpdateRecursiveWatchesForPath(target_); 534 return; 535 } 536 537 // Underneath |target_|, only directory changes trigger watch updates. 538 if (!is_dir) 539 return; 540 541 const FilePath& changed_dir = recursive_paths_by_watch_[fired_watch]; 542 543 std::map<FilePath, InotifyReader::Watch>::iterator start_it = 544 recursive_watches_by_path_.lower_bound(changed_dir); 545 std::map<FilePath, InotifyReader::Watch>::iterator end_it = start_it; 546 for (; end_it != recursive_watches_by_path_.end(); ++end_it) { 547 const FilePath& cur_path = end_it->first; 548 if (!changed_dir.IsParent(cur_path)) 549 break; 550 if (!DirectoryExists(cur_path)) 551 g_inotify_reader.Get().RemoveWatch(end_it->second, this); 552 } 553 recursive_watches_by_path_.erase(start_it, end_it); 554 UpdateRecursiveWatchesForPath(changed_dir); 555} 556 557void FilePathWatcherImpl::UpdateRecursiveWatchesForPath(const FilePath& path) { 558 DCHECK(recursive_); 559 DCHECK(!path.empty()); 560 DCHECK(DirectoryExists(path)); 561 562 // Note: SHOW_SYM_LINKS exposes symlinks as symlinks, so they are ignored 563 // rather than followed. Following symlinks can easily lead to the undesirable 564 // situation where the entire file system is being watched. 565 FileEnumerator enumerator( 566 path, 567 true /* recursive enumeration */, 568 FileEnumerator::DIRECTORIES | FileEnumerator::SHOW_SYM_LINKS); 569 for (FilePath current = enumerator.Next(); 570 !current.empty(); 571 current = enumerator.Next()) { 572 DCHECK(enumerator.GetInfo().IsDirectory()); 573 574 if (!ContainsKey(recursive_watches_by_path_, current)) { 575 // Add new watches. 576 InotifyReader::Watch watch = 577 g_inotify_reader.Get().AddWatch(current, this); 578 TrackWatchForRecursion(watch, current); 579 } else { 580 // Update existing watches. 581 InotifyReader::Watch old_watch = recursive_watches_by_path_[current]; 582 DCHECK_NE(InotifyReader::kInvalidWatch, old_watch); 583 InotifyReader::Watch watch = 584 g_inotify_reader.Get().AddWatch(current, this); 585 if (watch != old_watch) { 586 g_inotify_reader.Get().RemoveWatch(old_watch, this); 587 recursive_paths_by_watch_.erase(old_watch); 588 recursive_watches_by_path_.erase(current); 589 TrackWatchForRecursion(watch, current); 590 } 591 } 592 } 593} 594 595void FilePathWatcherImpl::TrackWatchForRecursion(InotifyReader::Watch watch, 596 const FilePath& path) { 597 DCHECK(recursive_); 598 DCHECK(!path.empty()); 599 DCHECK(target_.IsParent(path)); 600 601 if (watch == InotifyReader::kInvalidWatch) 602 return; 603 604 DCHECK(!ContainsKey(recursive_paths_by_watch_, watch)); 605 DCHECK(!ContainsKey(recursive_watches_by_path_, path)); 606 recursive_paths_by_watch_[watch] = path; 607 recursive_watches_by_path_[path] = watch; 608} 609 610void FilePathWatcherImpl::RemoveRecursiveWatches() { 611 if (!recursive_) 612 return; 613 614 for (hash_map<InotifyReader::Watch, FilePath>::const_iterator it = 615 recursive_paths_by_watch_.begin(); 616 it != recursive_paths_by_watch_.end(); 617 ++it) { 618 g_inotify_reader.Get().RemoveWatch(it->first, this); 619 } 620 recursive_paths_by_watch_.clear(); 621 recursive_watches_by_path_.clear(); 622} 623 624bool FilePathWatcherImpl::AddWatchForBrokenSymlink(const FilePath& path, 625 WatchEntry* watch_entry) { 626 DCHECK_EQ(InotifyReader::kInvalidWatch, watch_entry->watch); 627 FilePath link; 628 if (!ReadSymbolicLink(path, &link)) 629 return false; 630 631 if (!link.IsAbsolute()) 632 link = path.DirName().Append(link); 633 634 // Try watching symlink target directory. If the link target is "/", then we 635 // shouldn't get here in normal situations and if we do, we'd watch "/" for 636 // changes to a component "/" which is harmless so no special treatment of 637 // this case is required. 638 InotifyReader::Watch watch = 639 g_inotify_reader.Get().AddWatch(link.DirName(), this); 640 if (watch == InotifyReader::kInvalidWatch) { 641 // TODO(craig) Symlinks only work if the parent directory for the target 642 // exist. Ideally we should make sure we've watched all the components of 643 // the symlink path for changes. See crbug.com/91561 for details. 644 DPLOG(WARNING) << "Watch failed for " << link.DirName().value(); 645 return false; 646 } 647 watch_entry->watch = watch; 648 watch_entry->linkname = link.BaseName().value(); 649 return true; 650} 651 652bool FilePathWatcherImpl::HasValidWatchVector() const { 653 if (watches_.empty()) 654 return false; 655 for (size_t i = 0; i < watches_.size() - 1; ++i) { 656 if (watches_[i].subdir.empty()) 657 return false; 658 } 659 return watches_[watches_.size() - 1].subdir.empty(); 660} 661 662} // namespace 663 664FilePathWatcher::FilePathWatcher() { 665 impl_ = new FilePathWatcherImpl(); 666} 667 668} // namespace base 669