| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/base/file_flusher.h" | 5 #include "chrome/browser/chromeos/base/file_flusher.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 DCHECK(!started()); | 91 DCHECK(!started()); |
| 92 | 92 |
| 93 started_ = true; | 93 started_ = true; |
| 94 | 94 |
| 95 if (cancel_flag_.IsSet()) { | 95 if (cancel_flag_.IsSet()) { |
| 96 ScheduleFinish(); | 96 ScheduleFinish(); |
| 97 return; | 97 return; |
| 98 } | 98 } |
| 99 | 99 |
| 100 base::PostTaskWithTraitsAndReply( | 100 base::PostTaskWithTraitsAndReply( |
| 101 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( | 101 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, |
| 102 base::TaskPriority::BACKGROUND), | |
| 103 base::Bind(&FileFlusher::Job::FlushAsync, base::Unretained(this)), | 102 base::Bind(&FileFlusher::Job::FlushAsync, base::Unretained(this)), |
| 104 base::Bind(&FileFlusher::Job::FinishOnUIThread, base::Unretained(this))); | 103 base::Bind(&FileFlusher::Job::FinishOnUIThread, base::Unretained(this))); |
| 105 } | 104 } |
| 106 | 105 |
| 107 void FileFlusher::Job::Cancel() { | 106 void FileFlusher::Job::Cancel() { |
| 108 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 107 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 109 | 108 |
| 110 cancel_flag_.Set(); | 109 cancel_flag_.Set(); |
| 111 | 110 |
| 112 // Cancel() could be called in an iterator/range loop in master thus don't | 111 // Cancel() could be called in an iterator/range loop in master thus don't |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 if (*it == job) { | 213 if (*it == job) { |
| 215 jobs_.erase(it); | 214 jobs_.erase(it); |
| 216 break; | 215 break; |
| 217 } | 216 } |
| 218 } | 217 } |
| 219 | 218 |
| 220 ScheduleJob(); | 219 ScheduleJob(); |
| 221 } | 220 } |
| 222 | 221 |
| 223 } // namespace chromeos | 222 } // namespace chromeos |
| OLD | NEW |