Commit aafb822f authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

Reland "Remove unused members of ProfileIOData"

This is a reland of f37f7fde

crrev.com/c/1728889 no longer uses CreateURLLoaderThrottlesOnIO.

Original change's description:
> Remove unused members of ProfileIOData
>
> These are no longer used after http://crrev.com/c/1731919
>
> Bug: 824840
> Change-Id: I7163336861c227fb7fa7aab9fe297898d92067c7
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1731180
> Commit-Queue: Clark DuVall <cduvall@chromium.org>
> Reviewed-by: John Abd-El-Malek <jam@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#683474}

TBR=jam@chromium.org

Bug: 824840
Change-Id: I4d68b7d10ea49bfa220bfd16400f891a06c1fabb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1735058Reviewed-by: default avatarClark DuVall <cduvall@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#684025}
parent d45b6f39
......@@ -15,7 +15,6 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/stl_util.h"
#include "base/task/post_task.h"
#include "build/build_config.h"
#include "chrome/browser/profiles/profile_io_data.h"
#include "chrome/common/custom_handlers/protocol_handler.h"
......@@ -23,10 +22,7 @@
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "components/user_prefs/user_prefs.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/child_process_security_policy.h"
#include "net/base/network_delegate.h"
#include "net/url_request/url_request_redirect_job.h"
using content::BrowserThread;
using content::ChildProcessSecurityPolicy;
......@@ -75,64 +71,6 @@ GURL TranslateUrl(
} // namespace
// IOThreadDelegate ------------------------------------------------------------
ProtocolHandlerRegistry::IOThreadDelegate::IOThreadDelegate(bool)
: enabled_(true) {}
ProtocolHandlerRegistry::IOThreadDelegate::~IOThreadDelegate() {}
bool ProtocolHandlerRegistry::IOThreadDelegate::IsHandledProtocol(
const std::string& scheme) const {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
return enabled_ && !LookupHandler(default_handlers_, scheme).IsEmpty();
}
void ProtocolHandlerRegistry::IOThreadDelegate::ClearDefault(
const std::string& scheme) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
default_handlers_.erase(scheme);
}
void ProtocolHandlerRegistry::IOThreadDelegate::SetDefault(
const ProtocolHandler& handler) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
ClearDefault(handler.protocol());
default_handlers_.insert(std::make_pair(handler.protocol(), handler));
}
GURL ProtocolHandlerRegistry::IOThreadDelegate::Translate(
const GURL& url) const {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
return TranslateUrl(default_handlers_, url);
}
// Create a new job for the supplied |URLRequest| if a default handler
// is registered and the associated handler is able to interpret
// the url from |request|.
net::URLRequestJob* ProtocolHandlerRegistry::IOThreadDelegate::MaybeCreateJob(
net::URLRequest* request, net::NetworkDelegate* network_delegate) const {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
GURL translated_url(Translate(request->url()));
if (translated_url.is_empty())
return nullptr;
return new net::URLRequestRedirectJob(
request, network_delegate, translated_url,
net::URLRequestRedirectJob::REDIRECT_307_TEMPORARY_REDIRECT,
"Protocol Handler Registry");
}
void ProtocolHandlerRegistry::IOThreadDelegate::Enable() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
enabled_ = true;
}
void ProtocolHandlerRegistry::IOThreadDelegate::Disable() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
enabled_ = false;
}
// Delegate --------------------------------------------------------------------
ProtocolHandlerRegistry::Delegate::~Delegate() {}
......@@ -187,8 +125,7 @@ ProtocolHandlerRegistry::ProtocolHandlerRegistry(
delegate_(delegate),
enabled_(true),
is_loading_(false),
is_loaded_(false),
io_thread_delegate_(new IOThreadDelegate(enabled_)) {}
is_loaded_(false) {}
bool ProtocolHandlerRegistry::SilentlyHandleRegisterHandlerRequest(
const ProtocolHandler& handler) {
......@@ -267,9 +204,6 @@ void ProtocolHandlerRegistry::ClearDefault(const std::string& scheme) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
default_handlers_.erase(scheme);
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::IO},
base::BindOnce(&IOThreadDelegate::ClearDefault,
io_thread_delegate_, scheme));
Save();
NotifyChanged();
}
......@@ -529,11 +463,6 @@ void ProtocolHandlerRegistry::RemoveHandler(
// NOTE We pass a copy because SetDefault() modifies handlers.
SetDefault(ProtocolHandler(handlers[0]));
} else {
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&IOThreadDelegate::ClearDefault, io_thread_delegate_,
q->second.protocol()));
default_handlers_.erase(q);
}
}
......@@ -570,10 +499,6 @@ void ProtocolHandlerRegistry::Enable() {
return;
}
enabled_ = true;
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&IOThreadDelegate::Enable, io_thread_delegate_));
ProtocolHandlerMap::const_iterator p;
for (p = default_handlers_.begin(); p != default_handlers_.end(); ++p) {
delegate_->RegisterExternalHandler(p->first);
......@@ -588,9 +513,6 @@ void ProtocolHandlerRegistry::Disable() {
return;
}
enabled_ = false;
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&IOThreadDelegate::Disable, io_thread_delegate_));
ProtocolHandlerMap::const_iterator p;
for (p = default_handlers_.begin(); p != default_handlers_.end(); ++p) {
......@@ -678,9 +600,6 @@ void ProtocolHandlerRegistry::SetDefault(const ProtocolHandler& handler) {
default_handlers_.erase(handler.protocol());
default_handlers_.insert(std::make_pair(handler.protocol(), handler));
PromoteHandler(handler);
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::IO},
base::BindOnce(&IOThreadDelegate::SetDefault,
io_thread_delegate_, handler));
}
void ProtocolHandlerRegistry::InsertHandler(const ProtocolHandler& handler) {
......
......@@ -20,9 +20,6 @@
#include "chrome/common/custom_handlers/protocol_handler.h"
#include "components/keyed_service/core/keyed_service.h"
#include "content/public/browser/browser_thread.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_job.h"
#include "net/url_request/url_request_job_factory.h"
namespace user_prefs {
class PrefRegistrySyncable;
......@@ -65,59 +62,6 @@ class ProtocolHandlerRegistry : public KeyedService {
virtual void OnProtocolHandlerRegistryChanged() = 0;
};
// IOThreadDelegate is an IO thread specific object. Access to the class
// should all be done via the IO thread. The registry living on the UI thread
// makes a best effort to update the IO object after local updates are
// completed.
class IOThreadDelegate : public base::RefCountedThreadSafe<IOThreadDelegate> {
public:
// Creates a new instance. If |enabled| is true the registry is considered
// enabled on the IO thread.
explicit IOThreadDelegate(bool enabled);
// Returns true if the protocol has a default protocol handler.
// Should be called only from the IO thread.
bool IsHandledProtocol(const std::string& scheme) const;
// Clears the default for the provided protocol.
// Should be called only from the IO thread.
void ClearDefault(const std::string& scheme);
// Makes this ProtocolHandler the default handler for its protocol.
// Should be called only from the IO thread.
void SetDefault(const ProtocolHandler& handler);
// Returns a translated URL if |url| is handled by a protocol handler,
// otherwise it returns an empty URL.
GURL Translate(const GURL& url) const;
// Creates a URL request job for the given request if there is a matching
// protocol handler, returns NULL otherwise.
net::URLRequestJob* MaybeCreateJob(
net::URLRequest* request,
net::NetworkDelegate* network_delegate) const;
// Indicate that the registry has been enabled in the IO thread's
// copy of the data.
void Enable();
// Indicate that the registry has been disabled in the IO thread's copy of
// the data.
void Disable();
private:
friend class base::RefCountedThreadSafe<IOThreadDelegate>;
virtual ~IOThreadDelegate();
// Copy of protocol handlers use only on the IO thread.
ProtocolHandlerRegistry::ProtocolHandlerMap default_handlers_;
// Is the registry enabled on the IO thread.
bool enabled_;
DISALLOW_COPY_AND_ASSIGN(IOThreadDelegate);
};
// Creates a new instance. Assumes ownership of |delegate|.
ProtocolHandlerRegistry(content::BrowserContext* context, Delegate* delegate);
~ProtocolHandlerRegistry() override;
......@@ -245,10 +189,6 @@ class ProtocolHandlerRegistry : public KeyedService {
bool enabled() const { return enabled_; }
scoped_refptr<IOThreadDelegate> io_thread_delegate() {
return io_thread_delegate_;
}
// Add a predefined protocol handler. This has to be called before the first
// load command was issued, otherwise the command will be ignored.
void AddPredefinedHandler(const ProtocolHandler& handler);
......@@ -396,10 +336,6 @@ class ProtocolHandlerRegistry : public KeyedService {
// AddPredefinedHandler will be rejected.
bool is_loaded_;
// Copy of registry data for use on the IO thread. Changes to the registry
// are posted to the IO thread where updates are applied to this object.
scoped_refptr<IOThreadDelegate> io_thread_delegate_;
base::ObserverList<Observer> observers_;
// Makes it possible to invalidate the callback for the
......
......@@ -87,10 +87,6 @@ void OffTheRecordProfileIOData::Handle::LazyInitialize() const {
profile_->GetPrefs());
io_data_->safe_browsing_enabled()->MoveToSequence(
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}));
io_data_->safe_browsing_whitelist_domains()->Init(
prefs::kSafeBrowsingWhitelistDomains, profile_->GetPrefs());
io_data_->safe_browsing_whitelist_domains()->MoveToSequence(
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}));
#if BUILDFLAG(ENABLE_PLUGINS)
io_data_->always_open_pdf_externally()->Init(
prefs::kPluginsAlwaysOpenPdfExternally, profile_->GetPrefs());
......
......@@ -162,10 +162,6 @@ void ProfileImplIOData::Handle::LazyInitialize() const {
pref_service);
io_data_->safe_browsing_enabled()->MoveToSequence(
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}));
io_data_->safe_browsing_whitelist_domains()->Init(
prefs::kSafeBrowsingWhitelistDomains, pref_service);
io_data_->safe_browsing_whitelist_domains()->MoveToSequence(
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}));
#if BUILDFLAG(ENABLE_PLUGINS)
io_data_->always_open_pdf_externally()->Init(
prefs::kPluginsAlwaysOpenPdfExternally, pref_service);
......
......@@ -266,9 +266,6 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) {
ProtocolHandlerRegistryFactory::GetForBrowserContext(profile);
DCHECK(protocol_handler_registry);
protocol_handler_registry_io_thread_delegate_ =
protocol_handler_registry->io_thread_delegate();
#if defined(OS_CHROMEOS)
// Enable client certificates for the Chrome OS sign-in frame, if this feature
// is not disabled by a flag.
......@@ -319,15 +316,6 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) {
params->profile = profile;
profile_params_ = std::move(params);
force_google_safesearch_.Init(prefs::kForceGoogleSafeSearch, pref_service);
force_google_safesearch_.MoveToSequence(
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}));
force_youtube_restrict_.Init(prefs::kForceYouTubeRestrict, pref_service);
force_youtube_restrict_.MoveToSequence(
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}));
allowed_domains_for_apps_.Init(prefs::kAllowedDomainsForApps, pref_service);
allowed_domains_for_apps_.MoveToSequence(
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}));
signed_exchange_enabled_.Init(prefs::kSignedHTTPExchangeEnabled,
pref_service);
signed_exchange_enabled_.MoveToSequence(
......@@ -580,11 +568,7 @@ void ProfileIOData::ShutdownOnUIThread() {
#if !defined(OS_CHROMEOS)
signin_scoped_device_id_.Destroy();
#endif
force_google_safesearch_.Destroy();
force_youtube_restrict_.Destroy();
allowed_domains_for_apps_.Destroy();
safe_browsing_enabled_.Destroy();
safe_browsing_whitelist_domains_.Destroy();
network_prediction_options_.Destroy();
incognito_availibility_pref_.Destroy();
signed_exchange_enabled_.Destroy();
......
......@@ -96,10 +96,6 @@ class ProfileIOData {
return &safe_browsing_enabled_;
}
StringListPrefMember* safe_browsing_whitelist_domains() const {
return &safe_browsing_whitelist_domains_;
}
IntegerPrefMember* network_prediction_options() const {
return &network_prediction_options_;
}
......@@ -128,18 +124,6 @@ class ProfileIOData {
bool IsOffTheRecord() const;
BooleanPrefMember* force_google_safesearch() const {
return &force_google_safesearch_;
}
IntegerPrefMember* force_youtube_restrict() const {
return &force_youtube_restrict_;
}
StringPrefMember* allowed_domains_for_apps() const {
return &allowed_domains_for_apps_;
}
IntegerPrefMember* incognito_availibility() const {
return &incognito_availibility_pref_;
}
......@@ -166,11 +150,6 @@ class ProfileIOData {
return data_reduction_proxy_io_data_.get();
}
ProtocolHandlerRegistry::IOThreadDelegate*
protocol_handler_registry_io_thread_delegate() const {
return protocol_handler_registry_io_thread_delegate_.get();
}
// Get platform ClientCertStore. May return nullptr.
std::unique_ptr<net::ClientCertStore> CreateClientCertStore();
......@@ -288,11 +267,7 @@ class ProfileIOData {
#endif
// Member variables which are pointed to by the various context objects.
mutable BooleanPrefMember force_google_safesearch_;
mutable IntegerPrefMember force_youtube_restrict_;
mutable BooleanPrefMember safe_browsing_enabled_;
mutable StringListPrefMember safe_browsing_whitelist_domains_;
mutable StringPrefMember allowed_domains_for_apps_;
mutable IntegerPrefMember network_prediction_options_;
mutable IntegerPrefMember incognito_availibility_pref_;
mutable BooleanPrefMember signed_exchange_enabled_;
......@@ -311,9 +286,6 @@ class ProfileIOData {
mutable std::unique_ptr<data_reduction_proxy::DataReductionProxyIOData>
data_reduction_proxy_io_data_;
mutable scoped_refptr<ProtocolHandlerRegistry::IOThreadDelegate>
protocol_handler_registry_io_thread_delegate_;
#if defined(OS_CHROMEOS)
mutable std::string username_hash_;
mutable SystemKeySlotUseType system_key_slot_use_type_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment