OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/chromeos/file_manager/file_watcher.h" | 5 #include "chrome/browser/chromeos/file_manager/file_watcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
9 #include "google_apis/drive/task_util.h" | 9 #include "google_apis/drive/task_util.h" |
10 | 10 |
11 using content::BrowserThread; | 11 using content::BrowserThread; |
12 | 12 |
13 namespace file_manager { | 13 namespace file_manager { |
14 namespace { | 14 namespace { |
15 | 15 |
16 // Creates a base::FilePathWatcher and starts watching at |watch_path| with | 16 // Creates a base::FilePathWatcher and starts watching at |watch_path| with |
17 // |callback|. Returns NULL on failure. | 17 // |callback|. Returns NULL on failure. |
18 base::FilePathWatcher* CreateAndStartFilePathWatcher( | 18 base::FilePathWatcher* CreateAndStartFilePathWatcher( |
19 const base::FilePath& watch_path, | 19 const base::FilePath& watch_path, |
20 const base::FilePathWatcher::Callback& callback) { | 20 const base::FilePathWatcher::Callback& callback) { |
21 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 21 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
22 DCHECK(!callback.is_null()); | 22 DCHECK(!callback.is_null()); |
23 | 23 |
24 scoped_ptr<base::FilePathWatcher> watcher(new base::FilePathWatcher); | 24 std::unique_ptr<base::FilePathWatcher> watcher(new base::FilePathWatcher); |
25 if (!watcher->Watch(watch_path, false /* recursive */, callback)) | 25 if (!watcher->Watch(watch_path, false /* recursive */, callback)) |
26 return NULL; | 26 return NULL; |
27 | 27 |
28 return watcher.release(); | 28 return watcher.release(); |
29 } | 29 } |
30 | 30 |
31 } // namespace | 31 } // namespace |
32 | 32 |
33 FileWatcher::FileWatcher(const base::FilePath& virtual_path) | 33 FileWatcher::FileWatcher(const base::FilePath& virtual_path) |
34 : local_file_watcher_(NULL), | 34 : local_file_watcher_(NULL), |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 if (file_watcher) { | 107 if (file_watcher) { |
108 local_file_watcher_ = file_watcher; | 108 local_file_watcher_ = file_watcher; |
109 callback.Run(true); | 109 callback.Run(true); |
110 } else { | 110 } else { |
111 callback.Run(false); | 111 callback.Run(false); |
112 } | 112 } |
113 } | 113 } |
114 | 114 |
115 } // namespace file_manager | 115 } // namespace file_manager |
OLD | NEW |