summaryrefslogtreecommitdiffstats
path: root/mandoline
diff options
context:
space:
mode:
authorjam <jam@chromium.org>2015-11-01 19:45:32 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-02 03:46:32 +0000
commitfa71930f2532abee206f44755c2463b7aba9d5cb (patch)
tree1811660daac3ca78b1e247cc4c9df9f81e066411 /mandoline
parent34be42470c6a790b2ad3ffc9685c5f136c76bedb (diff)
downloadchromium_src-fa71930f2532abee206f44755c2463b7aba9d5cb.zip
chromium_src-fa71930f2532abee206f44755c2463b7aba9d5cb.tar.gz
chromium_src-fa71930f2532abee206f44755c2463b7aba9d5cb.tar.bz2
Fix hangs in Mandoline page cycler on Linux with --enable-multiprocess.
This was caused by content handlers sometimes dropping a request. The solution is to implement a simplified version of the two-phase shutdown used by apps. First, the ContentHandler implementation needs to keep a reference for the app's lifetime. Then every time StartApplication is called, a callback is passed along to be run when the content handler instance is destructed. When the ContentHandlerConnection notices that all the instances are deleted, it destructs itself. This releases the ContentHandler implementation which releases the app lifetime reference. BUG=544153, 478251 Review URL: https://codereview.chromium.org/1431573002 Cr-Commit-Position: refs/heads/master@{#357301}
Diffstat (limited to 'mandoline')
-rw-r--r--mandoline/services/core_services/core_services_application_delegate.cc13
-rw-r--r--mandoline/services/core_services/core_services_application_delegate.h3
2 files changed, 11 insertions, 5 deletions
diff --git a/mandoline/services/core_services/core_services_application_delegate.cc b/mandoline/services/core_services/core_services_application_delegate.cc
index 48c0c0a..093beac 100644
--- a/mandoline/services/core_services/core_services_application_delegate.cc
+++ b/mandoline/services/core_services/core_services_application_delegate.cc
@@ -31,18 +31,21 @@ class ApplicationThread : public base::SimpleThread {
core_services_application,
const std::string& url,
scoped_ptr<mojo::ApplicationDelegate> delegate,
- mojo::InterfaceRequest<mojo::Application> request)
+ mojo::InterfaceRequest<mojo::Application> request,
+ const mojo::Callback<void()>& destruct_callback)
: base::SimpleThread(url),
core_services_application_(core_services_application),
core_services_application_task_runner_(
base::MessageLoop::current()->task_runner()),
url_(url),
delegate_(delegate.Pass()),
- request_(request.Pass()) {
+ request_(request.Pass()),
+ destruct_callback_(destruct_callback) {
}
~ApplicationThread() override {
Join();
+ destruct_callback_.Run();
}
// Overridden from base::SimpleThread:
@@ -70,6 +73,7 @@ class ApplicationThread : public base::SimpleThread {
std::string url_;
scoped_ptr<mojo::ApplicationDelegate> delegate_;
mojo::InterfaceRequest<mojo::Application> request_;
+ mojo::Callback<void()> destruct_callback_;
DISALLOW_COPY_AND_ASSIGN(ApplicationThread);
};
@@ -119,7 +123,8 @@ void CoreServicesApplicationDelegate::Create(
void CoreServicesApplicationDelegate::StartApplication(
mojo::InterfaceRequest<mojo::Application> request,
- mojo::URLResponsePtr response) {
+ mojo::URLResponsePtr response,
+ const mojo::Callback<void()>& destruct_callback) {
const std::string url = response->url;
scoped_ptr<mojo::ApplicationDelegate> delegate;
@@ -148,7 +153,7 @@ void CoreServicesApplicationDelegate::StartApplication(
scoped_ptr<ApplicationThread> thread(
new ApplicationThread(weak_factory_.GetWeakPtr(), url, delegate.Pass(),
- request.Pass()));
+ request.Pass(), destruct_callback));
thread->Start();
application_threads_.push_back(thread.Pass());
}
diff --git a/mandoline/services/core_services/core_services_application_delegate.h b/mandoline/services/core_services/core_services_application_delegate.h
index f0129ae..168f068 100644
--- a/mandoline/services/core_services/core_services_application_delegate.h
+++ b/mandoline/services/core_services/core_services_application_delegate.h
@@ -45,7 +45,8 @@ class CoreServicesApplicationDelegate
// Overridden from mojo::ContentHandler:
void StartApplication(
mojo::InterfaceRequest<mojo::Application> request,
- mojo::URLResponsePtr response) override;
+ mojo::URLResponsePtr response,
+ const mojo::Callback<void()>& destruct_callback) override;
// Bindings for all of our connections.
mojo::WeakBindingSet<ContentHandler> handler_bindings_;