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/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "components/leveldb/public/cpp/util.h" | 9 #include "components/leveldb/public/cpp/util.h" |
10 #include "components/leveldb/public/interfaces/leveldb.mojom.h" | 10 #include "components/leveldb/public/interfaces/leveldb.mojom.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 wrapper->ScheduleImmediateCommit(); | 90 wrapper->ScheduleImmediateCommit(); |
91 } | 91 } |
92 | 92 |
93 void LocalStorageContextMojo::DeleteStorageForPhysicalOrigin( | 93 void LocalStorageContextMojo::DeleteStorageForPhysicalOrigin( |
94 const url::Origin& origin) { | 94 const url::Origin& origin) { |
95 GetStorageUsage(base::BindOnce( | 95 GetStorageUsage(base::BindOnce( |
96 &LocalStorageContextMojo::OnGotStorageUsageForDeletePhysicalOrigin, | 96 &LocalStorageContextMojo::OnGotStorageUsageForDeletePhysicalOrigin, |
97 weak_ptr_factory_.GetWeakPtr(), origin)); | 97 weak_ptr_factory_.GetWeakPtr(), origin)); |
98 } | 98 } |
99 | 99 |
| 100 void LocalStorageContextMojo::Flush() { |
| 101 for (const auto& it : level_db_wrappers_) |
| 102 it.second->ScheduleImmediateCommit(); |
| 103 } |
| 104 |
100 void LocalStorageContextMojo::SetDatabaseForTesting( | 105 void LocalStorageContextMojo::SetDatabaseForTesting( |
101 leveldb::mojom::LevelDBDatabasePtr database) { | 106 leveldb::mojom::LevelDBDatabasePtr database) { |
102 DCHECK_EQ(connection_state_, NO_CONNECTION); | 107 DCHECK_EQ(connection_state_, NO_CONNECTION); |
103 connection_state_ = CONNECTION_IN_PROGRESS; | 108 connection_state_ = CONNECTION_IN_PROGRESS; |
104 database_ = std::move(database); | 109 database_ = std::move(database); |
105 OnDatabaseOpened(leveldb::mojom::DatabaseError::OK); | 110 OnDatabaseOpened(leveldb::mojom::DatabaseError::OK); |
106 } | 111 } |
107 | 112 |
108 void LocalStorageContextMojo::RunWhenConnected(base::OnceClosure callback) { | 113 void LocalStorageContextMojo::RunWhenConnected(base::OnceClosure callback) { |
109 // If we don't have a filesystem_connection_, we'll need to establish one. | 114 // If we don't have a filesystem_connection_, we'll need to establish one. |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 for (const auto& info : usage) { | 364 for (const auto& info : usage) { |
360 url::Origin origin_candidate(info.origin); | 365 url::Origin origin_candidate(info.origin); |
361 if (!origin_candidate.IsSameOriginWith(origin) && | 366 if (!origin_candidate.IsSameOriginWith(origin) && |
362 origin_candidate.IsSamePhysicalOriginWith(origin)) | 367 origin_candidate.IsSamePhysicalOriginWith(origin)) |
363 DeleteStorage(origin_candidate); | 368 DeleteStorage(origin_candidate); |
364 } | 369 } |
365 DeleteStorage(origin); | 370 DeleteStorage(origin); |
366 } | 371 } |
367 | 372 |
368 } // namespace content | 373 } // namespace content |
OLD | NEW |