summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-24 22:53:56 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-24 22:53:56 +0000
commit88bb912cafbfa299fea3c54ebd9f5c7e789ae122 (patch)
tree1024251d976e8d3251dd33bbfb7df1540ecb4b9c
parent8a474e1987e1b8bb7c826a0473ee4320f38329eb (diff)
downloadchromium_src-88bb912cafbfa299fea3c54ebd9f5c7e789ae122.zip
chromium_src-88bb912cafbfa299fea3c54ebd9f5c7e789ae122.tar.gz
chromium_src-88bb912cafbfa299fea3c54ebd9f5c7e789ae122.tar.bz2
Launching ASH on Windows 8 should activate an existing instance if one exits.
The current behavior when there is an existing instance of ASH is that the launch fails taking down the existing instance of ASH. This is because metro app launches go through the delegate execute handler which first tries to launch the metro viewer process (browser). If we have an existing browser process which has an active MetroViewerProcessHost instance, we delete it first and recreate it. This takes down the existing ASH instance and attempts to launch the new one fail, because of a race condition in the metro startup code. Fix is to create a new instance of the MetroViewerProcessHost instance only if one does not exist in the BrowserProcessImpl::PerformInitForWindowsAura function which is invoked when a brower process processes a launch command line. We reset the MetroViewerProcessHost instance when we receive an OnChannelError notification in the MetroViewerProcessHost class. It in turn invokes the virtual function OnMetroViewerProcessTerminated added on the BrowserProcess interface with a windows aura specific implementation in the browser_process_impl_win.cc file. BUG=234429 R=cpu Review URL: https://codereview.chromium.org/13973023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@196254 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_process.h5
-rw-r--r--chrome/browser/browser_process_impl.h3
-rw-r--r--chrome/browser/browser_process_impl_win.cc7
-rw-r--r--chrome/browser/metro_viewer/metro_viewer_process_host_win.cc3
-rw-r--r--chrome/browser/metro_viewer/metro_viewer_process_host_win.h2
-rw-r--r--chrome/test/base/testing_browser_process.h4
6 files changed, 22 insertions, 2 deletions
diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h
index 8087f73..a85cd75 100644
--- a/chrome/browser/browser_process.h
+++ b/chrome/browser/browser_process.h
@@ -230,6 +230,11 @@ class BrowserProcess {
virtual bool created_local_state() const = 0;
+#if defined(OS_WIN) && defined(USE_AURA)
+ // Invoked when the ASH metro viewer process on Windows 8 exits.
+ virtual void OnMetroViewerProcessTerminated() = 0;
+#endif
+
private:
DISALLOW_COPY_AND_ASSIGN(BrowserProcess);
};
diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h
index 1401864..7c44781 100644
--- a/chrome/browser/browser_process_impl.h
+++ b/chrome/browser/browser_process_impl.h
@@ -139,6 +139,9 @@ class BrowserProcessImpl : public BrowserProcess,
virtual void PlatformSpecificCommandLineProcessing(
const CommandLine& command_line) OVERRIDE;
virtual bool created_local_state() const OVERRIDE;
+#if defined(OS_WIN) && defined(USE_AURA)
+ virtual void OnMetroViewerProcessTerminated() OVERRIDE;
+#endif
static void RegisterPrefs(PrefRegistrySimple* registry);
diff --git a/chrome/browser/browser_process_impl_win.cc b/chrome/browser/browser_process_impl_win.cc
index 1857fbf..9d013fd 100644
--- a/chrome/browser/browser_process_impl_win.cc
+++ b/chrome/browser/browser_process_impl_win.cc
@@ -18,9 +18,14 @@ void BrowserProcessImpl::PlatformSpecificCommandLineProcessing(
}
#if defined(USE_AURA)
+void BrowserProcessImpl::OnMetroViewerProcessTerminated() {
+ metro_viewer_process_host_.reset(NULL);
+}
+
void BrowserProcessImpl::PerformInitForWindowsAura(
const CommandLine& command_line) {
- if (command_line.HasSwitch(switches::kViewerConnection)) {
+ if (command_line.HasSwitch(switches::kViewerConnection) &&
+ !metro_viewer_process_host_.get()) {
// Tell the metro viewer process host to connect to the given IPC channel.
metro_viewer_process_host_.reset(
new MetroViewerProcessHost(
diff --git a/chrome/browser/metro_viewer/metro_viewer_process_host_win.cc b/chrome/browser/metro_viewer/metro_viewer_process_host_win.cc
index 3ed753a..806d29c 100644
--- a/chrome/browser/metro_viewer/metro_viewer_process_host_win.cc
+++ b/chrome/browser/metro_viewer/metro_viewer_process_host_win.cc
@@ -77,6 +77,9 @@ void MetroViewerProcessHost::OnChannelError() {
g_browser_process->ReleaseModule();
CloseOpenAshBrowsers();
chrome::CloseAsh();
+ // This will delete the MetroViewerProcessHost object. Don't access member
+ // variables/functions after this call.
+ g_browser_process->OnMetroViewerProcessTerminated();
}
void MetroViewerProcessHost::OnSetTargetSurface(
diff --git a/chrome/browser/metro_viewer/metro_viewer_process_host_win.h b/chrome/browser/metro_viewer/metro_viewer_process_host_win.h
index d38531d..1527d52 100644
--- a/chrome/browser/metro_viewer/metro_viewer_process_host_win.h
+++ b/chrome/browser/metro_viewer/metro_viewer_process_host_win.h
@@ -24,6 +24,7 @@ class MetroViewerProcessHost : public IPC::Listener,
explicit MetroViewerProcessHost(const std::string& ipc_channel_name);
virtual ~MetroViewerProcessHost();
+ private:
// IPC::Sender implementation:
virtual bool Send(IPC::Message* msg) OVERRIDE;
@@ -31,7 +32,6 @@ class MetroViewerProcessHost : public IPC::Listener,
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
virtual void OnChannelError() OVERRIDE;
- private:
void OnSetTargetSurface(gfx::NativeViewId target_surface);
scoped_ptr<IPC::ChannelProxy> channel_;
diff --git a/chrome/test/base/testing_browser_process.h b/chrome/test/base/testing_browser_process.h
index cd9fc34..a6aa33f 100644
--- a/chrome/test/base/testing_browser_process.h
+++ b/chrome/test/base/testing_browser_process.h
@@ -114,6 +114,10 @@ class TestingBrowserProcess : public BrowserProcess {
const CommandLine& command_line) OVERRIDE;
virtual bool created_local_state() const OVERRIDE;
+#if defined(OS_WIN) && defined(USE_AURA)
+ virtual void OnMetroViewerProcessTerminated() OVERRIDE {}
+#endif
+
// Set the local state for tests. Consumer is responsible for cleaning it up
// afterwards (using ScopedTestingLocalState, for example).
void SetLocalState(PrefService* local_state);