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: components/drive/file_write_watcher.cc

Issue 2837863004: Use base::OneShotTimer instead of base::Timer(false, false)
Patch Set: rebase Created 3 years, 7 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
OLDNEW
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> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 const StartWatchCallback& on_start_callback, 56 const StartWatchCallback& on_start_callback,
57 const base::Closure& on_write_callback); 57 const base::Closure& on_write_callback);
58 58
59 void OnWriteEvent(const base::FilePath& path, bool error); 59 void OnWriteEvent(const base::FilePath& path, bool error);
60 60
61 void InvokeCallback(const base::FilePath& path); 61 void InvokeCallback(const base::FilePath& path);
62 62
63 struct PathWatchInfo { 63 struct PathWatchInfo {
64 std::vector<base::Closure> on_write_callbacks; 64 std::vector<base::Closure> on_write_callbacks;
65 base::FilePathWatcher watcher; 65 base::FilePathWatcher watcher;
66 base::Timer timer; 66 base::OneShotTimer timer;
67 67
68 explicit PathWatchInfo(const base::Closure& on_write_callback) 68 explicit PathWatchInfo(const base::Closure& on_write_callback)
69 : on_write_callbacks(1, on_write_callback), 69 : on_write_callbacks(1, on_write_callback) {}
70 timer(false /* retain_closure_on_reset */, false /* is_repeating */) {
71 }
72 }; 70 };
73 71
74 base::TimeDelta delay_; 72 base::TimeDelta delay_;
75 std::map<base::FilePath, std::unique_ptr<PathWatchInfo>> watchers_; 73 std::map<base::FilePath, std::unique_ptr<PathWatchInfo>> watchers_;
76 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; 74 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
77 75
78 base::ThreadChecker thread_checker_; 76 base::ThreadChecker thread_checker_;
79 77
80 // Note: This should remain the last member so it'll be destroyed and 78 // Note: This should remain the last member so it'll be destroyed and
81 // invalidate its weak pointers before any other members are destroyed. 79 // invalidate its weak pointers before any other members are destroyed.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 DCHECK(thread_checker_.CalledOnValidThread()); 200 DCHECK(thread_checker_.CalledOnValidThread());
203 watcher_impl_->StartWatch(file_path, on_start_callback, on_write_callback); 201 watcher_impl_->StartWatch(file_path, on_start_callback, on_write_callback);
204 } 202 }
205 203
206 void FileWriteWatcher::DisableDelayForTesting() { 204 void FileWriteWatcher::DisableDelayForTesting() {
207 watcher_impl_->set_delay(base::TimeDelta()); 205 watcher_impl_->set_delay(base::TimeDelta());
208 } 206 }
209 207
210 } // namespace internal 208 } // namespace internal
211 } // namespace drive 209 } // namespace drive
OLDNEW
« no previous file with comments | « components/domain_reliability/util.cc ('k') | components/error_page/renderer/net_error_helper_core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698