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

Side by Side Diff: base/file_path_component_watcher.h

Issue 6660001: Getting service process on Mac to handle having things moved/changed underneath it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed up phajdan's comments, got things working properly Created 9 years, 9 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
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
Mark Mentovai 2011/03/11 20:13:52 What year is it? Throughout the entire change, th
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // This module provides a way to monitor a filepath for changes in the path.
TVL 2011/03/11 14:03:54 chrome/browser/file_path_watcher/file_path_watcher
Mark Mentovai 2011/03/11 20:13:52 TVL wrote:
Mark Mentovai 2011/03/11 20:13:52 filepath is two words.
6
7 #ifndef BASE_FILE_PATH_COMPONENT_WATCHER_H_
8 #define BASE_FILE_PATH_COMPONENT_WATCHER_H_
9 #pragma once
10
11 #include "base/basictypes.h"
12 #include "base/file_path.h"
13 #include "base/ref_counted.h"
14
15 namespace base {
16 // This class lets you register interest in changes on a FilePath.
17 // The delegate will get called whenever any components of a FilePath are
18 // changed (moved, deleted, attributes changed). This is different from
19 // FilePathWatcher, in that FilePathWatcher watches a single file, and it's
Mark Mentovai 2011/03/11 20:13:52 "single file, and it's" -> "single file and its"
20 // parent directory for changes, whereas this watches each component in a file's
21 // path for changes.
22 class FilePathComponentWatcher {
23 public:
24 // Declares the callback client code implements to receive notifications. Note
25 // that implementations of this interface should not keep a reference to the
26 // corresponding FileWatcher object to prevent a reference cycle.
Mark Mentovai 2011/03/11 20:13:52 What’s a FileWatcher object?
27 class Delegate : public base::RefCountedThreadSafe<Delegate> {
28 public:
29 virtual ~Delegate() {}
30 virtual void OnFilePathComponentsChanged(FilePathComponentWatcher* watcher,
31 const FilePath& old_path,
32 const FilePath& new_path) = 0;
33 // Called when platform specific code detected an error. The watcher will
Mark Mentovai 2011/03/11 20:13:52 Blank line before.
34 // not call OnFilePathChanged for future changes.
35 virtual void OnError(FilePathComponentWatcher* watcher) {}
36 };
37
38 FilePathComponentWatcher();
39 ~FilePathComponentWatcher();
40
41 // Register interest in any changes on |path|. OnPathChanged will be called
42 // back for each change. Returns true on success.
43 bool Watch(const FilePath& path, Delegate* delegate) WARN_UNUSED_RESULT;
Mark Mentovai 2011/03/11 20:13:52 Are you supposed to be able to call Watch twice on
44
45 // Used internally to encapsulate different members on different platforms.
Mark Mentovai 2011/03/11 20:13:52 I’m going to hold off on a thorough review of the
46 class PlatformDelegate
47 : public base::RefCountedThreadSafe<PlatformDelegate> {
Mark Mentovai 2011/03/11 20:13:52 What I just said notwithstanding… Why is the plat
48 public:
49 virtual ~PlatformDelegate() {}
50
51 // Start watching for the given |path| and notify |delegate| about changes.
52 virtual bool Watch(const FilePath& path, Delegate* delegate)
53 WARN_UNUSED_RESULT = 0;
54
55 // Stop watching. This is called from FilePathComponentWatcher's dtor
Mark Mentovai 2011/03/11 20:13:52 Spell things out. Destructor, not dtor.
56 // in order to allow it to shut down properly while the object is still
57 // alive.
58 virtual void Cancel() {}
59 };
60
61 private:
62 scoped_refptr<PlatformDelegate> impl_;
63
64 DISALLOW_COPY_AND_ASSIGN(FilePathComponentWatcher);
65 };
66
67 } // namespace
Mark Mentovai 2011/03/11 20:13:52 } // namespace base
68
69 #endif // BASE_FILE_PATH_COMPONENT_WATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698