Commit e1b443ae authored by Wez's avatar Wez Committed by Commit Bot

Migrate ProtocolHandlerMap from linked_ptr<> to unique_ptr<>.

Also migrates //headless from its own unique_ptr<> based ProtocolHandler
map to use content::ProtocolHandlerMap.

Bug: 556939
Change-Id: I4ceea7f048542da1dd7a1f4a68d6ab91f75ff813
Reviewed-on: https://chromium-review.googlesource.com/989397
Commit-Queue: Wez <wez@chromium.org>
Reviewed-by: default avatarSami Kyöstilä <skyostil@chromium.org>
Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548102}
parent 2ae7c231
......@@ -8,6 +8,7 @@
#include <map>
#include <string>
#include "base/memory/linked_ptr.h"
#include "base/values.h"
#include "chrome/browser/chromeos/drive/drive_integration_service.h"
#include "chrome/browser/extensions/extension_apitest.h"
......
......@@ -5,6 +5,7 @@
#include "chrome/browser/ui/app_list/search/launcher_search/launcher_search_icon_image_loader.h"
#include "base/macros.h"
#include "base/memory/linked_ptr.h"
#include "chrome/browser/chromeos/launcher_search_provider/error_reporter.h"
#include "extensions/common/manifest_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
......
......@@ -10,6 +10,7 @@
#include "ash/app_list/model/search/search_result.h"
#include "base/macros.h"
#include "base/memory/linked_ptr.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/search/launcher_search/launcher_search_icon_image_loader.h"
#include "extensions/common/extension.h"
......
......@@ -9,7 +9,6 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/memory/linked_ptr.h"
#include "base/memory/ptr_util.h"
#include "base/single_thread_task_runner.h"
#include "base/task_scheduler/post_task.h"
......@@ -212,8 +211,7 @@ net::URLRequestContextGetter* URLRequestContextFactory::CreateMainGetter(
<< "Main URLRequestContextGetter already initialized";
#if BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS)
(*protocol_handlers)[extensions::kExtensionScheme] =
linked_ptr<net::URLRequestJobFactory::ProtocolHandler>(
new ExtensionRequestProtocolHandler(browser_context));
std::make_unique<ExtensionRequestProtocolHandler>(browser_context);
#endif
main_getter_ =
new MainURLRequestContextGetter(this, browser_context, protocol_handlers,
......
......@@ -403,19 +403,13 @@ StoragePartitionImpl* StoragePartitionImplMap::Get(
ChromeBlobStorageContext::GetFor(browser_context_);
StreamContext* stream_context = StreamContext::GetFor(browser_context_);
ProtocolHandlerMap protocol_handlers;
protocol_handlers[url::kBlobScheme] =
linked_ptr<net::URLRequestJobFactory::ProtocolHandler>(
new BlobProtocolHandler(blob_storage_context, stream_context));
protocol_handlers[url::kFileSystemScheme] =
linked_ptr<net::URLRequestJobFactory::ProtocolHandler>(
CreateFileSystemProtocolHandler(partition_domain,
partition->GetFileSystemContext()));
protocol_handlers[url::kBlobScheme] = std::make_unique<BlobProtocolHandler>(
blob_storage_context, stream_context);
protocol_handlers[url::kFileSystemScheme] = CreateFileSystemProtocolHandler(
partition_domain, partition->GetFileSystemContext());
for (const auto& scheme : URLDataManagerBackend::GetWebUISchemes()) {
protocol_handlers[scheme] =
linked_ptr<net::URLRequestJobFactory::ProtocolHandler>(
URLDataManagerBackend::CreateProtocolHandler(
browser_context_->GetResourceContext(), blob_storage_context)
.release());
protocol_handlers[scheme] = URLDataManagerBackend::CreateProtocolHandler(
browser_context_->GetResourceContext(), blob_storage_context);
}
URLRequestInterceptorScopedVector request_interceptors;
......
......@@ -15,7 +15,6 @@
#include "base/callback_forward.h"
#include "base/containers/hash_tables.h"
#include "base/memory/linked_ptr.h"
#include "base/supports_user_data.h"
#include "content/common/content_export.h"
#include "net/url_request/url_request_interceptor.h"
......@@ -81,7 +80,7 @@ class SSLHostStateDelegate;
// content.
using ProtocolHandlerMap =
std::map<std::string,
linked_ptr<net::URLRequestJobFactory::ProtocolHandler>>;
std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>>;
// A owning vector of protocol interceptors.
using URLRequestInterceptorScopedVector =
......
......@@ -59,11 +59,8 @@ net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext(
// Handle only chrome-extension:// requests.
InfoMap* extension_info_map =
browser_main_parts_->extension_system()->info_map();
(*protocol_handlers)[kExtensionScheme] =
linked_ptr<net::URLRequestJobFactory::ProtocolHandler>(
CreateExtensionProtocolHandler(false /* is_incognito */,
extension_info_map)
.release());
(*protocol_handlers)[kExtensionScheme] = CreateExtensionProtocolHandler(
false /* is_incognito */, extension_info_map);
set_url_request_context_getter(new ShellURLRequestContextGetter(
this, IgnoreCertificateErrors(), GetPath(),
......
......@@ -44,7 +44,7 @@ namespace headless {
HeadlessURLRequestContextGetter::HeadlessURLRequestContextGetter(
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
content::ProtocolHandlerMap* protocol_handlers,
ProtocolHandlerMap context_protocol_handlers,
content::ProtocolHandlerMap context_protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors,
HeadlessBrowserContextOptions* options,
net::NetLog* net_log,
......@@ -62,13 +62,9 @@ HeadlessURLRequestContextGetter::HeadlessURLRequestContextGetter(
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
std::swap(protocol_handlers_, *protocol_handlers);
for (auto& pair : context_protocol_handlers) {
protocol_handlers_[pair.first] =
linked_ptr<net::URLRequestJobFactory::ProtocolHandler>(
pair.second.release());
protocol_handlers_[pair.first] = std::move(pair.second);
}
context_protocol_handlers.clear();
// We must create the proxy config service on the UI loop on Linux because it
// must synchronously run on the glib message loop. This will be passed to
......
......@@ -13,6 +13,7 @@
#include "base/callback.h"
#include "base/optional.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/resource_request_info.h"
#include "content/public/common/web_preferences.h"
#include "headless/lib/browser/headless_network_conditions.h"
......@@ -38,10 +39,7 @@ class HeadlessBrowserContextOptions;
using content::WebPreferences;
using DevToolsStatus = content::ResourceRequestInfo::DevToolsStatus;
using ProtocolHandlerMap = std::unordered_map<
std::string,
std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>>;
using content::ProtocolHandlerMap;
// Represents an isolated session with a unique cache, cookies, and other
// profile/session related data.
......
......@@ -62,10 +62,11 @@ net::URLRequestJob* FileSystemProtocolHandler::MaybeCreateJob(
} // anonymous namespace
net::URLRequestJobFactory::ProtocolHandler* CreateFileSystemProtocolHandler(
const std::string& storage_domain, FileSystemContext* context) {
std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>
CreateFileSystemProtocolHandler(const std::string& storage_domain,
FileSystemContext* context) {
DCHECK(context);
return new FileSystemProtocolHandler(storage_domain, context);
return std::make_unique<FileSystemProtocolHandler>(storage_domain, context);
}
} // namespace storage
......@@ -5,6 +5,7 @@
#ifndef STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_URL_REQUEST_JOB_FACTORY_H_
#define STORAGE_BROWSER_FILEAPI_FILE_SYSTEM_URL_REQUEST_JOB_FACTORY_H_
#include <memory>
#include <string>
#include "net/url_request/url_request_job_factory.h"
......@@ -18,8 +19,8 @@ class FileSystemContext;
// |context|'s lifetime should exceed the lifetime of the ProtocolHandler.
// Currently, this is only used by ProfileIOData which owns |context| and the
// ProtocolHandler.
STORAGE_EXPORT net::URLRequestJobFactory::ProtocolHandler*
CreateFileSystemProtocolHandler(const std::string& storage_domain,
STORAGE_EXPORT std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>
CreateFileSystemProtocolHandler(const std::string& storage_domain,
FileSystemContext* context);
} // namespace storage
......
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