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 "content/browser/dom_storage/dom_storage_context_wrapper.h" | 5 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 // of other values being set, so changes are batched. | 237 // of other values being set, so changes are batched. |
238 const int kCommitDefaultDelaySecs = 5; | 238 const int kCommitDefaultDelaySecs = 5; |
239 | 239 |
240 // To avoid excessive IO we apply limits to the amount of data being written | 240 // To avoid excessive IO we apply limits to the amount of data being written |
241 // and the frequency of writes. | 241 // and the frequency of writes. |
242 const int kMaxBytesPerHour = kPerStorageAreaQuota; | 242 const int kMaxBytesPerHour = kPerStorageAreaQuota; |
243 const int kMaxCommitsPerHour = 60; | 243 const int kMaxCommitsPerHour = 60; |
244 | 244 |
245 auto found = level_db_wrappers_.find(origin); | 245 auto found = level_db_wrappers_.find(origin); |
246 if (found == level_db_wrappers_.end()) { | 246 if (found == level_db_wrappers_.end()) { |
247 level_db_wrappers_[origin] = base::WrapUnique(new LevelDBWrapperImpl( | 247 level_db_wrappers_[origin] = base::MakeUnique<LevelDBWrapperImpl>( |
248 database_.get(), origin.Serialize(), | 248 database_.get(), origin.Serialize(), |
249 kPerStorageAreaQuota + kPerStorageAreaOverQuotaAllowance, | 249 kPerStorageAreaQuota + kPerStorageAreaOverQuotaAllowance, |
250 base::TimeDelta::FromSeconds(kCommitDefaultDelaySecs), | 250 base::TimeDelta::FromSeconds(kCommitDefaultDelaySecs), kMaxBytesPerHour, |
251 kMaxBytesPerHour, kMaxCommitsPerHour, | 251 kMaxCommitsPerHour, |
252 base::Bind(&MojoState::OnLevelDDWrapperHasNoBindings, | 252 base::Bind(&MojoState::OnLevelDDWrapperHasNoBindings, |
253 base::Unretained(this), origin))); | 253 base::Unretained(this), origin)); |
254 found = level_db_wrappers_.find(origin); | 254 found = level_db_wrappers_.find(origin); |
255 } | 255 } |
256 | 256 |
257 found->second->Bind(std::move(request)); | 257 found->second->Bind(std::move(request)); |
258 found->second->AddObserver(std::move(observer)); | 258 found->second->AddObserver(std::move(observer)); |
259 } | 259 } |
260 | 260 |
261 DOMStorageContextWrapper::DOMStorageContextWrapper( | 261 DOMStorageContextWrapper::DOMStorageContextWrapper( |
262 shell::Connector* connector, | 262 shell::Connector* connector, |
263 const base::FilePath& profile_path, | 263 const base::FilePath& profile_path, |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 if (memory_pressure_level == | 389 if (memory_pressure_level == |
390 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) { | 390 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) { |
391 purge_option = DOMStorageContextImpl::PURGE_AGGRESSIVE; | 391 purge_option = DOMStorageContextImpl::PURGE_AGGRESSIVE; |
392 } | 392 } |
393 context_->task_runner()->PostTask( | 393 context_->task_runner()->PostTask( |
394 FROM_HERE, | 394 FROM_HERE, |
395 base::Bind(&DOMStorageContextImpl::PurgeMemory, context_, purge_option)); | 395 base::Bind(&DOMStorageContextImpl::PurgeMemory, context_, purge_option)); |
396 } | 396 } |
397 | 397 |
398 } // namespace content | 398 } // namespace content |
OLD | NEW |