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

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

Issue 2868114: Rework FileWatcher to avoid race condition upon deletion. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Add missing return... Created 10 years, 4 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
« no previous file with comments | « chrome/browser/file_watcher_unittest.cc ('k') | chrome/browser/user_style_sheet_watcher.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_watcher.h" 5 #include "chrome/browser/file_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/object_watcher.h" 10 #include "base/object_watcher.h"
11 #include "base/ref_counted.h" 11 #include "base/ref_counted.h"
12 #include "base/time.h" 12 #include "base/time.h"
13 13
14 namespace { 14 namespace {
15 15
16 class FileWatcherImpl : public FileWatcher::PlatformDelegate, 16 class FileWatcherImpl : public FileWatcher::PlatformDelegate,
17 public base::ObjectWatcher::Delegate { 17 public base::ObjectWatcher::Delegate {
18 public: 18 public:
19 FileWatcherImpl() : delegate_(NULL), handle_(INVALID_HANDLE_VALUE) {} 19 FileWatcherImpl() : delegate_(NULL), handle_(INVALID_HANDLE_VALUE) {}
20 20
21 virtual bool Watch(const FilePath& path, FileWatcher::Delegate* delegate); 21 virtual bool Watch(const FilePath& path, FileWatcher::Delegate* delegate);
22 22
23 // Callback from MessageLoopForIO. 23 // Callback from MessageLoopForIO.
24 virtual void OnObjectSignaled(HANDLE object); 24 virtual void OnObjectSignaled(HANDLE object);
25 25
26 private: 26 private:
27 virtual ~FileWatcherImpl(); 27 virtual ~FileWatcherImpl();
28 28
29 // Delegate to notify upon changes. 29 // Delegate to notify upon changes.
30 FileWatcher::Delegate* delegate_; 30 scoped_refptr<FileWatcher::Delegate> delegate_;
31 31
32 // Path we're watching (passed to delegate). 32 // Path we're watching (passed to delegate).
33 FilePath path_; 33 FilePath path_;
34 34
35 // Handle for FindFirstChangeNotification. 35 // Handle for FindFirstChangeNotification.
36 HANDLE handle_; 36 HANDLE handle_;
37 37
38 // ObjectWatcher to watch handle_ for events. 38 // ObjectWatcher to watch handle_ for events.
39 base::ObjectWatcher watcher_; 39 base::ObjectWatcher watcher_;
40 40
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 BOOL ok = FindNextChangeNotification(object); 102 BOOL ok = FindNextChangeNotification(object);
103 DCHECK(ok); 103 DCHECK(ok);
104 watcher_.StartWatching(object, this); 104 watcher_.StartWatching(object, this);
105 } 105 }
106 106
107 } // namespace 107 } // namespace
108 108
109 FileWatcher::FileWatcher() { 109 FileWatcher::FileWatcher() {
110 impl_ = new FileWatcherImpl(); 110 impl_ = new FileWatcherImpl();
111 } 111 }
OLDNEW
« no previous file with comments | « chrome/browser/file_watcher_unittest.cc ('k') | chrome/browser/user_style_sheet_watcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698