OLD | NEW |
---|---|
1 // Copyright (c) 2012 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_win.h" | 5 #include "chrome/browser/automation/chrome_frame_automation_provider_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
grt (UTC plus 2)
2013/04/11 18:15:57
remove
robertshield
2013/04/12 19:49:07
Done.
| |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
grt (UTC plus 2)
2013/04/11 18:15:57
remove
robertshield
2013/04/12 19:49:07
Done.
| |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
grt (UTC plus 2)
2013/04/11 18:15:57
remove
robertshield
2013/04/12 19:49:07
Done.
| |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
14 #include "chrome/common/automation_messages.h" | 14 #include "chrome/common/automation_messages.h" |
15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
16 #include "ipc/ipc_channel.h" | 16 #include "ipc/ipc_channel.h" |
17 #include "ipc/ipc_message.h" | 17 #include "ipc/ipc_message.h" |
18 | 18 |
19 const int kMaxChromeShutdownDelaySeconds = 60*60; | 19 const int kMaxChromeShutdownDelaySeconds = 60*60; |
grt (UTC plus 2)
2013/04/11 18:15:57
remove
robertshield
2013/04/12 19:49:07
Done.
| |
20 | 20 |
21 ChromeFrameAutomationProvider::ChromeFrameAutomationProvider(Profile* profile) | 21 ChromeFrameAutomationProvider::ChromeFrameAutomationProvider(Profile* profile) |
22 : AutomationProvider(profile) { | 22 : AutomationProvider(profile) { |
23 DCHECK(g_browser_process); | 23 DCHECK(g_browser_process); |
24 if (g_browser_process) | 24 if (g_browser_process) |
25 g_browser_process->AddRefModule(); | 25 g_browser_process->AddRefModule(); |
26 } | 26 } |
27 | 27 |
28 ChromeFrameAutomationProvider::~ChromeFrameAutomationProvider() { | 28 ChromeFrameAutomationProvider::~ChromeFrameAutomationProvider() { |
29 DCHECK(g_browser_process); | 29 DCHECK(g_browser_process); |
30 if (g_browser_process) { | 30 if (g_browser_process) { |
grt (UTC plus 2)
2013/04/11 18:15:57
remove braces
robertshield
2013/04/12 19:49:07
Done.
| |
31 CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); | 31 g_browser_process->ReleaseModule(); |
32 | |
33 CommandLine::StringType shutdown_delay( | |
34 cmd_line.GetSwitchValueNative(switches::kChromeFrameShutdownDelay)); | |
35 if (!shutdown_delay.empty()) { | |
36 VLOG(1) << "ChromeFrameAutomationProvider: " | |
37 "Scheduling ReleaseBrowserProcess."; | |
38 | |
39 // Grab the specified shutdown delay. | |
40 int shutdown_delay_seconds = 0; | |
41 base::StringToInt(shutdown_delay, &shutdown_delay_seconds); | |
42 | |
43 // Clamp to reasonable values. | |
44 shutdown_delay_seconds = std::max(0, shutdown_delay_seconds); | |
45 shutdown_delay_seconds = std::min(shutdown_delay_seconds, | |
46 kMaxChromeShutdownDelaySeconds); | |
47 | |
48 // We have Chrome Frame defer Chrome shutdown for a time to improve | |
49 // intra-page load times. | |
50 // Note that we are tracking the perf impact of this under | |
51 // http://crbug.com/98506 | |
52 MessageLoop::current()->PostDelayedTask( | |
53 FROM_HERE, | |
54 base::Bind(&ChromeFrameAutomationProvider::ReleaseBrowserProcess), | |
55 base::TimeDelta::FromSeconds(shutdown_delay_seconds)); | |
56 } else { | |
57 VLOG(1) << "ChromeFrameAutomationProvider: " | |
58 "Releasing browser module with no delay."; | |
59 g_browser_process->ReleaseModule(); | |
60 } | |
61 } | 32 } |
62 } | 33 } |
63 | 34 |
64 bool ChromeFrameAutomationProvider::OnMessageReceived( | 35 bool ChromeFrameAutomationProvider::OnMessageReceived( |
65 const IPC::Message& message) { | 36 const IPC::Message& message) { |
66 if (IsValidMessage(message.type())) | 37 if (IsValidMessage(message.type())) |
67 return AutomationProvider::OnMessageReceived(message); | 38 return AutomationProvider::OnMessageReceived(message); |
68 | 39 |
69 OnUnhandledMessage(message); | 40 OnUnhandledMessage(message); |
70 return false; | 41 return false; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 is_valid_message = true; | 84 is_valid_message = true; |
114 break; | 85 break; |
115 } | 86 } |
116 | 87 |
117 default: | 88 default: |
118 break; | 89 break; |
119 } | 90 } |
120 | 91 |
121 return is_valid_message; | 92 return is_valid_message; |
122 } | 93 } |
123 | |
124 // static | |
125 void ChromeFrameAutomationProvider::ReleaseBrowserProcess() { | |
126 if (g_browser_process) { | |
127 VLOG(1) << "ChromeFrameAutomationProvider: Releasing browser process."; | |
128 g_browser_process->ReleaseModule(); | |
129 } | |
130 } | |
OLD | NEW |