Commit 297746b9 authored by apavlov's avatar apavlov Committed by Commit bot

Revert of Content Shell: Introduce LayoutTestBrowserContext. (patchset #2...

Revert of Content Shell: Introduce LayoutTestBrowserContext. (patchset #2 id:20001 of https://codereview.chromium.org/637843003/)

Reason for revert:
Tentatively resulted in multiple layout test timeouts across the chromium.webkit waterfall.

Original issue's description:
> Content Shell: Introduce LayoutTestBrowserContext.
>
> This splits the DRT-specific parts of ShellBrowserContext out into a new
> class that we'll only instantiate when the flag is set.
>
> BUG=420994
>
> Committed: https://crrev.com/98ce5ad6bdd2cd058c21f19b997032f3b958cb73
> Cr-Commit-Position: refs/heads/master@{#299068}

TBR=jochen@chromium.org,mkwst@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=420994

Review URL: https://codereview.chromium.org/641203004

Cr-Commit-Position: refs/heads/master@{#299077}
parent 416b5284
......@@ -92,8 +92,6 @@
'shell/app/webkit_test_platform_support_win.cc',
'shell/browser/ipc_echo_message_filter.cc',
'shell/browser/ipc_echo_message_filter.h',
'shell/browser/layout_test/layout_test_browser_context.cc',
'shell/browser/layout_test/layout_test_browser_context.h',
'shell/browser/layout_test/layout_test_devtools_frontend.cc',
'shell/browser/layout_test/layout_test_devtools_frontend.h',
'shell/browser/layout_test/layout_test_javascript_dialog_manager.cc',
......
......@@ -41,8 +41,6 @@ static_library("content_shell_lib") {
"app/webkit_test_platform_support_win.cc",
"browser/ipc_echo_message_filter.cc",
"browser/ipc_echo_message_filter.h",
"browser/layout_test/layout_test_browser_context.cc",
"browser/layout_test/layout_test_browser_context.h",
"browser/layout_test/layout_test_devtools_frontend.cc",
"browser/layout_test/layout_test_devtools_frontend.h",
"browser/layout_test/layout_test_javascript_dialog_manager.cc",
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/shell/browser/layout_test/layout_test_browser_context.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "content/public/browser/resource_context.h"
#include "content/shell/browser/shell_download_manager_delegate.h"
#include "content/shell/browser/shell_url_request_context_getter.h"
#if defined(OS_WIN)
#include "base/base_paths_win.h"
#elif defined(OS_LINUX)
#include "base/nix/xdg_util.h"
#elif defined(OS_MACOSX)
#include "base/base_paths_mac.h"
#endif
namespace content {
LayoutTestBrowserContext::LayoutTestBrowserContext(bool off_the_record,
net::NetLog* net_log)
: ShellBrowserContext(off_the_record, net_log) {
}
LayoutTestBrowserContext::~LayoutTestBrowserContext() {
}
void LayoutTestBrowserContext::InitWhileIOAllowed() {
ignore_certificate_errors_ = true;
ShellBrowserContext::InitWhileIOAllowed();
}
DownloadManagerDelegate*
LayoutTestBrowserContext::GetDownloadManagerDelegate() {
if (!download_manager_delegate_.get()) {
download_manager_delegate_.reset(new ShellDownloadManagerDelegate());
download_manager_delegate_->SetDownloadManager(
BrowserContext::GetDownloadManager(this));
// TODO(mkwst): We can avoid this bit in the future by defining a
// LayoutTestDownloadManagerDelegate.
download_manager_delegate_->SetDownloadBehaviorForTesting(
GetPath().Append(FILE_PATH_LITERAL("downloads")));
}
return download_manager_delegate_.get();
}
} // namespace content
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_SHELL_BROWSER_LAYOUT_TEST_BROWSER_CONTEXT_H_
#define CONTENT_SHELL_BROWSER_LAYOUT_TEST_BROWSER_CONTEXT_H_
#include "base/compiler_specific.h"
#include "content/shell/browser/shell_browser_context.h"
namespace net {
class NetLog;
}
namespace content {
class DownloadManagerDelegate;
class LayoutTestBrowserContext : public ShellBrowserContext {
public:
LayoutTestBrowserContext(bool off_the_record, net::NetLog* net_log);
virtual ~LayoutTestBrowserContext();
// BrowserContext implementation.
virtual DownloadManagerDelegate* GetDownloadManagerDelegate() override;
protected:
// Performs initialization of the ShellBrowserContext while IO is still
// allowed on the current thread.
virtual void InitWhileIOAllowed() override;
DISALLOW_COPY_AND_ASSIGN(LayoutTestBrowserContext);
};
} // namespace content
#endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_BROWSER_CONTEXT_H_
......@@ -49,9 +49,9 @@ ShellBrowserContext::ShellResourceContext::GetRequestContext() {
ShellBrowserContext::ShellBrowserContext(bool off_the_record,
net::NetLog* net_log)
: resource_context_(new ShellResourceContext),
ignore_certificate_errors_(false),
off_the_record_(off_the_record),
net_log_(net_log),
ignore_certificate_errors_(false),
guest_manager_(NULL) {
InitWhileIOAllowed();
}
......@@ -65,8 +65,10 @@ ShellBrowserContext::~ShellBrowserContext() {
void ShellBrowserContext::InitWhileIOAllowed() {
CommandLine* cmd_line = CommandLine::ForCurrentProcess();
if (cmd_line->HasSwitch(switches::kIgnoreCertificateErrors))
if (cmd_line->HasSwitch(switches::kIgnoreCertificateErrors) ||
cmd_line->HasSwitch(switches::kDumpRenderTree)) {
ignore_certificate_errors_ = true;
}
if (cmd_line->HasSwitch(switches::kContentShellDataPath)) {
path_ = cmd_line->GetSwitchValuePath(switches::kContentShellDataPath);
return;
......@@ -104,10 +106,16 @@ bool ShellBrowserContext::IsOffTheRecord() const {
}
DownloadManagerDelegate* ShellBrowserContext::GetDownloadManagerDelegate() {
DownloadManager* manager = BrowserContext::GetDownloadManager(this);
if (!download_manager_delegate_.get()) {
download_manager_delegate_.reset(new ShellDownloadManagerDelegate());
download_manager_delegate_->SetDownloadManager(
BrowserContext::GetDownloadManager(this));
download_manager_delegate_->SetDownloadManager(manager);
CommandLine* cmd_line = CommandLine::ForCurrentProcess();
if (cmd_line->HasSwitch(switches::kDumpRenderTree)) {
download_manager_delegate_->SetDownloadBehaviorForTesting(
path_.Append(FILE_PATH_LITERAL("downloads")));
}
}
return download_manager_delegate_.get();
......@@ -129,8 +137,7 @@ net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext(
protocol_handlers,
request_interceptors.Pass(),
net_log_);
static_cast<ShellResourceContext*>(resource_context_.get())
->set_url_request_context_getter(url_request_getter_.get());
resource_context_->set_url_request_context_getter(url_request_getter_.get());
return url_request_getter_.get();
}
......
......@@ -94,19 +94,20 @@ class ShellBrowserContext : public BrowserContext {
url_request_getter_ = getter;
}
// Performs initialization of the ShellBrowserContext while IO is still
// allowed on the current thread.
virtual void InitWhileIOAllowed();
scoped_ptr<ShellResourceContext> resource_context_;
bool ignore_certificate_errors_;
scoped_ptr<ShellDownloadManagerDelegate> download_manager_delegate_;
private:
// Performs initialization of the ShellBrowserContext while IO is still
// allowed on the current thread.
void InitWhileIOAllowed();
bool off_the_record_;
net::NetLog* net_log_;
bool ignore_certificate_errors_;
base::FilePath path_;
BrowserPluginGuestManager* guest_manager_;
scoped_ptr<ShellDownloadManagerDelegate> download_manager_delegate_;
scoped_refptr<ShellURLRequestContextGetter> url_request_getter_;
DISALLOW_COPY_AND_ASSIGN(ShellBrowserContext);
......
......@@ -16,7 +16,6 @@
#include "content/public/common/content_switches.h"
#include "content/public/common/main_function_params.h"
#include "content/public/common/url_constants.h"
#include "content/shell/browser/layout_test/layout_test_browser_context.h"
#include "content/shell/browser/shell.h"
#include "content/shell/browser/shell_browser_context.h"
#include "content/shell/browser/shell_devtools_delegate.h"
......@@ -129,15 +128,9 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
}
#endif
net_log_.reset(new ShellNetLog("content_shell"));
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) {
browser_context_.reset(new LayoutTestBrowserContext(false, net_log_.get()));
off_the_record_browser_context_.reset(
new LayoutTestBrowserContext(true, net_log_.get()));
} else {
browser_context_.reset(new ShellBrowserContext(false, net_log_.get()));
off_the_record_browser_context_.reset(
new ShellBrowserContext(true, net_log_.get()));
}
browser_context_.reset(new ShellBrowserContext(false, net_log_.get()));
off_the_record_browser_context_.reset(
new ShellBrowserContext(true, net_log_.get()));
Shell::Initialize();
net::NetModule::SetResourceProvider(PlatformResourceProvider);
......
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