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

Unified Diff: content/browser/browser_context.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 side-by-side diff with in-line comments
Download patch
Index: content/browser/browser_context.cc
diff --git a/content/browser/browser_context.cc b/content/browser/browser_context.cc
index 638e0ecc2ff862914320523ccebf325b8decfda3..7e8750baf464843c5461a8ce42056b7a43b3946d 100644
--- a/content/browser/browser_context.cc
+++ b/content/browser/browser_context.cc
@@ -13,12 +13,14 @@
#include <vector>
#include "base/command_line.h"
+#include "base/debug/leak_annotations.h"
#include "base/guid.h"
#include "base/lazy_instance.h"
#include "base/macros.h"
#include "base/rand_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
+#include "components/leveldb/env_mojo.h"
#include "content/browser/blob_storage/chrome_blob_storage_context.h"
#include "content/browser/download/download_manager_impl.h"
#include "content/browser/indexed_db/indexed_db_context_impl.h"
@@ -456,10 +458,13 @@ void BrowserContext::Initialize(
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kMojoLocalStorage)) {
ServiceInfo info;
- info.factory =
- base::Bind(&file::CreateFileService,
- BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE),
- BrowserThread::GetTaskRunnerForThread(BrowserThread::DB));
+ auto* env = new leveldb::MojoEnv(
+ BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE));
+ ANNOTATE_LEAKING_OBJECT_PTR(env);
+ info.factory = base::Bind(
+ &file::CreateFileService,
+ env,
+ BrowserThread::GetTaskRunnerForThread(BrowserThread::DB));
connection->AddEmbeddedService(file::mojom::kServiceName, info);
}

Powered by Google App Engine
This is Rietveld 408576698