| 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 } | 264 } |
| 265 | 265 |
| 266 void LocalStorageContextMojo::DeleteStorageForPhysicalOrigin( | 266 void LocalStorageContextMojo::DeleteStorageForPhysicalOrigin( |
| 267 const url::Origin& origin) { | 267 const url::Origin& origin) { |
| 268 GetStorageUsage(base::BindOnce( | 268 GetStorageUsage(base::BindOnce( |
| 269 &LocalStorageContextMojo::OnGotStorageUsageForDeletePhysicalOrigin, | 269 &LocalStorageContextMojo::OnGotStorageUsageForDeletePhysicalOrigin, |
| 270 weak_ptr_factory_.GetWeakPtr(), origin)); | 270 weak_ptr_factory_.GetWeakPtr(), origin)); |
| 271 } | 271 } |
| 272 | 272 |
| 273 void LocalStorageContextMojo::Flush() { | 273 void LocalStorageContextMojo::Flush() { |
| 274 if (connection_state_ != CONNECTION_FINISHED) { |
| 275 RunWhenConnected(base::BindOnce(&LocalStorageContextMojo::Flush, |
| 276 weak_ptr_factory_.GetWeakPtr())); |
| 277 return; |
| 278 } |
| 274 for (const auto& it : level_db_wrappers_) | 279 for (const auto& it : level_db_wrappers_) |
| 275 it.second->level_db_wrapper()->ScheduleImmediateCommit(); | 280 it.second->level_db_wrapper()->ScheduleImmediateCommit(); |
| 276 } | 281 } |
| 277 | 282 |
| 278 leveldb::mojom::LevelDBDatabaseAssociatedRequest | 283 leveldb::mojom::LevelDBDatabaseAssociatedRequest |
| 279 LocalStorageContextMojo::DatabaseRequestForTesting() { | 284 LocalStorageContextMojo::DatabaseRequestForTesting() { |
| 280 DCHECK_EQ(connection_state_, NO_CONNECTION); | 285 DCHECK_EQ(connection_state_, NO_CONNECTION); |
| 281 connection_state_ = CONNECTION_IN_PROGRESS; | 286 connection_state_ = CONNECTION_IN_PROGRESS; |
| 282 leveldb::mojom::LevelDBDatabaseAssociatedRequest request = | 287 leveldb::mojom::LevelDBDatabaseAssociatedRequest request = |
| 283 MakeRequestForTesting(&database_); | 288 MakeRequestForTesting(&database_); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 for (const auto& info : usage) { | 584 for (const auto& info : usage) { |
| 580 url::Origin origin_candidate(info.origin); | 585 url::Origin origin_candidate(info.origin); |
| 581 if (!origin_candidate.IsSameOriginWith(origin) && | 586 if (!origin_candidate.IsSameOriginWith(origin) && |
| 582 origin_candidate.IsSamePhysicalOriginWith(origin)) | 587 origin_candidate.IsSamePhysicalOriginWith(origin)) |
| 583 DeleteStorage(origin_candidate); | 588 DeleteStorage(origin_candidate); |
| 584 } | 589 } |
| 585 DeleteStorage(origin); | 590 DeleteStorage(origin); |
| 586 } | 591 } |
| 587 | 592 |
| 588 } // namespace content | 593 } // namespace content |
| OLD | NEW |