diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-28 12:51:39 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-28 12:51:39 +0000 |
commit | 042666f262a0c2ff601402e95f94fe9664a03f17 (patch) | |
tree | 508140a07a104fd3dd03b4c4c6548161de30f67f /chrome_frame | |
parent | 1d697f38d70b8edaca243a49f790b525c1c95a9d (diff) | |
download | chromium_src-042666f262a0c2ff601402e95f94fe9664a03f17.zip chromium_src-042666f262a0c2ff601402e95f94fe9664a03f17.tar.gz chromium_src-042666f262a0c2ff601402e95f94fe9664a03f17.tar.bz2 |
Have content/ create and destroy its own threads.
Change embedding API and embedders to allow for this.
Push inheritance of base::Thread down to content::BrowserThreadImpl so
that content::BrowserThread is just a namespace for API functions.
This change temporarily disables chrome_frame_net_tests as agreed by the CF lead, see bug 105435.
TBR=ben@chromium.org (IWYU change only)
BUG=98716,104578,105435
Review URL: http://codereview.chromium.org/8477004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111695 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r-- | chrome_frame/chrome_frame.gyp | 1 | ||||
-rw-r--r-- | chrome_frame/test/net/fake_external_tab.cc | 44 | ||||
-rw-r--r-- | chrome_frame/test/net/fake_external_tab.h | 11 |
3 files changed, 44 insertions, 12 deletions
diff --git a/chrome_frame/chrome_frame.gyp b/chrome_frame/chrome_frame.gyp index f1eb15f..c14440b 100644 --- a/chrome_frame/chrome_frame.gyp +++ b/chrome_frame/chrome_frame.gyp @@ -380,6 +380,7 @@ '../chrome/chrome.gyp:syncapi_core', '../chrome/chrome_resources.gyp:chrome_resources', '../content/content.gyp:content_gpu', + '../content/content.gyp:test_support_content', '../net/net.gyp:net', '../net/net.gyp:net_test_support', '../skia/skia.gyp:skia', diff --git a/chrome_frame/test/net/fake_external_tab.cc b/chrome_frame/test/net/fake_external_tab.cc index b33ad1e..5a7d371 100644 --- a/chrome_frame/test/net/fake_external_tab.cc +++ b/chrome_frame/test/net/fake_external_tab.cc @@ -23,10 +23,12 @@ #include "base/system_monitor/system_monitor.h" #include "base/test/test_timeouts.h" #include "base/threading/platform_thread.h" +#include "base/threading/thread.h" #include "base/win/scoped_com_initializer.h" #include "base/win/scoped_comptr.h" #include "base/win/scoped_handle.h" #include "chrome/browser/automation/automation_provider_list.h" +#include "chrome/browser/browser_process_impl.h" // TODO(joi): Remove #include "chrome/browser/chrome_content_browser_client.h" #include "chrome/browser/prefs/browser_prefs.h" #include "chrome/browser/prefs/pref_service.h" @@ -52,6 +54,7 @@ #include "content/public/browser/render_process_host.h" #include "content/public/common/content_client.h" #include "content/public/common/content_paths.h" +#include "content/test/test_browser_thread.h" // TODO(joi): Remove #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/ui_base_paths.h" @@ -273,8 +276,6 @@ void FakeExternalTab::Initialize() { browser_process_->local_state()->RegisterBooleanPref( prefs::kMetricsReportingEnabled, false); - FilePath profile_path(ProfileManager::GetDefaultProfileDir(user_data())); - // Initialize the content client which that code uses to talk to Chrome. content::SetContentClient(&g_chrome_content_client.Get()); @@ -283,14 +284,12 @@ void FakeExternalTab::Initialize() { content::GetContentClient()->set_browser(&g_browser_client.Get()); content::GetContentClient()->set_renderer(&g_renderer_client.Get()); +} +void FakeExternalTab::InitializePostThreadsCreated() { + FilePath profile_path(ProfileManager::GetDefaultProfileDir(user_data())); Profile* profile = g_browser_process->profile_manager()->GetProfile(profile_path); - - // Create the child threads. - g_browser_process->db_thread(); - g_browser_process->file_thread(); - g_browser_process->io_thread(); } void FakeExternalTab::Shutdown() { @@ -301,16 +300,39 @@ void FakeExternalTab::Shutdown() { ResourceBundle::CleanupSharedInstance(); } +// TODO(joi): Remove! +class ChromeFrameFriendOfBrowserProcessImpl { + public: + static void CreateIOThreadState() { + reinterpret_cast<BrowserProcessImpl*>( + g_browser_process)->CreateIOThreadState(); + } +}; + CFUrlRequestUnittestRunner::CFUrlRequestUnittestRunner(int argc, char** argv) : NetTestSuite(argc, argv), chrome_frame_html_("/chrome_frame", kChromeFrameHtml), registrar_(chrome_frame_test::GetTestBedType()), test_result_(0) { // Register the main thread by instantiating it, but don't call any methods. - main_thread_.reset(new content::DeprecatedBrowserThread( + main_thread_.reset(new content::TestBrowserThread( BrowserThread::UI, MessageLoop::current())); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); fake_chrome_.Initialize(); + + db_thread_.reset(new content::TestBrowserThread(BrowserThread::DB)); + db_thread_->Start(); + + file_thread_.reset(new content::TestBrowserThread(BrowserThread::FILE)); + file_thread_->Start(); + + ChromeFrameFriendOfBrowserProcessImpl::CreateIOThreadState(); + + io_thread_.reset(new content::TestBrowserThread(BrowserThread::IO)); + io_thread_->StartIOThread(); + + fake_chrome_.InitializePostThreadsCreated(); + pss_subclass_.reset(new ProcessSingletonSubclass(this)); EXPECT_TRUE(pss_subclass_->Subclass(fake_chrome_.user_data())); StartChromeFrameInHostBrowser(); @@ -587,13 +609,15 @@ const char* IEVersionToString(IEVersion version) { } int main(int argc, char** argv) { - if (chrome_frame_test::GetInstalledIEVersion() >= IE_9) { + // TODO(joi): Remove the "true" part here and fix the log statement below. + if (true || chrome_frame_test::GetInstalledIEVersion() >= IE_9) { // Adding this here as the command line and the logging stuff gets // initialized in the NetTestSuite constructor. Did not want to break that. base::AtExitManager at_exit_manager; CommandLine::Init(argc, argv); CFUrlRequestUnittestRunner::InitializeLogging(); - LOG(INFO) << "Not running ChromeFrame net tests on IE9+"; + LOG(INFO) << "Temporarily not running any ChromeFrame " + << "net tests (http://crbug.com/105435)"; return 0; } diff --git a/chrome_frame/test/net/fake_external_tab.h b/chrome_frame/test/net/fake_external_tab.h index 756e8f8..e3eb6b1 100644 --- a/chrome_frame/test/net/fake_external_tab.h +++ b/chrome_frame/test/net/fake_external_tab.h @@ -17,7 +17,7 @@ #include "chrome_frame/test/net/test_automation_provider.h" #include "chrome_frame/test/test_server.h" #include "chrome_frame/test_utils.h" -#include "content/public/browser/browser_thread.h" +#include "content/test/test_browser_thread.h" #include "net/base/net_test_suite.h" class ProcessSingleton; @@ -32,6 +32,7 @@ class FakeExternalTab { virtual ~FakeExternalTab(); virtual void Initialize(); + virtual void InitializePostThreadsCreated(); virtual void Shutdown(); const FilePath& user_data() const { @@ -105,9 +106,15 @@ class CFUrlRequestUnittestRunner // on the main thread. FakeExternalTab fake_chrome_; scoped_ptr<ProcessSingletonSubclass> pss_subclass_; - scoped_ptr<content::DeprecatedBrowserThread> main_thread_; + scoped_ptr<content::TestBrowserThread> main_thread_; ScopedChromeFrameRegistrar registrar_; int test_result_; + + // TODO(joi): This should be fixed so that this test executable uses + // content::BrowserMainParts. As it stands it is a horrible hack. + scoped_ptr<content::TestBrowserThread> db_thread_; + scoped_ptr<content::TestBrowserThread> file_thread_; + scoped_ptr<content::TestBrowserThread> io_thread_; }; #endif // CHROME_FRAME_TEST_NET_FAKE_EXTERNAL_TAB_H_ |