Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: content/browser/dom_storage/local_storage_context_mojo.cc

Issue 2722293002: Fix lifetime of leveldb::MojoEnv instances. (Closed)
Patch Set: annotate leaks Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 kStorageOpenHistogramName, 351 kStorageOpenHistogramName,
352 static_cast<int>(LocalStorageOpenHistogram::DIRECTORY_OPEN_FAILED), 352 static_cast<int>(LocalStorageOpenHistogram::DIRECTORY_OPEN_FAILED),
353 static_cast<int>(LocalStorageOpenHistogram::MAX)); 353 static_cast<int>(LocalStorageOpenHistogram::MAX));
354 OnDatabaseOpened(false, leveldb::mojom::DatabaseError::OK); 354 OnDatabaseOpened(false, leveldb::mojom::DatabaseError::OK);
355 return; 355 return;
356 } 356 }
357 357
358 // Now that we have a directory, connect to the LevelDB service and get our 358 // Now that we have a directory, connect to the LevelDB service and get our
359 // database. 359 // database.
360 connector_->BindInterface(file::mojom::kServiceName, &leveldb_service_); 360 connector_->BindInterface(file::mojom::kServiceName, &leveldb_service_);
361 leveldb_service_->SetEnvironmentName("LevelDBEnv.LocalStorage");
362 361
363 // We might still need to use the directory, so create a clone. 362 // We might still need to use the directory, so create a clone.
364 filesystem::mojom::DirectoryPtr directory_clone; 363 filesystem::mojom::DirectoryPtr directory_clone;
365 directory_->Clone(MakeRequest(&directory_clone)); 364 directory_->Clone(MakeRequest(&directory_clone));
366 365
367 auto options = leveldb::mojom::OpenOptions::New(); 366 auto options = leveldb::mojom::OpenOptions::New();
368 options->create_if_missing = true; 367 options->create_if_missing = true;
369 leveldb_service_->OpenWithOptions( 368 leveldb_service_->OpenWithOptions(
370 std::move(options), std::move(directory_clone), "leveldb", 369 std::move(options), std::move(directory_clone), "leveldb",
371 MakeRequest(&database_), 370 MakeRequest(&database_),
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 for (const auto& info : usage) { 578 for (const auto& info : usage) {
580 url::Origin origin_candidate(info.origin); 579 url::Origin origin_candidate(info.origin);
581 if (!origin_candidate.IsSameOriginWith(origin) && 580 if (!origin_candidate.IsSameOriginWith(origin) &&
582 origin_candidate.IsSamePhysicalOriginWith(origin)) 581 origin_candidate.IsSamePhysicalOriginWith(origin))
583 DeleteStorage(origin_candidate); 582 DeleteStorage(origin_candidate);
584 } 583 }
585 DeleteStorage(origin); 584 DeleteStorage(origin);
586 } 585 }
587 586
588 } // namespace content 587 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698