Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Unified Diff: chrome/browser/automation/chrome_frame_automation_provider.cc

Issue 9570017: Defer shutting down Chrome after the CF automation connection goes away. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing grt's latest nit. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/automation/chrome_frame_automation_provider.cc
diff --git a/chrome/browser/automation/chrome_frame_automation_provider.cc b/chrome/browser/automation/chrome_frame_automation_provider.cc
index ce2f6a42d095bb7cad8534ab2d900338073a8ffc..b7f21afe58ea3e7d18d727d6725fd86881a984b8 100644
--- a/chrome/browser/automation/chrome_frame_automation_provider.cc
+++ b/chrome/browser/automation/chrome_frame_automation_provider.cc
@@ -1,15 +1,21 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/automation/chrome_frame_automation_provider.h"
+
+#include "base/command_line.h"
+#include "base/string_number_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/automation_messages.h"
+#include "chrome/common/chrome_switches.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_channel.h"
+const int kMaxChromeShutdownDelaySeconds = 60*60;
+
ChromeFrameAutomationProvider::ChromeFrameAutomationProvider(Profile* profile)
: AutomationProvider(profile) {
DCHECK(g_browser_process);
@@ -19,8 +25,37 @@ ChromeFrameAutomationProvider::ChromeFrameAutomationProvider(Profile* profile)
ChromeFrameAutomationProvider::~ChromeFrameAutomationProvider() {
DCHECK(g_browser_process);
- if (g_browser_process)
- g_browser_process->ReleaseModule();
+ if (g_browser_process) {
+ CommandLine& cmd_line = *CommandLine::ForCurrentProcess();
+
+ CommandLine::StringType shutdown_delay(
+ cmd_line.GetSwitchValueNative(switches::kChromeFrameShutdownDelay));
+ if (!shutdown_delay.empty()) {
+ VLOG(1) << "ChromeFrameAutomationProvider: "
slightlyoff 2012/03/05 12:35:53 this is going to use streamio which, IIRC, once ha
robertshield 2012/03/05 13:33:25 We use this pattern to log all throughout the code
+ "Scheduling ReleaseBrowserProcess.";
+
+ // Grab the specified shutdown delay.
+ int shutdown_delay_seconds = 0;
+ base::StringToInt(shutdown_delay, &shutdown_delay_seconds);
+
+ // Clamp to reasonable values.
+ if (shutdown_delay_seconds < 0)
+ shutdown_delay_seconds = 0;
+ else if (shutdown_delay_seconds > kMaxChromeShutdownDelaySeconds)
+ shutdown_delay_seconds = kMaxChromeShutdownDelaySeconds;
slightlyoff 2012/03/05 12:35:53 Are there min/max functions somewhere for this?
robertshield 2012/03/05 13:33:25 Done.
+
+ // We have Chrome Frame defer Chrome shutdown for a time to improve
+ // intra-page load times.
slightlyoff 2012/03/05 12:35:53 Add a bug # for tracking perf here?
robertshield 2012/03/05 13:33:25 Good idea, I'll track it under the original bug nu
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&ChromeFrameAutomationProvider::ReleaseBrowserProcess),
+ base::TimeDelta::FromSeconds(shutdown_delay_seconds));
+ } else {
+ VLOG(1) << "ChromeFrameAutomationProvider: "
+ "Releasing browser module with no delay.";
+ g_browser_process->ReleaseModule();
+ }
+ }
}
bool ChromeFrameAutomationProvider::OnMessageReceived(
@@ -86,3 +121,12 @@ bool ChromeFrameAutomationProvider::IsValidMessage(uint32 type) {
return is_valid_message;
}
+
+// static
+void ChromeFrameAutomationProvider::ReleaseBrowserProcess() {
+ if (g_browser_process) {
+ VLOG(1) << "ChromeFrameAutomationProvider: "
+ "Releasing browser process.";
+ g_browser_process->ReleaseModule();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698