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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 kStorageOpenHistogramName, | 361 kStorageOpenHistogramName, |
362 static_cast<int>(LocalStorageOpenHistogram::DIRECTORY_OPEN_FAILED), | 362 static_cast<int>(LocalStorageOpenHistogram::DIRECTORY_OPEN_FAILED), |
363 static_cast<int>(LocalStorageOpenHistogram::MAX)); | 363 static_cast<int>(LocalStorageOpenHistogram::MAX)); |
364 OnDatabaseOpened(false, leveldb::mojom::DatabaseError::OK); | 364 OnDatabaseOpened(false, leveldb::mojom::DatabaseError::OK); |
365 return; | 365 return; |
366 } | 366 } |
367 | 367 |
368 // Now that we have a directory, connect to the LevelDB service and get our | 368 // Now that we have a directory, connect to the LevelDB service and get our |
369 // database. | 369 // database. |
370 file_service_connection_->GetInterface(&leveldb_service_); | 370 file_service_connection_->GetInterface(&leveldb_service_); |
371 leveldb_service_->SetEnvironmentName("LevelDBEnv.LocalStorage"); | |
372 | 371 |
373 // We might still need to use the directory, so create a clone. | 372 // We might still need to use the directory, so create a clone. |
374 filesystem::mojom::DirectoryPtr directory_clone; | 373 filesystem::mojom::DirectoryPtr directory_clone; |
375 directory_->Clone(MakeRequest(&directory_clone)); | 374 directory_->Clone(MakeRequest(&directory_clone)); |
376 | 375 |
377 auto options = leveldb::mojom::OpenOptions::New(); | 376 auto options = leveldb::mojom::OpenOptions::New(); |
378 options->create_if_missing = true; | 377 options->create_if_missing = true; |
379 leveldb_service_->OpenWithOptions( | 378 leveldb_service_->OpenWithOptions( |
380 std::move(options), std::move(directory_clone), "leveldb", | 379 std::move(options), std::move(directory_clone), "leveldb", |
381 MakeRequest(&database_), | 380 MakeRequest(&database_), |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 for (const auto& info : usage) { | 588 for (const auto& info : usage) { |
590 url::Origin origin_candidate(info.origin); | 589 url::Origin origin_candidate(info.origin); |
591 if (!origin_candidate.IsSameOriginWith(origin) && | 590 if (!origin_candidate.IsSameOriginWith(origin) && |
592 origin_candidate.IsSamePhysicalOriginWith(origin)) | 591 origin_candidate.IsSamePhysicalOriginWith(origin)) |
593 DeleteStorage(origin_candidate); | 592 DeleteStorage(origin_candidate); |
594 } | 593 } |
595 DeleteStorage(origin); | 594 DeleteStorage(origin); |
596 } | 595 } |
597 | 596 |
598 } // namespace content | 597 } // namespace content |
OLD | NEW |