| 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 "components/drive/file_write_watcher.h" | 5 #include "components/drive/file_write_watcher.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
| 7 #include <map> | 10 #include <map> |
| 8 #include <vector> | 11 #include <vector> |
| 9 | 12 |
| 10 #include "base/bind.h" | 13 #include "base/bind.h" |
| 11 #include "base/callback.h" | 14 #include "base/callback.h" |
| 12 #include "base/files/file_path_watcher.h" | 15 #include "base/files/file_path_watcher.h" |
| 16 #include "base/macros.h" |
| 13 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
| 14 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
| 15 #include "google_apis/drive/task_util.h" | 19 #include "google_apis/drive/task_util.h" |
| 16 | 20 |
| 17 namespace drive { | 21 namespace drive { |
| 18 namespace internal { | 22 namespace internal { |
| 19 | 23 |
| 20 namespace { | 24 namespace { |
| 21 const int64 kWriteEventDelayInSeconds = 5; | 25 const int64_t kWriteEventDelayInSeconds = 5; |
| 22 } // namespace | 26 } // namespace |
| 23 | 27 |
| 24 // base::FileWatcher needs to live in a thread that is allowed to do File IO | 28 // base::FileWatcher needs to live in a thread that is allowed to do File IO |
| 25 // and has a TYPE_IO message loop: that is, FILE thread. This class bridges the | 29 // and has a TYPE_IO message loop: that is, FILE thread. This class bridges the |
| 26 // UI thread and FILE thread, and does all the main tasks in the FILE thread. | 30 // UI thread and FILE thread, and does all the main tasks in the FILE thread. |
| 27 class FileWriteWatcher::FileWriteWatcherImpl { | 31 class FileWriteWatcher::FileWriteWatcherImpl { |
| 28 public: | 32 public: |
| 29 explicit FileWriteWatcherImpl(base::SingleThreadTaskRunner* file_task_runner); | 33 explicit FileWriteWatcherImpl(base::SingleThreadTaskRunner* file_task_runner); |
| 30 | 34 |
| 31 // Forwards the call to DestoryOnFileThread(). This method must be used to | 35 // Forwards the call to DestoryOnFileThread(). This method must be used to |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 DCHECK(thread_checker_.CalledOnValidThread()); | 202 DCHECK(thread_checker_.CalledOnValidThread()); |
| 199 watcher_impl_->StartWatch(file_path, on_start_callback, on_write_callback); | 203 watcher_impl_->StartWatch(file_path, on_start_callback, on_write_callback); |
| 200 } | 204 } |
| 201 | 205 |
| 202 void FileWriteWatcher::DisableDelayForTesting() { | 206 void FileWriteWatcher::DisableDelayForTesting() { |
| 203 watcher_impl_->set_delay(base::TimeDelta()); | 207 watcher_impl_->set_delay(base::TimeDelta()); |
| 204 } | 208 } |
| 205 | 209 |
| 206 } // namespace internal | 210 } // namespace internal |
| 207 } // namespace drive | 211 } // namespace drive |
| OLD | NEW |