| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 : public base::RefCountedThreadSafe<NotificationCollector> { | 37 : public base::RefCountedThreadSafe<NotificationCollector> { |
| 38 public: | 38 public: |
| 39 NotificationCollector() | 39 NotificationCollector() |
| 40 : loop_(base::MessageLoopProxy::CreateForCurrentThread()) {} | 40 : loop_(base::MessageLoopProxy::CreateForCurrentThread()) {} |
| 41 | 41 |
| 42 // Called from the file thread by the delegates. | 42 // Called from the file thread by the delegates. |
| 43 void OnChange(TestDelegate* delegate) { | 43 void OnChange(TestDelegate* delegate) { |
| 44 loop_->PostTask(FROM_HERE, | 44 loop_->PostTask(FROM_HERE, |
| 45 NewRunnableMethod(this, | 45 NewRunnableMethod(this, |
| 46 &NotificationCollector::RecordChange, | 46 &NotificationCollector::RecordChange, |
| 47 delegate)); | 47 make_scoped_refptr(delegate))); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void Register(TestDelegate* delegate) { | 50 void Register(TestDelegate* delegate) { |
| 51 delegates_.insert(delegate); | 51 delegates_.insert(delegate); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void Reset() { | 54 void Reset() { |
| 55 signaled_.clear(); | 55 signaled_.clear(); |
| 56 } | 56 } |
| 57 | 57 |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 SetupWatch(dest_file, &file_watcher, file_delegate.get()); | 446 SetupWatch(dest_file, &file_watcher, file_delegate.get()); |
| 447 scoped_refptr<TestDelegate> subdir_delegate(new TestDelegate(collector())); | 447 scoped_refptr<TestDelegate> subdir_delegate(new TestDelegate(collector())); |
| 448 SetupWatch(dest_subdir, &subdir_watcher, subdir_delegate.get()); | 448 SetupWatch(dest_subdir, &subdir_watcher, subdir_delegate.get()); |
| 449 | 449 |
| 450 // Move the directory into place, s.t. the watched file appears. | 450 // Move the directory into place, s.t. the watched file appears. |
| 451 ASSERT_TRUE(file_util::Move(source_dir, dest_dir)); | 451 ASSERT_TRUE(file_util::Move(source_dir, dest_dir)); |
| 452 WaitForEvents(); | 452 WaitForEvents(); |
| 453 } | 453 } |
| 454 | 454 |
| 455 } // namespace | 455 } // namespace |
| OLD | NEW |