OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_system_provider/throttled_file_system.h" | 5 #include "chrome/browser/chromeos/file_system_provider/throttled_file_system.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/files/file.h" | 13 #include "base/files/file.h" |
14 #include "chrome/browser/chromeos/file_system_provider/queue.h" | 14 #include "chrome/browser/chromeos/file_system_provider/queue.h" |
15 | 15 |
16 namespace chromeos { | 16 namespace chromeos { |
17 namespace file_system_provider { | 17 namespace file_system_provider { |
18 | 18 |
19 ThrottledFileSystem::ThrottledFileSystem( | 19 ThrottledFileSystem::ThrottledFileSystem( |
20 scoped_ptr<ProvidedFileSystemInterface> file_system) | 20 std::unique_ptr<ProvidedFileSystemInterface> file_system) |
21 : file_system_(std::move(file_system)), weak_ptr_factory_(this) { | 21 : file_system_(std::move(file_system)), weak_ptr_factory_(this) { |
22 const int opened_files_limit = | 22 const int opened_files_limit = |
23 file_system_->GetFileSystemInfo().opened_files_limit(); | 23 file_system_->GetFileSystemInfo().opened_files_limit(); |
24 open_queue_.reset(opened_files_limit | 24 open_queue_.reset(opened_files_limit |
25 ? new Queue(static_cast<size_t>(opened_files_limit)) | 25 ? new Queue(static_cast<size_t>(opened_files_limit)) |
26 : new Queue(std::numeric_limits<size_t>::max())); | 26 : new Queue(std::numeric_limits<size_t>::max())); |
27 } | 27 } |
28 | 28 |
29 ThrottledFileSystem::~ThrottledFileSystem() { | 29 ThrottledFileSystem::~ThrottledFileSystem() { |
30 } | 30 } |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 } | 185 } |
186 | 186 |
187 void ThrottledFileSystem::RemoveObserver(ProvidedFileSystemObserver* observer) { | 187 void ThrottledFileSystem::RemoveObserver(ProvidedFileSystemObserver* observer) { |
188 file_system_->RemoveObserver(observer); | 188 file_system_->RemoveObserver(observer); |
189 } | 189 } |
190 | 190 |
191 void ThrottledFileSystem::Notify( | 191 void ThrottledFileSystem::Notify( |
192 const base::FilePath& entry_path, | 192 const base::FilePath& entry_path, |
193 bool recursive, | 193 bool recursive, |
194 storage::WatcherManager::ChangeType change_type, | 194 storage::WatcherManager::ChangeType change_type, |
195 scoped_ptr<ProvidedFileSystemObserver::Changes> changes, | 195 std::unique_ptr<ProvidedFileSystemObserver::Changes> changes, |
196 const std::string& tag, | 196 const std::string& tag, |
197 const storage::AsyncFileUtil::StatusCallback& callback) { | 197 const storage::AsyncFileUtil::StatusCallback& callback) { |
198 return file_system_->Notify(entry_path, recursive, change_type, | 198 return file_system_->Notify(entry_path, recursive, change_type, |
199 std::move(changes), tag, callback); | 199 std::move(changes), tag, callback); |
200 } | 200 } |
201 | 201 |
202 void ThrottledFileSystem::Configure( | 202 void ThrottledFileSystem::Configure( |
203 const storage::AsyncFileUtil::StatusCallback& callback) { | 203 const storage::AsyncFileUtil::StatusCallback& callback) { |
204 return file_system_->Configure(callback); | 204 return file_system_->Configure(callback); |
205 } | 205 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 238 |
239 const int queue_token = it->second; | 239 const int queue_token = it->second; |
240 open_queue_->Complete(queue_token); | 240 open_queue_->Complete(queue_token); |
241 opened_files_.erase(file_handle); | 241 opened_files_.erase(file_handle); |
242 | 242 |
243 callback.Run(result); | 243 callback.Run(result); |
244 } | 244 } |
245 | 245 |
246 } // namespace file_system_provider | 246 } // namespace file_system_provider |
247 } // namespace chromeos | 247 } // namespace chromeos |
OLD | NEW |