diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 39 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider.h | 7 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider_list.cc | 8 | ||||
-rw-r--r-- | chrome/browser/browser_init.cc | 9 | ||||
-rw-r--r-- | chrome/browser/browser_main.cc | 2 | ||||
-rw-r--r-- | chrome/browser/browser_process_impl.cc | 14 | ||||
-rw-r--r-- | chrome/browser/navigation_controller_unittest.cc | 9 | ||||
-rw-r--r-- | chrome/browser/printing/printing_layout_uitest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/render_process_host.cc | 1 | ||||
-rw-r--r-- | chrome/browser/resource_dispatcher_host_unittest.cc | 6 | ||||
-rw-r--r-- | chrome/browser/site_instance_unittest.cc | 3 | ||||
-rw-r--r-- | chrome/browser/url_fetcher_unittest.cc | 6 | ||||
-rw-r--r-- | chrome/browser/web_contents_unittest.cc | 3 |
13 files changed, 44 insertions, 65 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index f23e7d1..d6e6b08 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -582,13 +582,8 @@ class DocumentPrintedNotificationObserver : public NotificationObserver { }; AutomationProvider::AutomationProvider(Profile* profile) - : connected_(false), - redirect_query_(0), + : redirect_query_(0), profile_(profile) { - AutomationProviderList* list = - g_browser_process->InitAutomationProviderList(); - DCHECK(NULL != list); - list->AddProvider(this); browser_tracker_.reset(new AutomationBrowserTracker(this)); window_tracker_.reset(new AutomationWindowTracker(this)); tab_tracker_.reset(new AutomationTabTracker(this)); @@ -601,21 +596,13 @@ AutomationProvider::AutomationProvider(Profile* profile) } AutomationProvider::~AutomationProvider() { - // TODO(vibhor) : Delete the pending observer objects. - AutomationProviderList* list = - g_browser_process->InitAutomationProviderList(); - DCHECK(NULL != list); - list->RemoveProvider(this); } void AutomationProvider::ConnectToChannel(const std::wstring& channel_id) { - scoped_ptr<IPC::Channel> channel( - new IPC::Channel(channel_id, IPC::Channel::MODE_CLIENT, this)); - connected_ = channel->Connect(); - if (connected_) { - channel_.swap(channel); - channel_->Send(new AutomationMsg_Hello(0)); - } + channel_.reset( + new IPC::ChannelProxy(channel_id, IPC::Channel::MODE_CLIENT, this, NULL, + g_browser_process->io_thread()->message_loop())); + channel_->Send(new AutomationMsg_Hello(0)); } void AutomationProvider::SetExpectedTabCount(size_t expected_tabs) { @@ -1450,7 +1437,7 @@ void AutomationProvider::HandleUnused(const IPC::Message& message, int handle) { void AutomationProvider::OnChannelError() { LOG(ERROR) << "AutomationProxy went away, shutting down app."; - delete this; + AutomationProviderList::GetInstance()->RemoveProvider(this); } // TODO(brettw) change this to accept GURLs when history supports it @@ -1478,11 +1465,8 @@ void AutomationProvider::OnRedirectQueryComplete( } bool AutomationProvider::Send(IPC::Message* msg) { - if (connected_) { - DCHECK(channel_.get()); - return channel_->Send(msg); - } - return false; + DCHECK(channel_.get()); + return channel_->Send(msg); } Browser* AutomationProvider::FindAndActivateTab( @@ -2235,7 +2219,8 @@ void TestingAutomationProvider::OnBrowserRemoving(const Browser* browser) { // last browser goes away. if (BrowserList::size() == 1) { // If you change this, update Observer for NOTIFY_SESSION_END below. - MessageLoop::current()->ReleaseSoon(FROM_HERE, this); + MessageLoop::current()->PostTask(FROM_HERE, + NewRunnableMethod(this, &TestingAutomationProvider::OnRemoveProvider)); } } @@ -2248,3 +2233,7 @@ void TestingAutomationProvider::Observe(NotificationType type, // Release balance out the Release scheduled by OnBrowserRemoving. Release(); } + +void TestingAutomationProvider::OnRemoveProvider() { + AutomationProviderList::GetInstance()->RemoveProvider(this); +} diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index 20f34a1..1bde370 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -47,7 +47,7 @@ #include "chrome/browser/automation/automation_autocomplete_edit_tracker.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/history/history.h" -#include "chrome/common/ipc_channel.h" +#include "chrome/common/ipc_channel_proxy.h" #include "chrome/common/ipc_message.h" #include "chrome/common/notification_service.h" @@ -321,8 +321,7 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, typedef ObserverList<NotificationObserver> NotificationObserverList; typedef std::map<NavigationController*, LoginHandler*> LoginHandlerMap; - bool connected_; - scoped_ptr<IPC::Channel> channel_; + scoped_ptr<IPC::ChannelProxy> channel_; scoped_ptr<NotificationObserver> initial_load_observer_; scoped_ptr<NotificationObserver> new_tab_ui_load_observer_; scoped_ptr<NotificationObserver> find_in_page_observer_; @@ -383,5 +382,7 @@ class TestingAutomationProvider : public AutomationProvider, virtual void Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details); + + void OnRemoveProvider(); // Called via PostTask }; #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_H_ diff --git a/chrome/browser/automation/automation_provider_list.cc b/chrome/browser/automation/automation_provider_list.cc index 4d9bb93..8d683d8 100644 --- a/chrome/browser/automation/automation_provider_list.cc +++ b/chrome/browser/automation/automation_provider_list.cc @@ -41,18 +41,15 @@ AutomationProviderList::AutomationProviderList() { AutomationProviderList::~AutomationProviderList() { iterator iter = automation_providers_.begin(); while (iter != automation_providers_.end()) { - AutomationProvider* provider = (*iter); - // Delete the entry first and update the iterator first because the d'tor - // of AutomationProvider will call RemoveProvider, making this iterator - // invalid + (*iter)->Release(); iter = automation_providers_.erase(iter); g_browser_process->ReleaseModule(); - delete provider; } instance_ = NULL; } bool AutomationProviderList::AddProvider(AutomationProvider* provider) { + provider->AddRef(); automation_providers_.push_back(provider); g_browser_process->AddRefModule(); return true; @@ -62,6 +59,7 @@ bool AutomationProviderList::RemoveProvider(AutomationProvider* provider) { const iterator remove_provider = find(automation_providers_.begin(), automation_providers_.end(), provider); if (remove_provider != automation_providers_.end()) { + (*remove_provider)->Release(); automation_providers_.erase(remove_provider); g_browser_process->ReleaseModule(); return true; diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc index ff1fa47..e3a4630 100644 --- a/chrome/browser/browser_init.cc +++ b/chrome/browser/browser_init.cc @@ -718,8 +718,13 @@ template <class AutomationProviderClass> void BrowserInit::CreateAutomationProvider(const std::wstring& channel_id, Profile* profile, size_t expected_tabs) { - AutomationProviderClass* automation = new AutomationProviderClass(profile); - automation->AddRef(); + scoped_refptr<AutomationProviderClass> automation = + new AutomationProviderClass(profile); automation->ConnectToChannel(channel_id); automation->SetExpectedTabCount(expected_tabs); + + AutomationProviderList* list = + g_browser_process->InitAutomationProviderList(); + DCHECK(list); + list->AddProvider(automation); } diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 24f07ce..2287533 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -271,7 +271,7 @@ int BrowserMain(CommandLine &parsed_command_line, int show_command, const char* main_thread_name = "Chrome_BrowserMain"; Thread::SetThreadName(main_thread_name, GetCurrentThreadId()); - MessageLoop::current()->SetThreadName(main_thread_name); + MessageLoop::current()->set_thread_name(main_thread_name); bool already_running = CreateUniqueChromeEvent(); // Make the selection of network stacks early on before any consumers try to diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index ad12c305..3b0560b 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -216,14 +216,10 @@ BrowserProcessImpl::~BrowserProcessImpl() { g_browser_process = NULL; } -// Need to define this so InvokeLater on the MessageLoop works. It's ok -// not to addref/release the MessageLoop here as we *know* the main thread -// isn't going to go away on us. -template <> -struct RunnableMethodTraits<MessageLoop> { - static void RetainCallee(MessageLoop* obj) { } - static void ReleaseCallee(MessageLoop* obj) { } -}; +// Send a QuitTask to the given MessageLoop. +static void PostQuit(MessageLoop* message_loop) { + message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); +} void BrowserProcessImpl::EndSession() { // Notify we are going away. @@ -249,7 +245,7 @@ void BrowserProcessImpl::EndSession() { // otherwise on startup we'll think we crashed. So we block until done and // then proceed with normal shutdown. g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE, - NewRunnableMethod(MessageLoop::current(), &MessageLoop::Quit)); + NewRunnableFunction(PostQuit, MessageLoop::current())); MessageLoop::current()->Run(); } diff --git a/chrome/browser/navigation_controller_unittest.cc b/chrome/browser/navigation_controller_unittest.cc index 51eeb67..cce2cf9 100644 --- a/chrome/browser/navigation_controller_unittest.cc +++ b/chrome/browser/navigation_controller_unittest.cc @@ -666,8 +666,7 @@ TEST_F(NavigationControllerTest, SwitchTypes) { EXPECT_TRUE(contents->controller()->CanGoForward()); // There may be TabContentsCollector tasks pending, so flush them from queue. - MessageLoop::current()->Quit(); - MessageLoop::current()->Run(); + MessageLoop::current()->RunAllPending(); } // Tests what happens when we begin to navigate to a new contents type, but @@ -700,8 +699,7 @@ TEST_F(NavigationControllerTest, SwitchTypes_Discard) { EXPECT_FALSE(contents->controller()->CanGoForward()); // There may be TabContentsCollector tasks pending, so flush them from queue. - MessageLoop::current()->Quit(); - MessageLoop::current()->Run(); + MessageLoop::current()->RunAllPending(); } // Tests that TabContentsTypes that are not in use are deleted (via a @@ -729,8 +727,7 @@ TEST_F(NavigationControllerTest, SwitchTypesCleanup) { contents->CompleteNavigation(1); // There may be TabContentsCollector tasks pending, so flush them from queue. - MessageLoop::current()->Quit(); - MessageLoop::current()->Run(); + MessageLoop::current()->RunAllPending(); // Now that the tasks have been flushed, the first tab type should be gone. ASSERT_TRUE( diff --git a/chrome/browser/printing/printing_layout_uitest.cc b/chrome/browser/printing/printing_layout_uitest.cc index 87c2c13..c3e2060 100644 --- a/chrome/browser/printing/printing_layout_uitest.cc +++ b/chrome/browser/printing/printing_layout_uitest.cc @@ -492,7 +492,7 @@ class DismissTheWindow : public Task { MessageLoop::current()->timer_manager()->StopTimer(timer_); timer_ = NULL; // Unlock the other thread. - other_thread_->Quit(); + other_thread_->PostTask(FROM_HERE, new MessageLoop::QuitTask()); } else { // Maybe it's time to try to click it again. Restart from the begining. dialog_window_ = NULL; diff --git a/chrome/browser/render_process_host.cc b/chrome/browser/render_process_host.cc index be36149..558a161 100644 --- a/chrome/browser/render_process_host.cc +++ b/chrome/browser/render_process_host.cc @@ -285,7 +285,6 @@ bool RenderProcessHost::Init() { switches::kAllowAllActiveX, switches::kMemoryProfiling, switches::kEnableWatchdog, - switches::kMessageLoopStrategy, switches::kMessageLoopHistogrammer, switches::kEnableDCHECK, switches::kSilentDumpOnDCHECK, diff --git a/chrome/browser/resource_dispatcher_host_unittest.cc b/chrome/browser/resource_dispatcher_host_unittest.cc index f2d8154..7d00f6a 100644 --- a/chrome/browser/resource_dispatcher_host_unittest.cc +++ b/chrome/browser/resource_dispatcher_host_unittest.cc @@ -146,11 +146,7 @@ class ResourceDispatcherHostTest : public testing::Test, // Spin up the message loop to kick off the request. static void KickOffRequest() { - // First we post a Quit message to the loop, causing it to terminate after - // processing the messages it currently has queued up. - MessageLoop::current()->Quit(); - // Then we spin up the loop. - MessageLoop::current()->Run(); + MessageLoop::current()->RunAllPending(); } void ResourceDispatcherHostTest::MakeTestRequest(int request_id, diff --git a/chrome/browser/site_instance_unittest.cc b/chrome/browser/site_instance_unittest.cc index 61fb7f0..d1cb055 100644 --- a/chrome/browser/site_instance_unittest.cc +++ b/chrome/browser/site_instance_unittest.cc @@ -129,8 +129,7 @@ TEST(SiteInstanceTest, SiteInstanceDestructor) { contents->CloseContents(); // Make sure that we flush any messages related to WebContents destruction. - MessageLoop::current()->Quit(); - MessageLoop::current()->Run(); + MessageLoop::current()->RunAllPending(); EXPECT_EQ(2, siteDeleteCounter); EXPECT_EQ(2, browsingDeleteCounter); diff --git a/chrome/browser/url_fetcher_unittest.cc b/chrome/browser/url_fetcher_unittest.cc index 2a3b034..4948e27 100644 --- a/chrome/browser/url_fetcher_unittest.cc +++ b/chrome/browser/url_fetcher_unittest.cc @@ -157,7 +157,7 @@ namespace { // because the destructor won't necessarily run on the // same thread that CreateFetcher() did. - main_loop_->Quit(); + main_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask()); // If MessageLoop::current() != main_loop_, it will be shut down when the // main loop returns and this thread subsequently goes out of scope. } @@ -209,7 +209,7 @@ namespace { start_time_ = Time::Now(); fetcher_->Start(); } - + void URLFetcherProtectTest::OnURLFetchComplete(const URLFetcher* source, const GURL& url, const URLRequestStatus& status, @@ -224,7 +224,7 @@ namespace { EXPECT_TRUE(status.is_success()); EXPECT_FALSE(data.empty()); delete fetcher_; - main_loop_->Quit(); + main_loop_->Quit(); } else { // Now running Overload test. static int count = 0; diff --git a/chrome/browser/web_contents_unittest.cc b/chrome/browser/web_contents_unittest.cc index 3b7450c..c62fcfd 100644 --- a/chrome/browser/web_contents_unittest.cc +++ b/chrome/browser/web_contents_unittest.cc @@ -316,8 +316,7 @@ class WebContentsTest : public testing::Test { // Make sure that we flush any messages related to WebContents destruction // before we destroy the profile. - MessageLoop::current()->Quit(); - MessageLoop::current()->Run(); + MessageLoop::current()->RunAllPending(); } scoped_ptr<WebContentsTestingProfile> profile; |