// muddles the experiment data, but as this was written to be considered for
// backport, having it behave differently than in stable would be a bigger
// problem. TODO: Does this work in later macOS releases?
-#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || \
- BUILDFLAG(IS_MAC)
+#if (BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || \
+ BUILDFLAG(IS_MAC)) && \
+ !BUILDFLAG(IS_TIZEN_TV)
return net::URLRequestContextBuilder::HttpCacheParams::DISK_SIMPLE;
#else
return net::URLRequestContextBuilder::HttpCacheParams::DISK_BLOCKFILE;
}
void StoragePartitionImpl::InitNetworkContext() {
+ LOG(INFO) << "is_in_memory is " << is_in_memory();
network::mojom::NetworkContextParamsPtr context_params =
network::mojom::NetworkContextParams::New();
+ if (base::FeatureList::IsEnabled(
+ network::features::kCompressionDictionaryTransportBackend) &&
+ GetContentClient()->browser()->AllowCompressionDictionaryTransport(
+ browser_context_)) {
+ context_params->shared_dictionary_enabled = true;
+ if (!is_in_memory()) {
+ // Some callers may already initialize NetworkContextFilePaths, and we
+ // don't want to overwrite them.
+ if (!context_params->file_paths) {
+ context_params->file_paths =
+ network::mojom::NetworkContextFilePaths::New();
+ }
+ context_params->file_paths->shared_dictionary_directory =
+ partition_path_.Append(FILE_PATH_LITERAL("Shared Dictionary"));
+ }
+ if (context_params->shared_dictionary_cache_max_size == 0u) {
+ CalculateAndSetSharedDictionaryCacheMaxSize(
+ GetWeakPtr(), is_in_memory() ? base::FilePath() : partition_path_);
+ }
+ }
cert_verifier::mojom::CertVerifierCreationParamsPtr
cert_verifier_creation_params =
cert_verifier::mojom::CertVerifierCreationParams::New();
cors_exempt_header_list_ = context_params->cors_exempt_header_list;
- if (base::FeatureList::IsEnabled(
- network::features::kCompressionDictionaryTransportBackend) &&
- GetContentClient()->browser()->AllowCompressionDictionaryTransport(
- browser_context_)) {
- context_params->shared_dictionary_enabled = true;
- if (!is_in_memory()) {
- // Some callers may already initialize NetworkContextFilePaths, and we
- // don't want to overwrite them.
- if (!context_params->file_paths) {
- context_params->file_paths =
- network::mojom::NetworkContextFilePaths::New();
- }
- context_params->file_paths->shared_dictionary_directory =
- partition_path_.Append(FILE_PATH_LITERAL("Shared Dictionary"));
- }
- if (context_params->shared_dictionary_cache_max_size == 0u) {
- CalculateAndSetSharedDictionaryCacheMaxSize(
- GetWeakPtr(), is_in_memory() ? base::FilePath() : partition_path_);
- }
- }
-
if (cookie_deprecation_label_manager_) {
context_params->cookie_deprecation_label =
cookie_deprecation_label_manager_->GetValue();
std::move(url_loader_factory_params));
}
+void NetworkContext::SetCacheMode(bool enable) {
+ net::HttpCache* cache =
+ url_request_context_->http_transaction_factory()->GetCache();
+ if (!cache) {
+ LOG(ERROR) << "Fail to set cache mode.";
+ return;
+ }
+ cache->set_mode(enable ? net::HttpCache::NORMAL : net::HttpCache::DISABLE);
+}
+
void NetworkContext::CreateCookieManager(
mojom::NetworkContextParamsPtr params) {
base::FilePath cookie_path;
// be removed when AFP block list logic is migrated to subresource filter.
bool AfpBlockListExperimentEnabled() const;
- void CreateCookieManager(mojom::NetworkContextParamsPtr params) override;
+ void CreateCookieManager(mojom::NetworkContextParamsPtr params) override;
+ void SetCacheMode(bool enable) override;
private:
class NetworkContextHttpAuthPreferences : public net::HttpAuthPreferences {
// Create a new cookie manager with new parameters.
CreateCookieManager(NetworkContextParams params);
+
+ // Disable/Enable diskcache
+ SetCacheMode(bool enable);
};
const char kCORSEnabledURLSchemes[] = "cors-enabled-url-schemes";
// JS plugin mime types
const char kJSPluginMimeTypes[] = "jsplugin-mime-types";
+// Forces the maximum disk space to be used by the disk cache, in bytes.
+const char kSizeOfDiskCache[] = "disk-cache-size";
// Time offset
const char kTimeOffset[] = "time-offset";
#endif
CONTENT_EXPORT extern const char kCORSEnabledURLSchemes[];
// JS plugin mime types
CONTENT_EXPORT extern const char kJSPluginMimeTypes[];
+CONTENT_EXPORT extern const char kSizeOfDiskCache[];
// Enables time offset
CONTENT_EXPORT extern const char kTimeOffset[];
#endif
#include "content_browser_client_efl.h"
#include "base/functional/callback.h"
+#include "base/path_service.h"
#include "base/strings/string_number_conversions.h"
#include "browser/navigation_throttle_efl.h"
#include "browser/network_service/browser_url_loader_throttle_efl.h"
}
}
+void ContentBrowserClientEfl::ConfigureNetworkContextParams(
+ BrowserContext* context,
+ bool in_memory,
+ const base::FilePath& relative_partition_path,
+ network::mojom::NetworkContextParams* network_context_params,
+ cert_verifier::mojom::CertVerifierCreationParams*
+ cert_verifier_creation_params) {
+ base::FilePath cache_base_path;
+
+ if (!base::PathService::Get(base::DIR_CACHE, &cache_base_path)) {
+ LOG(ERROR) << "Could not retrieve path to the cache directory";
+ return;
+ }
+#if BUILDFLAG(IS_TIZEN_TV)
+ int cache_max_size = 0;
+ if (!base::StringToInt(
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kSizeOfDiskCache),
+ &cache_max_size)) {
+ // Fallback when StringToInt failed as it could modify the output.
+ cache_max_size = 0;
+ }
+ network_context_params->http_cache_max_size = cache_max_size;
+ if (network_context_params->file_paths)
+ network_context_params->file_paths->http_cache_directory =
+ cache_base_path.Append("Cache");
+#else
+ if (network_context_params->file_paths)
+ network_context_params->file_paths->http_cache_directory = cache_base_path;
+#endif
+ network_context_params->user_agent = GetUserAgent();
+ network_context_params->accept_language = GetAcceptLangs(context);
+}
+
void AcceptLanguagesHelper::NotifyAcceptLangsChanged() {
std::vector<AcceptLangsChangedCallback> callbacks;
callbacks.swap(accept_langs_changed_callbacks_);
content::NavigationUIData* navigation_ui_data,
int frame_tree_node_id) override;
std::string GetAcceptLangs(BrowserContext* context) override;
+ void ConfigureNetworkContextParams(
+ BrowserContext* context,
+ bool in_memory,
+ const base::FilePath& relative_partition_path,
+ network::mojom::NetworkContextParams* network_context_params,
+ cert_verifier::mojom::CertVerifierCreationParams*
+ cert_verifier_creation_params) override;
void EnableAppControl(bool enabled) {
enabled_app_control = enabled;
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/password_manager/core/browser/password_form.h"
#include "components/password_manager/core/browser/password_store.h"
-#include "content/browser/inspector/devtools_util_manager.h"
#include "components/services/storage/public/cpp/buckets/bucket_locator.h"
+#include "content/browser/inspector/devtools_util_manager.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "net/proxy_resolution/proxy_config_service_fixed.h"
#include "net/proxy_resolution/proxy_resolution_service.h"
#include "net/url_request/url_request_context.h"
+#include "services/network/public/mojom/network_context.mojom.h"
#include "storage/browser/database/database_quota_client.h"
#include "storage/browser/file_system/file_system_quota_client.h"
#include "storage/browser/quota/quota_manager.h"
typedef void (*DynamicPreloading)(void);
#endif
+void SetNetworkCacheEnableOnIOThread(
+ bool enable,
+ content::StoragePartition* storage_partition) {
+ if (!storage_partition)
+ return;
+
+ auto network_context = storage_partition->GetNetworkContext();
+ if (!network_context)
+ return;
+
+ network_context->SetCacheMode(enable);
+}
/**
* @brief Helper class for obtaining WebStorage origins
*/
EWebContext::EWebContext(bool incognito, const std::string& injectedBundlePath)
: injected_bundle_path_(injectedBundlePath),
+ cache_enable_(false),
#if BUILDFLAG(IS_TIZEN)
injected_bundle_handle_(nullptr),
#endif
}
void EWebContext::SetNetworkCacheEnable(bool enable) { // LCOV_EXCL_LINE
-#if !defined(EWK_BRINGUP) // FIXME: m85 bringup
- net::URLRequestContextGetter* url_context =
- BrowserContext::GetDefaultStoragePartition(browser_context())
- ->GetURLRequestContext();
- if (!url_context)
+ if (enable == cache_enable_)
return;
- net::HttpTransactionFactory* transaction_factory =
- url_context->GetURLRequestContext()->http_transaction_factory();
- if (!transaction_factory)
- return;
-
- net::HttpCache* http_cache = transaction_factory->GetCache();
- if (!http_cache)
- return;
+ cache_enable_ = enable;
- if (enable)
- http_cache->set_mode(net::HttpCache::NORMAL);
- else
- http_cache->set_mode(net::HttpCache::DISABLE);
-#endif
+ content::GetIOThreadTaskRunner({})->PostTask(
+ FROM_HERE,
+ base::BindOnce(&SetNetworkCacheEnableOnIOThread, cache_enable_,
+ browser_context()->GetDefaultStoragePartition()));
} // LCOV_EXCL_LINE
-bool EWebContext::GetNetworkCacheEnable() const { // LCOV_EXCL_LINE
-#if defined(EWK_BRINGUP) // FIXME: m85 bringup
- return false; // LCOV_EXCL_LINE
-#else
- net::HttpCache* http_cache =
- BrowserContext::GetDefaultStoragePartition(browser_context())
- ->GetURLRequestContext()
- ->GetURLRequestContext()
- ->http_transaction_factory()
- ->GetCache();
- if (!http_cache)
- return false;
-
- return (http_cache->mode() != net::HttpCache::DISABLE);
-#endif
-}
/* LCOV_EXCL_START */
void EWebContext::SetCertificatePath(const std::string& certificate_path) {
browser_context_->SetCertificatePath(certificate_path);
void SetCacheModel(Ewk_Cache_Model);
Ewk_Cache_Model GetCacheModel() const;
void SetNetworkCacheEnable(bool enable);
- bool GetNetworkCacheEnable() const;
+ bool GetNetworkCacheEnable() const { return cache_enable_; }
void NotifyLowMemory();
std::string proxy_username_;
std::string proxy_password_;
std::string injected_bundle_path_;
+ bool cache_enable_;
#if BUILDFLAG(IS_TIZEN)
void* injected_bundle_handle_;