| 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 "content/browser/dom_storage/local_storage_context_mojo.h" | 5 #include "content/browser/dom_storage/local_storage_context_mojo.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "components/leveldb/public/cpp/util.h" | 10 #include "components/leveldb/public/cpp/util.h" |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 void LocalStorageContextMojo::Flush() { | 273 void LocalStorageContextMojo::Flush() { |
| 274 if (connection_state_ != CONNECTION_FINISHED) { | 274 if (connection_state_ != CONNECTION_FINISHED) { |
| 275 RunWhenConnected(base::BindOnce(&LocalStorageContextMojo::Flush, | 275 RunWhenConnected(base::BindOnce(&LocalStorageContextMojo::Flush, |
| 276 weak_ptr_factory_.GetWeakPtr())); | 276 weak_ptr_factory_.GetWeakPtr())); |
| 277 return; | 277 return; |
| 278 } | 278 } |
| 279 for (const auto& it : level_db_wrappers_) | 279 for (const auto& it : level_db_wrappers_) |
| 280 it.second->level_db_wrapper()->ScheduleImmediateCommit(); | 280 it.second->level_db_wrapper()->ScheduleImmediateCommit(); |
| 281 } | 281 } |
| 282 | 282 |
| 283 void LocalStorageContextMojo::PurgeMemory() { |
| 284 for (const auto& it : level_db_wrappers_) |
| 285 it.second->level_db_wrapper()->PurgeMemory(); |
| 286 } |
| 287 |
| 283 leveldb::mojom::LevelDBDatabaseAssociatedRequest | 288 leveldb::mojom::LevelDBDatabaseAssociatedRequest |
| 284 LocalStorageContextMojo::DatabaseRequestForTesting() { | 289 LocalStorageContextMojo::DatabaseRequestForTesting() { |
| 285 DCHECK_EQ(connection_state_, NO_CONNECTION); | 290 DCHECK_EQ(connection_state_, NO_CONNECTION); |
| 286 connection_state_ = CONNECTION_IN_PROGRESS; | 291 connection_state_ = CONNECTION_IN_PROGRESS; |
| 287 leveldb::mojom::LevelDBDatabaseAssociatedRequest request = | 292 leveldb::mojom::LevelDBDatabaseAssociatedRequest request = |
| 288 MakeRequestForTesting(&database_); | 293 MakeRequestForTesting(&database_); |
| 289 OnDatabaseOpened(true, leveldb::mojom::DatabaseError::OK); | 294 OnDatabaseOpened(true, leveldb::mojom::DatabaseError::OK); |
| 290 return request; | 295 return request; |
| 291 } | 296 } |
| 292 | 297 |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 for (const auto& info : usage) { | 589 for (const auto& info : usage) { |
| 585 url::Origin origin_candidate(info.origin); | 590 url::Origin origin_candidate(info.origin); |
| 586 if (!origin_candidate.IsSameOriginWith(origin) && | 591 if (!origin_candidate.IsSameOriginWith(origin) && |
| 587 origin_candidate.IsSamePhysicalOriginWith(origin)) | 592 origin_candidate.IsSamePhysicalOriginWith(origin)) |
| 588 DeleteStorage(origin_candidate); | 593 DeleteStorage(origin_candidate); |
| 589 } | 594 } |
| 590 DeleteStorage(origin); | 595 DeleteStorage(origin); |
| 591 } | 596 } |
| 592 | 597 |
| 593 } // namespace content | 598 } // namespace content |
| OLD | NEW |