Commit eaae5d98 authored by tommycli's avatar tommycli Committed by Commit bot

Componentize component_updater: Move URLRequestPrepackagedInterceptor from content/ to net/.

This patch breaks the URLRequestPrepackagedInterceptor dependencies on content/.

We want to use URLRequestPrepackagedInterceptor in unit tests that will be in components/. These tests cannot depend on content/.

BUG=371463
TBR=wtc@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#293861}
parent c13b6049
...@@ -66,7 +66,10 @@ ComponentUpdaterTest::~ComponentUpdaterTest() { ...@@ -66,7 +66,10 @@ ComponentUpdaterTest::~ComponentUpdaterTest() {
} }
void ComponentUpdaterTest::SetUp() { void ComponentUpdaterTest::SetUp() {
get_interceptor_.reset(new GetInterceptor); get_interceptor_.reset(new GetInterceptor(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
interceptor_factory_.reset(new InterceptorFactory( interceptor_factory_.reset(new InterceptorFactory(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
post_interceptor_ = interceptor_factory_->CreateInterceptor(); post_interceptor_ = interceptor_factory_->CreateInterceptor();
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "components/component_updater/test/test_configurator.h" #include "components/component_updater/test/test_configurator.h"
#include "components/component_updater/test/url_request_post_interceptor.h" #include "components/component_updater/test/url_request_post_interceptor.h"
#include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_browser_thread_bundle.h"
#include "content/test/net/url_request_prepackaged_interceptor.h" #include "net/url_request/test_url_request_interceptor.h"
#include "net/url_request/url_request_test_util.h" #include "net/url_request/url_request_test_util.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -25,7 +25,7 @@ namespace component_updater { ...@@ -25,7 +25,7 @@ namespace component_updater {
class TestInstaller; class TestInstaller;
// Intercepts HTTP GET requests sent to "localhost". // Intercepts HTTP GET requests sent to "localhost".
typedef content::URLLocalHostRequestPrepackagedInterceptor GetInterceptor; typedef net::LocalHostTestURLRequestInterceptor GetInterceptor;
class ComponentUpdaterTest : public testing::Test { class ComponentUpdaterTest : public testing::Test {
public: public:
......
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
#include "chrome/browser/extensions/api/image_writer_private/test_utils.h" #include "chrome/browser/extensions/api/image_writer_private/test_utils.h"
#include "chrome/browser/extensions/api/image_writer_private/write_from_url_operation.h" #include "chrome/browser/extensions/api/image_writer_private/write_from_url_operation.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "content/test/net/url_request_prepackaged_interceptor.h" #include "content/public/browser/browser_thread.h"
#include "net/url_request/test_url_request_interceptor.h"
#include "net/url_request/url_fetcher.h" #include "net/url_request/url_fetcher.h"
namespace extensions { namespace extensions {
...@@ -14,6 +15,7 @@ namespace image_writer { ...@@ -14,6 +15,7 @@ namespace image_writer {
namespace { namespace {
using content::BrowserThread;
using testing::_; using testing::_;
using testing::AnyNumber; using testing::AnyNumber;
using testing::AtLeast; using testing::AtLeast;
...@@ -22,7 +24,7 @@ using testing::Lt; ...@@ -22,7 +24,7 @@ using testing::Lt;
const char kTestImageUrl[] = "http://localhost/test/image.zip"; const char kTestImageUrl[] = "http://localhost/test/image.zip";
typedef content::URLLocalHostRequestPrepackagedInterceptor GetInterceptor; typedef net::LocalHostTestURLRequestInterceptor GetInterceptor;
// This class gives us a generic Operation with the ability to set or inspect // This class gives us a generic Operation with the ability to set or inspect
// the current path to the image file. // the current path to the image file.
...@@ -76,7 +78,10 @@ class ImageWriterWriteFromUrlOperationTest : public ImageWriterUnitTestBase { ...@@ -76,7 +78,10 @@ class ImageWriterWriteFromUrlOperationTest : public ImageWriterUnitTestBase {
// Turn on interception and set up our dummy file. // Turn on interception and set up our dummy file.
net::URLFetcher::SetEnableInterceptionForTests(true); net::URLFetcher::SetEnableInterceptionForTests(true);
get_interceptor_.reset(new GetInterceptor()); get_interceptor_.reset(new GetInterceptor(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
get_interceptor_->SetResponse(GURL(kTestImageUrl), get_interceptor_->SetResponse(GURL(kTestImageUrl),
test_utils_.GetImagePath()); test_utils_.GetImagePath());
} }
......
...@@ -23,19 +23,21 @@ ...@@ -23,19 +23,21 @@
#include "components/policy/core/browser/browser_policy_connector.h" #include "components/policy/core/browser/browser_policy_connector.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h" #include "components/policy/core/common/mock_configuration_policy_provider.h"
#include "components/policy/core/common/policy_map.h" #include "components/policy/core/common/policy_map.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/test/browser_test_utils.h" #include "content/public/test/browser_test_utils.h"
#include "content/test/net/url_request_prepackaged_interceptor.h"
#include "extensions/browser/extension_host.h" #include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_prefs.h" #include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h" #include "extensions/browser/extension_system.h"
#include "extensions/browser/notification_types.h" #include "extensions/browser/notification_types.h"
#include "net/url_request/test_url_request_interceptor.h"
#include "net/url_request/url_fetcher.h" #include "net/url_request/url_fetcher.h"
#include "policy/policy_constants.h" #include "policy/policy_constants.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
using content::BrowserThread;
using extensions::Extension; using extensions::Extension;
using extensions::ExtensionRegistry; using extensions::ExtensionRegistry;
using extensions::Manifest; using extensions::Manifest;
...@@ -283,8 +285,12 @@ class NotificationListener : public content::NotificationObserver { ...@@ -283,8 +285,12 @@ class NotificationListener : public content::NotificationObserver {
IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, MAYBE_AutoUpdate) { IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, MAYBE_AutoUpdate) {
NotificationListener notification_listener; NotificationListener notification_listener;
base::FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); base::FilePath basedir = test_data_dir_.AppendASCII("autoupdate");
// Note: This interceptor gets requests on the IO thread. // Note: This interceptor gets requests on the IO thread.
content::URLLocalHostRequestPrepackagedInterceptor interceptor; net::LocalHostTestURLRequestInterceptor interceptor(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
net::URLFetcher::SetEnableInterceptionForTests(true); net::URLFetcher::SetEnableInterceptionForTests(true);
interceptor.SetResponseIgnoreQuery( interceptor.SetResponseIgnoreQuery(
...@@ -368,8 +374,12 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ...@@ -368,8 +374,12 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest,
MAYBE_AutoUpdateDisabledExtensions) { MAYBE_AutoUpdateDisabledExtensions) {
NotificationListener notification_listener; NotificationListener notification_listener;
base::FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); base::FilePath basedir = test_data_dir_.AppendASCII("autoupdate");
// Note: This interceptor gets requests on the IO thread. // Note: This interceptor gets requests on the IO thread.
content::URLLocalHostRequestPrepackagedInterceptor interceptor; net::LocalHostTestURLRequestInterceptor interceptor(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
net::URLFetcher::SetEnableInterceptionForTests(true); net::URLFetcher::SetEnableInterceptionForTests(true);
interceptor.SetResponseIgnoreQuery( interceptor.SetResponseIgnoreQuery(
...@@ -435,7 +445,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalUrlUpdate) { ...@@ -435,7 +445,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalUrlUpdate) {
base::FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); base::FilePath basedir = test_data_dir_.AppendASCII("autoupdate");
// Note: This interceptor gets requests on the IO thread. // Note: This interceptor gets requests on the IO thread.
content::URLLocalHostRequestPrepackagedInterceptor interceptor; net::LocalHostTestURLRequestInterceptor interceptor(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
net::URLFetcher::SetEnableInterceptionForTests(true); net::URLFetcher::SetEnableInterceptionForTests(true);
interceptor.SetResponseIgnoreQuery( interceptor.SetResponseIgnoreQuery(
...@@ -528,7 +541,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalPolicyRefresh) { ...@@ -528,7 +541,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ExternalPolicyRefresh) {
base::FilePath basedir = test_data_dir_.AppendASCII("autoupdate"); base::FilePath basedir = test_data_dir_.AppendASCII("autoupdate");
// Note: This interceptor gets requests on the IO thread. // Note: This interceptor gets requests on the IO thread.
content::URLLocalHostRequestPrepackagedInterceptor interceptor; net::LocalHostTestURLRequestInterceptor interceptor(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
net::URLFetcher::SetEnableInterceptionForTests(true); net::URLFetcher::SetEnableInterceptionForTests(true);
interceptor.SetResponseIgnoreQuery( interceptor.SetResponseIgnoreQuery(
...@@ -609,7 +625,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, ...@@ -609,7 +625,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest,
ASSERT_TRUE(registry->disabled_extensions().is_empty()); ASSERT_TRUE(registry->disabled_extensions().is_empty());
// Note: This interceptor gets requests on the IO thread. // Note: This interceptor gets requests on the IO thread.
content::URLLocalHostRequestPrepackagedInterceptor interceptor; net::LocalHostTestURLRequestInterceptor interceptor(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
net::URLFetcher::SetEnableInterceptionForTests(true); net::URLFetcher::SetEnableInterceptionForTests(true);
interceptor.SetResponseIgnoreQuery( interceptor.SetResponseIgnoreQuery(
......
...@@ -19,15 +19,16 @@ ...@@ -19,15 +19,16 @@
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
#include "content/test/net/url_request_prepackaged_interceptor.h"
#include "extensions/browser/extension_prefs.h" #include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h" #include "extensions/browser/extension_system.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
#include "net/url_request/test_url_request_interceptor.h"
#include "net/url_request/url_fetcher.h" #include "net/url_request/url_fetcher.h"
#include "sync/protocol/extension_specifics.pb.h" #include "sync/protocol/extension_specifics.pb.h"
#include "sync/protocol/sync.pb.h" #include "sync/protocol/sync.pb.h"
using content::BrowserThread;
using extensions::Extension; using extensions::Extension;
using extensions::ExtensionRegistry; using extensions::ExtensionRegistry;
using extensions::ExtensionPrefs; using extensions::ExtensionPrefs;
...@@ -210,7 +211,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, ...@@ -210,7 +211,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest,
InstallIncreasingPermissionExtensionV1(); InstallIncreasingPermissionExtensionV1();
// Note: This interceptor gets requests on the IO thread. // Note: This interceptor gets requests on the IO thread.
content::URLLocalHostRequestPrepackagedInterceptor interceptor; net::LocalHostTestURLRequestInterceptor interceptor(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
net::URLFetcher::SetEnableInterceptionForTests(true); net::URLFetcher::SetEnableInterceptionForTests(true);
interceptor.SetResponseIgnoreQuery( interceptor.SetResponseIgnoreQuery(
GURL("http://localhost/autoupdate/updates.xml"), GURL("http://localhost/autoupdate/updates.xml"),
...@@ -247,7 +251,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, RemoteInstall) { ...@@ -247,7 +251,10 @@ IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, RemoteInstall) {
ExtensionSyncService::Get(browser()->profile()); ExtensionSyncService::Get(browser()->profile());
// Note: This interceptor gets requests on the IO thread. // Note: This interceptor gets requests on the IO thread.
content::URLLocalHostRequestPrepackagedInterceptor interceptor; net::LocalHostTestURLRequestInterceptor interceptor(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
net::URLFetcher::SetEnableInterceptionForTests(true); net::URLFetcher::SetEnableInterceptionForTests(true);
interceptor.SetResponseIgnoreQuery( interceptor.SetResponseIgnoreQuery(
GURL("http://localhost/autoupdate/updates.xml"), GURL("http://localhost/autoupdate/updates.xml"),
......
...@@ -7,18 +7,15 @@ ...@@ -7,18 +7,15 @@
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/threading/sequenced_worker_pool.h"
#include "components/component_updater/crx_downloader.h" #include "components/component_updater/crx_downloader.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "content/test/net/url_request_prepackaged_interceptor.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/url_request/test_url_request_interceptor.h"
#include "net/url_request/url_request_test_util.h" #include "net/url_request/url_request_test_util.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
using content::BrowserThread;
using base::ContentsEqual; using base::ContentsEqual;
namespace component_updater { namespace component_updater {
...@@ -26,7 +23,7 @@ namespace component_updater { ...@@ -26,7 +23,7 @@ namespace component_updater {
namespace { namespace {
// Intercepts HTTP GET requests sent to "localhost". // Intercepts HTTP GET requests sent to "localhost".
typedef content::URLLocalHostRequestPrepackagedInterceptor GetInterceptor; typedef net::LocalHostTestURLRequestInterceptor GetInterceptor;
const char kTestFileName[] = "jebgalgnebhfojomionfpkfelancnnkf.crx"; const char kTestFileName[] = "jebgalgnebhfojomionfpkfelancnnkf.crx";
...@@ -59,6 +56,8 @@ class CrxDownloaderTest : public testing::Test { ...@@ -59,6 +56,8 @@ class CrxDownloaderTest : public testing::Test {
protected: protected:
scoped_ptr<CrxDownloader> crx_downloader_; scoped_ptr<CrxDownloader> crx_downloader_;
scoped_ptr<GetInterceptor> get_interceptor_;
CrxDownloader::DownloadCallback callback_; CrxDownloader::DownloadCallback callback_;
CrxDownloader::ProgressCallback progress_callback_; CrxDownloader::ProgressCallback progress_callback_;
...@@ -75,9 +74,8 @@ class CrxDownloaderTest : public testing::Test { ...@@ -75,9 +74,8 @@ class CrxDownloaderTest : public testing::Test {
static const int kExpectedContext = 0xaabb; static const int kExpectedContext = 0xaabb;
private: private:
scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; base::MessageLoopForIO loop_;
scoped_refptr<net::TestURLRequestContextGetter> context_; scoped_refptr<net::TestURLRequestContextGetter> context_;
content::TestBrowserThreadBundle thread_bundle_;
base::Closure quit_closure_; base::Closure quit_closure_;
}; };
...@@ -93,17 +91,16 @@ CrxDownloaderTest::CrxDownloaderTest() ...@@ -93,17 +91,16 @@ CrxDownloaderTest::CrxDownloaderTest()
crx_context_(0), crx_context_(0),
num_download_complete_calls_(0), num_download_complete_calls_(0),
num_progress_calls_(0), num_progress_calls_(0),
blocking_task_runner_(BrowserThread::GetBlockingPool()->
GetSequencedTaskRunnerWithShutdownBehavior(
BrowserThread::GetBlockingPool()->GetSequenceToken(),
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)),
context_(new net::TestURLRequestContextGetter( context_(new net::TestURLRequestContextGetter(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))), base::MessageLoopProxy::current())) {
thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {
} }
CrxDownloaderTest::~CrxDownloaderTest() { CrxDownloaderTest::~CrxDownloaderTest() {
context_ = NULL; context_ = NULL;
// The GetInterceptor requires the message loop to run to destruct correctly.
get_interceptor_.reset();
RunThreadsUntilIdle();
} }
void CrxDownloaderTest::SetUp() { void CrxDownloaderTest::SetUp() {
...@@ -111,12 +108,16 @@ void CrxDownloaderTest::SetUp() { ...@@ -111,12 +108,16 @@ void CrxDownloaderTest::SetUp() {
download_complete_result_ = CrxDownloader::Result(); download_complete_result_ = CrxDownloader::Result();
num_progress_calls_ = 0; num_progress_calls_ = 0;
download_progress_result_ = CrxDownloader::Result(); download_progress_result_ = CrxDownloader::Result();
crx_downloader_.reset(CrxDownloader::Create( crx_downloader_.reset(CrxDownloader::Create(
false, // Do not use the background downloader in these tests. false, // Do not use the background downloader in these tests.
context_.get(), context_.get(),
blocking_task_runner_, base::MessageLoopProxy::current(),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE))); NULL)); // No |background_task_runner| because no background downloader.
crx_downloader_->set_progress_callback(progress_callback_); crx_downloader_->set_progress_callback(progress_callback_);
get_interceptor_.reset(new GetInterceptor(base::MessageLoopProxy::current(),
base::MessageLoopProxy::current()));
} }
void CrxDownloaderTest::TearDown() { void CrxDownloaderTest::TearDown() {
...@@ -179,13 +180,12 @@ TEST_F(CrxDownloaderTest, OneUrl) { ...@@ -179,13 +180,12 @@ TEST_F(CrxDownloaderTest, OneUrl) {
GURL("http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx"); GURL("http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx");
const base::FilePath test_file(MakeTestFilePath(kTestFileName)); const base::FilePath test_file(MakeTestFilePath(kTestFileName));
GetInterceptor interceptor; get_interceptor_->SetResponse(expected_crx_url, test_file);
interceptor.SetResponse(expected_crx_url, test_file);
crx_downloader_->StartDownloadFromUrl(expected_crx_url, callback_); crx_downloader_->StartDownloadFromUrl(expected_crx_url, callback_);
RunThreads(); RunThreads();
EXPECT_EQ(1, interceptor.GetHitCount()); EXPECT_EQ(1, get_interceptor_->GetHitCount());
EXPECT_EQ(1, num_download_complete_calls_); EXPECT_EQ(1, num_download_complete_calls_);
EXPECT_EQ(kExpectedContext, crx_context_); EXPECT_EQ(kExpectedContext, crx_context_);
...@@ -214,8 +214,7 @@ TEST_F(CrxDownloaderTest, MAYBE_TwoUrls) { ...@@ -214,8 +214,7 @@ TEST_F(CrxDownloaderTest, MAYBE_TwoUrls) {
GURL("http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx"); GURL("http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx");
const base::FilePath test_file(MakeTestFilePath(kTestFileName)); const base::FilePath test_file(MakeTestFilePath(kTestFileName));
GetInterceptor interceptor; get_interceptor_->SetResponse(expected_crx_url, test_file);
interceptor.SetResponse(expected_crx_url, test_file);
std::vector<GURL> urls; std::vector<GURL> urls;
urls.push_back(expected_crx_url); urls.push_back(expected_crx_url);
...@@ -224,7 +223,7 @@ TEST_F(CrxDownloaderTest, MAYBE_TwoUrls) { ...@@ -224,7 +223,7 @@ TEST_F(CrxDownloaderTest, MAYBE_TwoUrls) {
crx_downloader_->StartDownload(urls, callback_); crx_downloader_->StartDownload(urls, callback_);
RunThreads(); RunThreads();
EXPECT_EQ(1, interceptor.GetHitCount()); EXPECT_EQ(1, get_interceptor_->GetHitCount());
EXPECT_EQ(1, num_download_complete_calls_); EXPECT_EQ(1, num_download_complete_calls_);
EXPECT_EQ(kExpectedContext, crx_context_); EXPECT_EQ(kExpectedContext, crx_context_);
...@@ -246,8 +245,7 @@ TEST_F(CrxDownloaderTest, OneUrl_InvalidHost) { ...@@ -246,8 +245,7 @@ TEST_F(CrxDownloaderTest, OneUrl_InvalidHost) {
GURL("http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx"); GURL("http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx");
const base::FilePath test_file(MakeTestFilePath(kTestFileName)); const base::FilePath test_file(MakeTestFilePath(kTestFileName));
GetInterceptor interceptor; get_interceptor_->SetResponse(expected_crx_url, test_file);
interceptor.SetResponse(expected_crx_url, test_file);
crx_downloader_->StartDownloadFromUrl( crx_downloader_->StartDownloadFromUrl(
GURL("http://no.such.host" GURL("http://no.such.host"
...@@ -255,7 +253,7 @@ TEST_F(CrxDownloaderTest, OneUrl_InvalidHost) { ...@@ -255,7 +253,7 @@ TEST_F(CrxDownloaderTest, OneUrl_InvalidHost) {
callback_); callback_);
RunThreads(); RunThreads();
EXPECT_EQ(0, interceptor.GetHitCount()); EXPECT_EQ(0, get_interceptor_->GetHitCount());
EXPECT_EQ(1, num_download_complete_calls_); EXPECT_EQ(1, num_download_complete_calls_);
EXPECT_EQ(kExpectedContext, crx_context_); EXPECT_EQ(kExpectedContext, crx_context_);
...@@ -269,14 +267,13 @@ TEST_F(CrxDownloaderTest, OneUrl_InvalidPath) { ...@@ -269,14 +267,13 @@ TEST_F(CrxDownloaderTest, OneUrl_InvalidPath) {
GURL("http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx"); GURL("http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx");
const base::FilePath test_file(MakeTestFilePath(kTestFileName)); const base::FilePath test_file(MakeTestFilePath(kTestFileName));
GetInterceptor interceptor; get_interceptor_->SetResponse(expected_crx_url, test_file);
interceptor.SetResponse(expected_crx_url, test_file);
crx_downloader_->StartDownloadFromUrl(GURL("http://localhost/no/such/file"), crx_downloader_->StartDownloadFromUrl(GURL("http://localhost/no/such/file"),
callback_); callback_);
RunThreads(); RunThreads();
EXPECT_EQ(0, interceptor.GetHitCount()); EXPECT_EQ(0, get_interceptor_->GetHitCount());
EXPECT_EQ(1, num_download_complete_calls_); EXPECT_EQ(1, num_download_complete_calls_);
EXPECT_EQ(kExpectedContext, crx_context_); EXPECT_EQ(kExpectedContext, crx_context_);
...@@ -296,8 +293,7 @@ TEST_F(CrxDownloaderTest, MAYBE_TwoUrls_FirstInvalid) { ...@@ -296,8 +293,7 @@ TEST_F(CrxDownloaderTest, MAYBE_TwoUrls_FirstInvalid) {
GURL("http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx"); GURL("http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx");
const base::FilePath test_file(MakeTestFilePath(kTestFileName)); const base::FilePath test_file(MakeTestFilePath(kTestFileName));
GetInterceptor interceptor; get_interceptor_->SetResponse(expected_crx_url, test_file);
interceptor.SetResponse(expected_crx_url, test_file);
std::vector<GURL> urls; std::vector<GURL> urls;
urls.push_back(GURL("http://localhost/no/such/file")); urls.push_back(GURL("http://localhost/no/such/file"));
...@@ -306,7 +302,7 @@ TEST_F(CrxDownloaderTest, MAYBE_TwoUrls_FirstInvalid) { ...@@ -306,7 +302,7 @@ TEST_F(CrxDownloaderTest, MAYBE_TwoUrls_FirstInvalid) {
crx_downloader_->StartDownload(urls, callback_); crx_downloader_->StartDownload(urls, callback_);
RunThreads(); RunThreads();
EXPECT_EQ(1, interceptor.GetHitCount()); EXPECT_EQ(1, get_interceptor_->GetHitCount());
EXPECT_EQ(1, num_download_complete_calls_); EXPECT_EQ(1, num_download_complete_calls_);
EXPECT_EQ(kExpectedContext, crx_context_); EXPECT_EQ(kExpectedContext, crx_context_);
...@@ -329,8 +325,7 @@ TEST_F(CrxDownloaderTest, TwoUrls_SecondInvalid) { ...@@ -329,8 +325,7 @@ TEST_F(CrxDownloaderTest, TwoUrls_SecondInvalid) {
GURL("http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx"); GURL("http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx");
const base::FilePath test_file(MakeTestFilePath(kTestFileName)); const base::FilePath test_file(MakeTestFilePath(kTestFileName));
GetInterceptor interceptor; get_interceptor_->SetResponse(expected_crx_url, test_file);
interceptor.SetResponse(expected_crx_url, test_file);
std::vector<GURL> urls; std::vector<GURL> urls;
urls.push_back(expected_crx_url); urls.push_back(expected_crx_url);
...@@ -339,7 +334,7 @@ TEST_F(CrxDownloaderTest, TwoUrls_SecondInvalid) { ...@@ -339,7 +334,7 @@ TEST_F(CrxDownloaderTest, TwoUrls_SecondInvalid) {
crx_downloader_->StartDownload(urls, callback_); crx_downloader_->StartDownload(urls, callback_);
RunThreads(); RunThreads();
EXPECT_EQ(1, interceptor.GetHitCount()); EXPECT_EQ(1, get_interceptor_->GetHitCount());
EXPECT_EQ(1, num_download_complete_calls_); EXPECT_EQ(1, num_download_complete_calls_);
EXPECT_EQ(kExpectedContext, crx_context_); EXPECT_EQ(kExpectedContext, crx_context_);
...@@ -361,8 +356,7 @@ TEST_F(CrxDownloaderTest, TwoUrls_BothInvalid) { ...@@ -361,8 +356,7 @@ TEST_F(CrxDownloaderTest, TwoUrls_BothInvalid) {
GURL("http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx"); GURL("http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx");
const base::FilePath test_file(MakeTestFilePath(kTestFileName)); const base::FilePath test_file(MakeTestFilePath(kTestFileName));
GetInterceptor interceptor; get_interceptor_->SetResponse(expected_crx_url, test_file);
interceptor.SetResponse(expected_crx_url, test_file);
std::vector<GURL> urls; std::vector<GURL> urls;
urls.push_back(GURL("http://localhost/no/such/file")); urls.push_back(GURL("http://localhost/no/such/file"));
...@@ -372,7 +366,7 @@ TEST_F(CrxDownloaderTest, TwoUrls_BothInvalid) { ...@@ -372,7 +366,7 @@ TEST_F(CrxDownloaderTest, TwoUrls_BothInvalid) {
crx_downloader_->StartDownload(urls, callback_); crx_downloader_->StartDownload(urls, callback_);
RunThreads(); RunThreads();
EXPECT_EQ(0, interceptor.GetHitCount()); EXPECT_EQ(0, get_interceptor_->GetHitCount());
EXPECT_EQ(1, num_download_complete_calls_); EXPECT_EQ(1, num_download_complete_calls_);
EXPECT_EQ(kExpectedContext, crx_context_); EXPECT_EQ(kExpectedContext, crx_context_);
......
...@@ -130,8 +130,6 @@ ...@@ -130,8 +130,6 @@
'test/net/url_request_failed_job.h', 'test/net/url_request_failed_job.h',
'test/net/url_request_mock_http_job.cc', 'test/net/url_request_mock_http_job.cc',
'test/net/url_request_mock_http_job.h', 'test/net/url_request_mock_http_job.h',
'test/net/url_request_prepackaged_interceptor.cc',
'test/net/url_request_prepackaged_interceptor.h',
'test/net/url_request_slow_download_job.cc', 'test/net/url_request_slow_download_job.cc',
'test/net/url_request_slow_download_job.h', 'test/net/url_request_slow_download_job.h',
'test/ppapi_unittest.cc', 'test/ppapi_unittest.cc',
......
...@@ -689,6 +689,8 @@ source_set("test_support") { ...@@ -689,6 +689,8 @@ source_set("test_support") {
"test/spawned_test_server/spawner_communicator.h", "test/spawned_test_server/spawner_communicator.h",
"url_request/test_url_fetcher_factory.cc", "url_request/test_url_fetcher_factory.cc",
"url_request/test_url_fetcher_factory.h", "url_request/test_url_fetcher_factory.h",
"url_request/test_url_request_interceptor.cc",
"url_request/test_url_request_interceptor.h",
"url_request/url_request_test_util.cc", "url_request/url_request_test_util.cc",
"url_request/url_request_test_util.h", "url_request/url_request_test_util.h",
] ]
......
...@@ -966,6 +966,8 @@ ...@@ -966,6 +966,8 @@
'test/spawned_test_server/spawner_communicator.h', 'test/spawned_test_server/spawner_communicator.h',
'url_request/test_url_fetcher_factory.cc', 'url_request/test_url_fetcher_factory.cc',
'url_request/test_url_fetcher_factory.h', 'url_request/test_url_fetcher_factory.h',
'url_request/test_url_request_interceptor.cc',
'url_request/test_url_request_interceptor.h',
'url_request/url_request_test_util.cc', 'url_request/url_request_test_util.cc',
'url_request/url_request_test_util.h', 'url_request/url_request_test_util.h',
], ],
......
...@@ -2,61 +2,67 @@ ...@@ -2,61 +2,67 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/test/net/url_request_prepackaged_interceptor.h" #include "net/url_request/test_url_request_interceptor.h"
#include "base/files/file_util.h" #include "base/file_util.h"
#include "base/threading/sequenced_worker_pool.h" #include "base/threading/sequenced_worker_pool.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "content/public/browser/browser_thread.h"
#include "net/url_request/url_request.h" #include "net/url_request/url_request.h"
#include "net/url_request/url_request_file_job.h" #include "net/url_request/url_request_file_job.h"
#include "net/url_request/url_request_filter.h" #include "net/url_request/url_request_filter.h"
#include "net/url_request/url_request_interceptor.h" #include "net/url_request/url_request_interceptor.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
using content::BrowserThread; namespace net {
namespace content {
namespace { namespace {
class URLRequestPrepackagedJob : public net::URLRequestFileJob { // This class is needed because net::URLRequestFileJob always returns a -1
// HTTP response status code.
class TestURLRequestJob : public net::URLRequestFileJob {
public: public:
URLRequestPrepackagedJob(net::URLRequest* request, TestURLRequestJob(net::URLRequest* request,
net::NetworkDelegate* network_delegate, net::NetworkDelegate* network_delegate,
const base::FilePath& file_path) const base::FilePath& file_path,
: net::URLRequestFileJob( const scoped_refptr<base::TaskRunner>& worker_task_runner)
request, network_delegate, file_path, : net::URLRequestFileJob(request,
content::BrowserThread::GetBlockingPool()-> network_delegate,
GetTaskRunnerWithShutdownBehavior( file_path,
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)) {} worker_task_runner) {}
virtual int GetResponseCode() const OVERRIDE { return 200; } virtual int GetResponseCode() const OVERRIDE { return 200; }
private: private:
virtual ~URLRequestPrepackagedJob() {} virtual ~TestURLRequestJob() {}
DISALLOW_COPY_AND_ASSIGN(URLRequestPrepackagedJob); DISALLOW_COPY_AND_ASSIGN(TestURLRequestJob);
}; };
} // namespace } // namespace
class URLRequestPrepackagedInterceptor::Delegate // This class handles the actual URL request interception. It may be constructed
: public net::URLRequestInterceptor { // on any thread, but all other methods are called on the |network_task_runner|
// thread. It is destroyed by the net::URLRequestFilter singleton.
class TestURLRequestInterceptor::Delegate : public net::URLRequestInterceptor {
public: public:
Delegate(const std::string& scheme, const std::string& hostname) Delegate(const std::string& scheme,
: scheme_(scheme), hostname_(hostname), hit_count_(0) {} const std::string& hostname,
const scoped_refptr<base::TaskRunner>& network_task_runner,
const scoped_refptr<base::TaskRunner>& worker_task_runner)
: scheme_(scheme),
hostname_(hostname),
network_task_runner_(network_task_runner),
worker_task_runner_(worker_task_runner),
hit_count_(0) {}
virtual ~Delegate() {} virtual ~Delegate() {}
void Register() { void Register() {
net::URLRequestFilter::GetInstance()->AddHostnameInterceptor( net::URLRequestFilter::GetInstance()->AddHostnameInterceptor(
scheme_, hostname_, scheme_, hostname_, scoped_ptr<net::URLRequestInterceptor>(this));
scoped_ptr<net::URLRequestInterceptor>(this));
} }
static void Unregister( static void Unregister(const std::string& scheme,
const std::string& scheme, const std::string& hostname) {
const std::string& hostname) {
net::URLRequestFilter::GetInstance()->RemoveHostnameHandler(scheme, net::URLRequestFilter::GetInstance()->RemoveHostnameHandler(scheme,
hostname); hostname);
} }
...@@ -67,11 +73,7 @@ class URLRequestPrepackagedInterceptor::Delegate ...@@ -67,11 +73,7 @@ class URLRequestPrepackagedInterceptor::Delegate
void SetResponse(const GURL& url, void SetResponse(const GURL& url,
const base::FilePath& path, const base::FilePath& path,
bool ignore_query) { bool ignore_query) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
// It's ok to do a blocking disk access on this thread; this class
// is just used for tests.
base::ThreadRestrictions::ScopedAllowIO allow_io;
EXPECT_TRUE(base::PathExists(path));
if (ignore_query) { if (ignore_query) {
ignore_query_responses_[url] = path; ignore_query_responses_[url] = path;
} else { } else {
...@@ -92,7 +94,7 @@ class URLRequestPrepackagedInterceptor::Delegate ...@@ -92,7 +94,7 @@ class URLRequestPrepackagedInterceptor::Delegate
virtual net::URLRequestJob* MaybeInterceptRequest( virtual net::URLRequestJob* MaybeInterceptRequest(
net::URLRequest* request, net::URLRequest* request,
net::NetworkDelegate* network_delegate) const OVERRIDE { net::NetworkDelegate* network_delegate) const OVERRIDE {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
if (request->url().scheme() != scheme_ || if (request->url().scheme() != scheme_ ||
request->url().host() != hostname_) { request->url().host() != hostname_) {
return NULL; return NULL;
...@@ -116,14 +118,16 @@ class URLRequestPrepackagedInterceptor::Delegate ...@@ -116,14 +118,16 @@ class URLRequestPrepackagedInterceptor::Delegate
++hit_count_; ++hit_count_;
} }
return new URLRequestPrepackagedJob(request, return new TestURLRequestJob(
network_delegate, request, network_delegate, it->second, worker_task_runner_);
it->second);
} }
const std::string scheme_; const std::string scheme_;
const std::string hostname_; const std::string hostname_;
const scoped_refptr<base::TaskRunner> network_task_runner_;
const scoped_refptr<base::TaskRunner> worker_task_runner_;
ResponseMap responses_; ResponseMap responses_;
ResponseMap ignore_query_responses_; ResponseMap ignore_query_responses_;
...@@ -133,55 +137,63 @@ class URLRequestPrepackagedInterceptor::Delegate ...@@ -133,55 +137,63 @@ class URLRequestPrepackagedInterceptor::Delegate
DISALLOW_COPY_AND_ASSIGN(Delegate); DISALLOW_COPY_AND_ASSIGN(Delegate);
}; };
TestURLRequestInterceptor::TestURLRequestInterceptor(
URLRequestPrepackagedInterceptor::URLRequestPrepackagedInterceptor(
const std::string& scheme, const std::string& scheme,
const std::string& hostname) const std::string& hostname,
const scoped_refptr<base::TaskRunner>& network_task_runner,
const scoped_refptr<base::TaskRunner>& worker_task_runner)
: scheme_(scheme), : scheme_(scheme),
hostname_(hostname), hostname_(hostname),
delegate_(new Delegate(scheme, hostname)) { network_task_runner_(network_task_runner),
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, delegate_(new Delegate(scheme,
base::Bind(&Delegate::Register, hostname,
base::Unretained(delegate_))); network_task_runner_,
worker_task_runner)) {
network_task_runner_->PostTask(
FROM_HERE, base::Bind(&Delegate::Register, base::Unretained(delegate_)));
} }
URLRequestPrepackagedInterceptor::~URLRequestPrepackagedInterceptor() { TestURLRequestInterceptor::~TestURLRequestInterceptor() {
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, network_task_runner_->PostTask(
base::Bind(&Delegate::Unregister, FROM_HERE, base::Bind(&Delegate::Unregister, scheme_, hostname_));
scheme_,
hostname_));
} }
void URLRequestPrepackagedInterceptor::SetResponse( void TestURLRequestInterceptor::SetResponse(const GURL& url,
const GURL& url, const base::FilePath& path) {
const base::FilePath& path) {
CHECK_EQ(scheme_, url.scheme()); CHECK_EQ(scheme_, url.scheme());
CHECK_EQ(hostname_, url.host()); CHECK_EQ(hostname_, url.host());
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, network_task_runner_->PostTask(FROM_HERE,
base::Bind(&Delegate::SetResponse, base::Bind(&Delegate::SetResponse,
base::Unretained(delegate_), url, path, base::Unretained(delegate_),
false)); url,
path,
false));
} }
void URLRequestPrepackagedInterceptor::SetResponseIgnoreQuery( void TestURLRequestInterceptor::SetResponseIgnoreQuery(
const GURL& url, const GURL& url,
const base::FilePath& path) { const base::FilePath& path) {
CHECK_EQ(scheme_, url.scheme()); CHECK_EQ(scheme_, url.scheme());
CHECK_EQ(hostname_, url.host()); CHECK_EQ(hostname_, url.host());
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, network_task_runner_->PostTask(FROM_HERE,
base::Bind(&Delegate::SetResponse, base::Bind(&Delegate::SetResponse,
base::Unretained(delegate_), url, path, base::Unretained(delegate_),
true)); url,
path,
true));
} }
int URLRequestPrepackagedInterceptor::GetHitCount() { int TestURLRequestInterceptor::GetHitCount() {
return delegate_->GetHitCount(); return delegate_->GetHitCount();
} }
LocalHostTestURLRequestInterceptor::LocalHostTestURLRequestInterceptor(
URLLocalHostRequestPrepackagedInterceptor const scoped_refptr<base::TaskRunner>& network_task_runner,
::URLLocalHostRequestPrepackagedInterceptor() const scoped_refptr<base::TaskRunner>& worker_task_runner)
: URLRequestPrepackagedInterceptor("http", "localhost") { : TestURLRequestInterceptor("http",
"localhost",
network_task_runner,
worker_task_runner) {
} }
} // namespace content } // namespace net
...@@ -2,38 +2,49 @@ ...@@ -2,38 +2,49 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_INTERCEPTOR_H_ #ifndef NET_URL_REQUEST_TEST_URL_REQUEST_INTERCEPTOR_H_
#define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_INTERCEPTOR_H_ #define NET_URL_REQUEST_TEST_URL_REQUEST_INTERCEPTOR_H_
#include <string> #include <string>
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/memory/ref_counted.h"
class GURL; class GURL;
namespace base { namespace base {
class FilePath; class FilePath;
class TaskRunner;
} }
namespace content { namespace net {
// Intercepts HTTP requests and gives pre-defined responses to specified URLs. // Intercepts HTTP requests and gives pre-defined responses to specified URLs.
// The pre-defined responses are loaded from files on disk. The interception // The pre-defined responses are loaded from files on disk. The interception
// occurs while the URLRequestPrepackagedInterceptor is alive. // occurs while the TestURLRequestInterceptor is alive. This class may be
class URLRequestPrepackagedInterceptor { // instantiated on any thread.
class TestURLRequestInterceptor {
public: public:
// Registers an interceptor for urls using |scheme| and |hostname|. Urls // Registers an interceptor for URLs using |scheme| and |hostname|. URLs
// passed to "SetResponse" are required to use |scheme| and |hostname|. // passed to "SetResponse" are required to use |scheme| and |hostname|.
URLRequestPrepackagedInterceptor(const std::string& scheme, // |network_task_runner| is the task runner used for network activity
const std::string& hostname); // (e.g. where URL requests are processed).
virtual ~URLRequestPrepackagedInterceptor(); // |worker_task_runner| will be used to read the files specified by
// either SetResponse() or SetResponseIgnoreQuery() asynchronously. It
// must be a task runner allowed to perform disk IO.
TestURLRequestInterceptor(
const std::string& scheme,
const std::string& hostname,
const scoped_refptr<base::TaskRunner>& network_task_runner,
const scoped_refptr<base::TaskRunner>& worker_task_runner);
virtual ~TestURLRequestInterceptor();
// When requests for |url| arrive, respond with the contents of |path|. The // When requests for |url| arrive, respond with the contents of |path|. The
// hostname and scheme of |url| must match the corresponding parameters // hostname and scheme of |url| must match the corresponding parameters
// passed as constructor arguments. // passed as constructor arguments.
void SetResponse(const GURL& url, const base::FilePath& path); void SetResponse(const GURL& url, const base::FilePath& path);
// Identical to SetResponse except that query parameters are ignored on // Identical to SetResponse, except that query parameters are ignored on
// incoming URLs when comparing against |url|. // incoming URLs when comparing against |url|.
void SetResponseIgnoreQuery(const GURL& url, const base::FilePath& path); void SetResponseIgnoreQuery(const GURL& url, const base::FilePath& path);
...@@ -46,24 +57,28 @@ class URLRequestPrepackagedInterceptor { ...@@ -46,24 +57,28 @@ class URLRequestPrepackagedInterceptor {
const std::string scheme_; const std::string scheme_;
const std::string hostname_; const std::string hostname_;
// After creation, |delegate_| lives on the IO thread, and a task to delete scoped_refptr<base::TaskRunner> network_task_runner_;
// it is posted from ~URLRequestPrepackagedInterceptor().
// After creation, |delegate_| lives on the thread of the
// |network_task_runner_|, and a task to delete it is posted from
// ~TestURLRequestInterceptor().
Delegate* delegate_; Delegate* delegate_;
DISALLOW_COPY_AND_ASSIGN(URLRequestPrepackagedInterceptor); DISALLOW_COPY_AND_ASSIGN(TestURLRequestInterceptor);
}; };
// Specialization of URLRequestPrepackagedInterceptor where scheme is "http" and // Specialization of TestURLRequestInterceptor where scheme is "http" and
// hostname is "localhost". // hostname is "localhost".
class URLLocalHostRequestPrepackagedInterceptor class LocalHostTestURLRequestInterceptor : public TestURLRequestInterceptor {
: public URLRequestPrepackagedInterceptor {
public: public:
URLLocalHostRequestPrepackagedInterceptor(); LocalHostTestURLRequestInterceptor(
const scoped_refptr<base::TaskRunner>& network_task_runner,
const scoped_refptr<base::TaskRunner>& worker_task_runner);
private: private:
DISALLOW_COPY_AND_ASSIGN(URLLocalHostRequestPrepackagedInterceptor); DISALLOW_COPY_AND_ASSIGN(LocalHostTestURLRequestInterceptor);
}; };
} // namespace content } // namespace net
#endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_INTERCEPTOR_H_ #endif // NET_URL_REQUEST_TEST_URL_REQUEST_INTERCEPTOR_H_
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