OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/automation/chrome_frame_automation_provider.h" | 5 #include "chrome/browser/automation/chrome_frame_automation_provider.h" |
6 | |
7 #include "base/command_line.h" | |
8 #include "base/string_number_conversions.h" | |
6 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
7 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
9 #include "chrome/common/automation_messages.h" | 12 #include "chrome/common/automation_messages.h" |
13 #include "chrome/common/chrome_switches.h" | |
10 #include "ipc/ipc_message.h" | 14 #include "ipc/ipc_message.h" |
11 #include "ipc/ipc_channel.h" | 15 #include "ipc/ipc_channel.h" |
12 | 16 |
17 | |
13 ChromeFrameAutomationProvider::ChromeFrameAutomationProvider(Profile* profile) | 18 ChromeFrameAutomationProvider::ChromeFrameAutomationProvider(Profile* profile) |
14 : AutomationProvider(profile) { | 19 : AutomationProvider(profile) { |
15 DCHECK(g_browser_process); | 20 DCHECK(g_browser_process); |
16 if (g_browser_process) | 21 if (g_browser_process) |
17 g_browser_process->AddRefModule(); | 22 g_browser_process->AddRefModule(); |
18 } | 23 } |
19 | 24 |
20 ChromeFrameAutomationProvider::~ChromeFrameAutomationProvider() { | 25 ChromeFrameAutomationProvider::~ChromeFrameAutomationProvider() { |
21 DCHECK(g_browser_process); | 26 DCHECK(g_browser_process); |
22 if (g_browser_process) | 27 if (g_browser_process) { |
23 g_browser_process->ReleaseModule(); | 28 CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); |
29 if (cmd_line.HasSwitch(switches::kChromeFrameShutdownDelay)) { | |
grt (UTC plus 2)
2012/03/02 20:13:37
please rework this block to:
CommandLine::StringT
robertshield
2012/03/02 20:33:37
Done.
| |
30 VLOG(1) << "ChromeFrameAutomationProvider: " | |
31 "Scheduling ReleaseBrowserProcess."; | |
32 | |
33 // Grab the specified shutdown delay. | |
34 int shutdown_delay_seconds = 0; | |
35 std::string shutdown_delay( | |
36 cmd_line.GetSwitchValueASCII(switches::kChromeFrameShutdownDelay)); | |
37 base::StringToInt(shutdown_delay, &shutdown_delay_seconds); | |
grt (UTC plus 2)
2012/03/02 20:13:37
in worst-case conditions, shutdown_delay_seconds c
robertshield
2012/03/02 20:33:37
Done.
| |
38 | |
39 // We have Chrome Frame defer Chrome shutdown for a time to improve | |
40 // intra-page load times. | |
41 MessageLoop::current()->PostDelayedTask( | |
42 FROM_HERE, | |
43 base::Bind(&ChromeFrameAutomationProvider::ReleaseBrowserProcess), | |
44 base::TimeDelta::FromSeconds(shutdown_delay_seconds)); | |
45 } else { | |
46 VLOG(1) << "ChromeFrameAutomationProvider: " | |
47 "Releasing browser module with no delay."; | |
48 g_browser_process->ReleaseModule(); | |
49 } | |
50 } | |
24 } | 51 } |
25 | 52 |
26 bool ChromeFrameAutomationProvider::OnMessageReceived( | 53 bool ChromeFrameAutomationProvider::OnMessageReceived( |
27 const IPC::Message& message) { | 54 const IPC::Message& message) { |
28 if (IsValidMessage(message.type())) | 55 if (IsValidMessage(message.type())) |
29 return AutomationProvider::OnMessageReceived(message); | 56 return AutomationProvider::OnMessageReceived(message); |
30 | 57 |
31 OnUnhandledMessage(message); | 58 OnUnhandledMessage(message); |
32 return false; | 59 return false; |
33 } | 60 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 is_valid_message = true; | 106 is_valid_message = true; |
80 break; | 107 break; |
81 } | 108 } |
82 | 109 |
83 default: | 110 default: |
84 break; | 111 break; |
85 } | 112 } |
86 | 113 |
87 return is_valid_message; | 114 return is_valid_message; |
88 } | 115 } |
116 | |
117 // static | |
118 void ChromeFrameAutomationProvider::ReleaseBrowserProcess() { | |
119 if (g_browser_process) { | |
120 VLOG(1) << "ChromeFrameAutomationProvider: " | |
121 "Releasing browser process."; | |
122 g_browser_process->ReleaseModule(); | |
123 } | |
124 } | |
OLD | NEW |