| 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/sync_file_system/local/syncable_file_operation_runner.h
" | 5 #include "chrome/browser/sync_file_system/local/syncable_file_operation_runner.h
" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 |
| 7 #include <algorithm> | 9 #include <algorithm> |
| 8 #include <functional> | 10 #include <functional> |
| 9 | 11 |
| 10 #include "base/callback.h" | 12 #include "base/callback.h" |
| 11 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 12 | 14 |
| 13 using storage::FileSystemURL; | 15 using storage::FileSystemURL; |
| 14 | 16 |
| 15 namespace sync_file_system { | 17 namespace sync_file_system { |
| 16 | 18 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 36 for (size_t i = 0; i < target_paths().size(); ++i) { | 38 for (size_t i = 0; i < target_paths().size(); ++i) { |
| 37 DCHECK(status->IsWritable(target_paths()[i])); | 39 DCHECK(status->IsWritable(target_paths()[i])); |
| 38 status->StartWriting(target_paths()[i]); | 40 status->StartWriting(target_paths()[i]); |
| 39 } | 41 } |
| 40 Run(); | 42 Run(); |
| 41 } | 43 } |
| 42 | 44 |
| 43 // SyncableFileOperationRunner ------------------------------------------------- | 45 // SyncableFileOperationRunner ------------------------------------------------- |
| 44 | 46 |
| 45 SyncableFileOperationRunner::SyncableFileOperationRunner( | 47 SyncableFileOperationRunner::SyncableFileOperationRunner( |
| 46 int64 max_inflight_tasks, | 48 int64_t max_inflight_tasks, |
| 47 LocalFileSyncStatus* sync_status) | 49 LocalFileSyncStatus* sync_status) |
| 48 : sync_status_(sync_status), | 50 : sync_status_(sync_status), |
| 49 max_inflight_tasks_(max_inflight_tasks), | 51 max_inflight_tasks_(max_inflight_tasks), |
| 50 num_inflight_tasks_(0) { | 52 num_inflight_tasks_(0) { |
| 51 DCHECK(CalledOnValidThread()); | 53 DCHECK(CalledOnValidThread()); |
| 52 sync_status_->AddObserver(this); | 54 sync_status_->AddObserver(this); |
| 53 } | 55 } |
| 54 | 56 |
| 55 SyncableFileOperationRunner::~SyncableFileOperationRunner() { | 57 SyncableFileOperationRunner::~SyncableFileOperationRunner() { |
| 56 DCHECK(CalledOnValidThread()); | 58 DCHECK(CalledOnValidThread()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 sync_status()->EndWriting(target_paths[i]); | 99 sync_status()->EndWriting(target_paths[i]); |
| 98 } | 100 } |
| 99 RunNextRunnableTask(); | 101 RunNextRunnableTask(); |
| 100 } | 102 } |
| 101 | 103 |
| 102 bool SyncableFileOperationRunner::ShouldStartMoreTasks() const { | 104 bool SyncableFileOperationRunner::ShouldStartMoreTasks() const { |
| 103 return num_inflight_tasks_ < max_inflight_tasks_; | 105 return num_inflight_tasks_ < max_inflight_tasks_; |
| 104 } | 106 } |
| 105 | 107 |
| 106 } // namespace sync_file_system | 108 } // namespace sync_file_system |
| OLD | NEW |