Skip to content

Commit e1338e0

Browse files
authored
Limit javascript code cache usage to 3MB. (#5605)
b/411414696
1 parent 0d5d5bc commit e1338e0

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cobalt/browser/cobalt_content_browser_client.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,16 @@ CobaltContentBrowserClient::CreateBrowserMainParts(
137137
return browser_main_parts;
138138
}
139139

140+
content::GeneratedCodeCacheSettings
141+
CobaltContentBrowserClient::GetGeneratedCodeCacheSettings(
142+
content::BrowserContext* context) {
143+
// Default compiled javascript quota in Cobalt 25.
144+
// https://github.com/youtube/cobalt/blob/3ccdb04a5e36c2597fe7066039037eabf4906ba5/cobalt/network/disk_cache/resource_type.cc#L72
145+
constexpr size_t size = 3 * 1024 * 1024;
146+
return content::GeneratedCodeCacheSettings(/*enabled=*/true, size,
147+
context->GetPath());
148+
}
149+
140150
std::string CobaltContentBrowserClient::GetApplicationLocale() {
141151
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
142152
return base::i18n::GetConfiguredLocale();

cobalt/browser/cobalt_content_browser_client.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "base/threading/thread_checker.h"
2020
#include "cobalt/browser/client_hint_headers/cobalt_trusted_url_loader_header_client.h"
2121
#include "cobalt/browser/cobalt_web_contents_delegate.h"
22+
#include "content/public/browser/generated_code_cache_settings.h"
2223
#include "content/shell/browser/shell_content_browser_client.h"
2324
#include "mojo/public/cpp/bindings/pending_receiver.h"
2425

@@ -67,6 +68,8 @@ class CobaltContentBrowserClient : public content::ShellContentBrowserClient {
6768
// ShellContentBrowserClient overrides.
6869
std::unique_ptr<content::BrowserMainParts> CreateBrowserMainParts(
6970
bool is_integration_test) override;
71+
content::GeneratedCodeCacheSettings GetGeneratedCodeCacheSettings(
72+
content::BrowserContext* context) override;
7073
std::string GetApplicationLocale() override;
7174
std::string GetUserAgent() override;
7275
std::string GetFullUserAgent() override;

0 commit comments

Comments
 (0)