fix: browser contexts live forever (#24964)
This commit is contained in:
parent
befbbc27d8
commit
bac2f46ba9
11 changed files with 68 additions and 73 deletions
|
@ -10,7 +10,6 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/memory/ref_counted_delete_on_sequence.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "chrome/browser/predictors/preconnect_manager.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
|
@ -50,8 +49,7 @@ class WebViewManager;
|
|||
class ProtocolRegistry;
|
||||
|
||||
class ElectronBrowserContext
|
||||
: public base::RefCountedDeleteOnSequence<ElectronBrowserContext>,
|
||||
public content::BrowserContext,
|
||||
: public content::BrowserContext,
|
||||
public network::mojom::TrustedURLLoaderAuthClient {
|
||||
public:
|
||||
// partition_id => browser_context
|
||||
|
@ -73,19 +71,17 @@ class ElectronBrowserContext
|
|||
}
|
||||
};
|
||||
using BrowserContextMap =
|
||||
std::map<PartitionKey, base::WeakPtr<ElectronBrowserContext>>;
|
||||
std::map<PartitionKey, std::unique_ptr<ElectronBrowserContext>>;
|
||||
|
||||
// Get or create the BrowserContext according to its |partition| and
|
||||
// |in_memory|. The |options| will be passed to constructor when there is no
|
||||
// existing BrowserContext.
|
||||
static scoped_refptr<ElectronBrowserContext> From(
|
||||
static ElectronBrowserContext* From(
|
||||
const std::string& partition,
|
||||
bool in_memory,
|
||||
base::DictionaryValue options = base::DictionaryValue());
|
||||
|
||||
static BrowserContextMap browser_context_map() {
|
||||
return browser_context_map_;
|
||||
}
|
||||
static BrowserContextMap& browser_context_map();
|
||||
|
||||
void SetUserAgent(const std::string& user_agent);
|
||||
std::string GetUserAgent() const;
|
||||
|
@ -151,15 +147,12 @@ class ElectronBrowserContext
|
|||
return protocol_registry_.get();
|
||||
}
|
||||
|
||||
protected:
|
||||
ElectronBrowserContext(const std::string& partition,
|
||||
bool in_memory,
|
||||
base::DictionaryValue options);
|
||||
~ElectronBrowserContext() override;
|
||||
|
||||
private:
|
||||
friend class base::RefCountedDeleteOnSequence<ElectronBrowserContext>;
|
||||
friend class base::DeleteHelper<ElectronBrowserContext>;
|
||||
ElectronBrowserContext(const std::string& partition,
|
||||
bool in_memory,
|
||||
base::DictionaryValue options);
|
||||
|
||||
void OnLoaderCreated(int32_t request_id,
|
||||
mojo::PendingReceiver<network::mojom::TrustedAuthClient>
|
||||
|
@ -168,8 +161,6 @@ class ElectronBrowserContext
|
|||
// Initialize pref registry.
|
||||
void InitPrefs();
|
||||
|
||||
static BrowserContextMap browser_context_map_;
|
||||
|
||||
ValueMapPrefStore* in_memory_pref_store_;
|
||||
|
||||
std::unique_ptr<content::ResourceContext> resource_context_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue