| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/indexed_db/indexed_db_context_impl.h" | 5 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 std::string origin_id = file_path.BaseName().RemoveExtension() | 75 std::string origin_id = file_path.BaseName().RemoveExtension() |
| 76 .RemoveExtension().MaybeAsASCII(); | 76 .RemoveExtension().MaybeAsASCII(); |
| 77 origins->push_back(Origin(storage::GetOriginFromIdentifier(origin_id))); | 77 origins->push_back(Origin(storage::GetOriginFromIdentifier(origin_id))); |
| 78 if (file_paths) | 78 if (file_paths) |
| 79 file_paths->push_back(file_path); | 79 file_paths->push_back(file_path); |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 | 83 |
| 84 // This will be called after the IndexedDBContext is destroyed. | 84 // This will be called after the IndexedDBContext is destroyed. |
| 85 void ClearSessionOnlyOrigins( | 85 void IndexedDBClearSessionOnlyOrigins( |
| 86 const base::FilePath& indexeddb_path, | 86 const base::FilePath& indexeddb_path, |
| 87 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy) { | 87 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy) { |
| 88 // TODO(jsbell): DCHECK that this is running on an IndexedDB sequence, | 88 // TODO(jsbell): DCHECK that this is running on an IndexedDB sequence, |
| 89 // if a global handle to it is ever available. | 89 // if a global handle to it is ever available. |
| 90 std::vector<Origin> origins; | 90 std::vector<Origin> origins; |
| 91 std::vector<base::FilePath> file_paths; | 91 std::vector<base::FilePath> file_paths; |
| 92 GetAllOriginsAndPaths(indexeddb_path, &origins, &file_paths); | 92 GetAllOriginsAndPaths(indexeddb_path, &origins, &file_paths); |
| 93 DCHECK_EQ(origins.size(), file_paths.size()); | 93 DCHECK_EQ(origins.size(), file_paths.size()); |
| 94 auto file_path = file_paths.cbegin(); | 94 auto file_path = file_paths.cbegin(); |
| 95 auto origin = origins.cbegin(); | 95 auto origin = origins.cbegin(); |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 | 485 |
| 486 bool has_session_only_databases = | 486 bool has_session_only_databases = |
| 487 special_storage_policy_.get() && | 487 special_storage_policy_.get() && |
| 488 special_storage_policy_->HasSessionOnlyOrigins(); | 488 special_storage_policy_->HasSessionOnlyOrigins(); |
| 489 | 489 |
| 490 // Clearing only session-only databases, and there are none. | 490 // Clearing only session-only databases, and there are none. |
| 491 if (!has_session_only_databases) | 491 if (!has_session_only_databases) |
| 492 return; | 492 return; |
| 493 | 493 |
| 494 TaskRunner()->PostTask(FROM_HERE, | 494 TaskRunner()->PostTask(FROM_HERE, |
| 495 base::BindOnce(&ClearSessionOnlyOrigins, data_path_, | 495 base::BindOnce(&IndexedDBClearSessionOnlyOrigins, data_
path_, |
| 496 special_storage_policy_)); | 496 special_storage_policy_)); |
| 497 } | 497 } |
| 498 | 498 |
| 499 // static | 499 // static |
| 500 base::FilePath IndexedDBContextImpl::GetBlobStoreFileName( | 500 base::FilePath IndexedDBContextImpl::GetBlobStoreFileName( |
| 501 const Origin& origin) { | 501 const Origin& origin) { |
| 502 std::string origin_id = storage::GetIdentifierFromOrigin(origin.GetURL()); | 502 std::string origin_id = storage::GetIdentifierFromOrigin(origin.GetURL()); |
| 503 return base::FilePath() | 503 return base::FilePath() |
| 504 .AppendASCII(origin_id) | 504 .AppendASCII(origin_id) |
| 505 .AddExtension(kIndexedDBExtension) | 505 .AddExtension(kIndexedDBExtension) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 } | 563 } |
| 564 return origin_set_.get(); | 564 return origin_set_.get(); |
| 565 } | 565 } |
| 566 | 566 |
| 567 base::SequencedTaskRunner* IndexedDBContextImpl::TaskRunner() const { | 567 base::SequencedTaskRunner* IndexedDBContextImpl::TaskRunner() const { |
| 568 DCHECK(task_runner_.get()); | 568 DCHECK(task_runner_.get()); |
| 569 return task_runner_.get(); | 569 return task_runner_.get(); |
| 570 } | 570 } |
| 571 | 571 |
| 572 } // namespace content | 572 } // namespace content |
| OLD | NEW |