From e6986dc6773be9c9715fd526da2fdb0676336cb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Riku=20Palom=C3=A4ki?= Date: Mon, 18 Mar 2019 18:34:38 -0400 Subject: [PATCH] Don't create cache directories in incognito mode (fixes issue #2289) --- patch/patch.cfg | 3 +- patch/patches/storage_partition_1973.patch | 44 ++++++++++++++++++++-- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/patch/patch.cfg b/patch/patch.cfg index d2ce79690..6b1e3ff2d 100644 --- a/patch/patch.cfg +++ b/patch/patch.cfg @@ -261,7 +261,8 @@ patches = [ # (c) Removing static_cast<> of StoragePartition to StoragePartitionImpl. # https://bitbucket.org/chromiumembedded/cef/issues/1973 # - # Don't create a "databases" directory when cache_path is empty. + # Don't create databases, blob_storage or VideoDecodeStats directories when + # cache_path is empty. # https://bitbucket.org/chromiumembedded/cef/issues/2289 'name': 'storage_partition_1973', }, diff --git a/patch/patches/storage_partition_1973.patch b/patch/patches/storage_partition_1973.patch index f5fb015e5..8fe76b0bd 100644 --- a/patch/patches/storage_partition_1973.patch +++ b/patch/patches/storage_partition_1973.patch @@ -38,7 +38,7 @@ index d56cc6909782..69c4e8c2877e 100644 render_frame_host->GetLastCommittedOrigin(), render_frame_host->GetFrameTreeNodeId(), std::move(wc_getter), diff --git content/browser/blob_storage/chrome_blob_storage_context.cc content/browser/blob_storage/chrome_blob_storage_context.cc -index 944324e66cad..6d2ddc4d04be 100644 +index 944324e66cad..a34d3ba83123 100644 --- content/browser/blob_storage/chrome_blob_storage_context.cc +++ content/browser/blob_storage/chrome_blob_storage_context.cc @@ -88,6 +88,11 @@ class BlobHandleImpl : public BlobHandle { @@ -53,6 +53,16 @@ index 944324e66cad..6d2ddc4d04be 100644 ChromeBlobStorageContext* ChromeBlobStorageContext::GetFor( BrowserContext* context) { DCHECK_CURRENTLY_ON(BrowserThread::UI); +@@ -116,7 +121,8 @@ ChromeBlobStorageContext* ChromeBlobStorageContext::GetFor( + + // If we're not incognito mode, schedule all of our file tasks to enable + // disk on the storage context. +- if (!context->IsOffTheRecord() && io_thread_valid) { ++ if (!context->GetPath().empty() && !context->IsOffTheRecord() && ++ io_thread_valid) { + file_task_runner = base::CreateTaskRunnerWithTraits( + {base::MayBlock(), base::TaskPriority::BEST_EFFORT, + base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}); diff --git content/browser/blob_storage/chrome_blob_storage_context.h content/browser/blob_storage/chrome_blob_storage_context.h index 26cf1ebfdffc..f6de541d25d1 100644 --- content/browser/blob_storage/chrome_blob_storage_context.h @@ -83,10 +93,18 @@ index 4728c4f008b5..07dc19b2240a 100644 partition->GetBluetoothAllowedDevicesMap(); return allowed_devices_map->GetOrCreateAllowedDevices(GetOrigin()); diff --git content/browser/browser_context.cc content/browser/browser_context.cc -index 0c58a53ac435..aa462081c726 100644 +index 0c58a53ac435..4d86680e1be9 100644 --- content/browser/browser_context.cc +++ content/browser/browser_context.cc -@@ -209,11 +209,18 @@ StoragePartition* GetStoragePartitionFromConfig( +@@ -54,6 +54,7 @@ + #include "content/public/common/content_switches.h" + #include "content/public/common/service_manager_connection.h" + #include "content/public/common/service_names.mojom.h" ++#include "media/capabilities/in_memory_video_decode_stats_db_impl.h" + #include "media/capabilities/video_decode_stats_db_impl.h" + #include "media/mojo/services/video_decode_perf_history.h" + #include "net/cookies/cookie_store.h" +@@ -209,11 +210,18 @@ StoragePartition* GetStoragePartitionFromConfig( StoragePartitionImplMap* partition_map = GetStoragePartitionMap(browser_context); @@ -108,7 +126,7 @@ index 0c58a53ac435..aa462081c726 100644 } void SaveSessionStateOnIOThread( -@@ -731,6 +738,11 @@ ServiceManagerConnection* BrowserContext::GetServiceManagerConnectionFor( +@@ -731,6 +739,11 @@ ServiceManagerConnection* BrowserContext::GetServiceManagerConnectionFor( BrowserContext::BrowserContext() : unique_id_(base::UnguessableToken::Create().ToString()) {} @@ -120,6 +138,24 @@ index 0c58a53ac435..aa462081c726 100644 BrowserContext::~BrowserContext() { CHECK(GetUserData(kServiceInstanceGroup)) << "Attempting to destroy a BrowserContext that never called " +@@ -780,9 +793,14 @@ media::VideoDecodePerfHistory* BrowserContext::GetVideoDecodePerfHistory() { + // occurs later upon first VideoDecodePerfHistory API request that requires DB + // access. DB operations will not block the UI thread. + if (!decode_history) { +- std::unique_ptr stats_db = +- media::VideoDecodeStatsDBImpl::Create( +- GetPath().Append(FILE_PATH_LITERAL("VideoDecodeStats"))); ++ std::unique_ptr stats_db; ++ if (GetPath().empty()) { ++ stats_db = ++ std::make_unique(nullptr); ++ } else { ++ stats_db = media::VideoDecodeStatsDBImpl::Create( ++ GetPath().Append(FILE_PATH_LITERAL("VideoDecodeStats"))); ++ } + auto new_decode_history = + std::make_unique(std::move(stats_db)); + decode_history = new_decode_history.get(); diff --git content/browser/devtools/protocol/network_handler.cc content/browser/devtools/protocol/network_handler.cc index 6ff1be0aed25..140a59ba3ac0 100644 --- content/browser/devtools/protocol/network_handler.cc