OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_frame/chrome_frame_automation.h" | 5 #include "chrome_frame/chrome_frame_automation.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/trace_event.h" | 10 #include "base/trace_event.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 thread_.reset(new base::Thread(WideToASCII(profile_name).c_str())); | 216 thread_.reset(new base::Thread(WideToASCII(profile_name).c_str())); |
217 thread_->Start(); | 217 thread_->Start(); |
218 // Use scoped_refptr so that the params will get released when the task | 218 // Use scoped_refptr so that the params will get released when the task |
219 // has been run. | 219 // has been run. |
220 scoped_refptr<ChromeFrameLaunchParams> ref_params(params); | 220 scoped_refptr<ChromeFrameLaunchParams> ref_params(params); |
221 thread_->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(this, | 221 thread_->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(this, |
222 &AutomationProxyCacheEntry::CreateProxy, ref_params, delegate)); | 222 &AutomationProxyCacheEntry::CreateProxy, ref_params, delegate)); |
223 } | 223 } |
224 | 224 |
225 AutomationProxyCacheEntry::~AutomationProxyCacheEntry() { | 225 AutomationProxyCacheEntry::~AutomationProxyCacheEntry() { |
226 DLOG(INFO) << __FUNCTION__ << profile_name; | 226 DVLOG(1) << __FUNCTION__ << profile_name; |
227 // Attempt to fix chrome_frame_tests crash seen at times on the IE6/IE7 | 227 // Attempt to fix chrome_frame_tests crash seen at times on the IE6/IE7 |
228 // builders. It appears that there are cases when we can enter here when the | 228 // builders. It appears that there are cases when we can enter here when the |
229 // AtExitManager is tearing down the global ProxyCache which causes a crash | 229 // AtExitManager is tearing down the global ProxyCache which causes a crash |
230 // while tearing down the AutomationProxy object due to a NULL MessageLoop | 230 // while tearing down the AutomationProxy object due to a NULL MessageLoop |
231 // The AutomationProxy class uses the SyncChannel which assumes the existence | 231 // The AutomationProxy class uses the SyncChannel which assumes the existence |
232 // of a MessageLoop instance. | 232 // of a MessageLoop instance. |
233 // We leak the AutomationProxy pointer here to avoid a crash. | 233 // We leak the AutomationProxy pointer here to avoid a crash. |
234 if (MessageLoop::current() == NULL) { | 234 if (MessageLoop::current() == NULL) { |
235 proxy_.release(); | 235 proxy_.release(); |
236 } | 236 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 // In headless mode runs like reliability test runs we want full crash dumps | 288 // In headless mode runs like reliability test runs we want full crash dumps |
289 // from chrome. | 289 // from chrome. |
290 if (IsHeadlessMode()) | 290 if (IsHeadlessMode()) |
291 command_line->AppendSwitch(switches::kFullMemoryCrashReport); | 291 command_line->AppendSwitch(switches::kFullMemoryCrashReport); |
292 | 292 |
293 // In accessible mode automation tests expect renderer accessibility to be | 293 // In accessible mode automation tests expect renderer accessibility to be |
294 // enabled in chrome. | 294 // enabled in chrome. |
295 if (IsAccessibleMode()) | 295 if (IsAccessibleMode()) |
296 command_line->AppendSwitch(switches::kForceRendererAccessibility); | 296 command_line->AppendSwitch(switches::kForceRendererAccessibility); |
297 | 297 |
298 DLOG(INFO) << "Profile path: " << params->profile_path().value(); | 298 DVLOG(1) << "Profile path: " << params->profile_path().value(); |
299 command_line->AppendSwitchPath(switches::kUserDataDir, | 299 command_line->AppendSwitchPath(switches::kUserDataDir, |
300 params->profile_path()); | 300 params->profile_path()); |
301 | 301 |
302 std::wstring command_line_string(command_line->command_line_string()); | 302 std::wstring command_line_string(command_line->command_line_string()); |
303 // If there are any extra arguments, append them to the command line. | 303 // If there are any extra arguments, append them to the command line. |
304 if (!params->extra_arguments().empty()) { | 304 if (!params->extra_arguments().empty()) { |
305 command_line_string += L' ' + params->extra_arguments(); | 305 command_line_string += L' ' + params->extra_arguments(); |
306 } | 306 } |
307 | 307 |
308 automation_server_launch_start_time_ = base::TimeTicks::Now(); | 308 automation_server_launch_start_time_ = base::TimeTicks::Now(); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 // Find already existing launcher thread for given profile | 464 // Find already existing launcher thread for given profile |
465 AutoLock lock(lock_); | 465 AutoLock lock(lock_); |
466 for (size_t i = 0; i < proxies_.container().size(); ++i) { | 466 for (size_t i = 0; i < proxies_.container().size(); ++i) { |
467 if (proxies_[i]->IsSameProfile(params->profile_name())) { | 467 if (proxies_[i]->IsSameProfile(params->profile_name())) { |
468 entry = proxies_[i]; | 468 entry = proxies_[i]; |
469 break; | 469 break; |
470 } | 470 } |
471 } | 471 } |
472 | 472 |
473 if (entry == NULL) { | 473 if (entry == NULL) { |
474 DLOG(INFO) << __FUNCTION__ << " creating new proxy entry"; | 474 DVLOG(1) << __FUNCTION__ << " creating new proxy entry"; |
475 entry = new AutomationProxyCacheEntry(params, delegate); | 475 entry = new AutomationProxyCacheEntry(params, delegate); |
476 proxies_.container().push_back(entry); | 476 proxies_.container().push_back(entry); |
477 | 477 |
478 // IE uses the chrome frame provided UMA data uploading scheme. NPAPI | 478 // IE uses the chrome frame provided UMA data uploading scheme. NPAPI |
479 // continues to use Chrome to upload UMA data. | 479 // continues to use Chrome to upload UMA data. |
480 if (!CrashMetricsReporter::GetInstance()->active()) { | 480 if (!CrashMetricsReporter::GetInstance()->active()) { |
481 entry->StartSendUmaInterval(&chrome_frame_histograms_, | 481 entry->StartSendUmaInterval(&chrome_frame_histograms_, |
482 uma_send_interval_); | 482 uma_send_interval_); |
483 } | 483 } |
484 } else if (delegate) { | 484 } else if (delegate) { |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 | 995 |
996 // Invoked in launch background thread. | 996 // Invoked in launch background thread. |
997 void ChromeFrameAutomationClient::LaunchComplete( | 997 void ChromeFrameAutomationClient::LaunchComplete( |
998 ChromeFrameAutomationProxy* proxy, | 998 ChromeFrameAutomationProxy* proxy, |
999 AutomationLaunchResult result) { | 999 AutomationLaunchResult result) { |
1000 // If we're shutting down we don't keep a pointer to the automation server. | 1000 // If we're shutting down we don't keep a pointer to the automation server. |
1001 if (init_state_ != UNINITIALIZING) { | 1001 if (init_state_ != UNINITIALIZING) { |
1002 DCHECK(init_state_ == INITIALIZING); | 1002 DCHECK(init_state_ == INITIALIZING); |
1003 automation_server_ = proxy; | 1003 automation_server_ = proxy; |
1004 } else { | 1004 } else { |
1005 DLOG(INFO) << "Not storing automation server pointer due to shutting down"; | 1005 DVLOG(1) << "Not storing automation server pointer due to shutting down"; |
1006 } | 1006 } |
1007 | 1007 |
1008 if (result == AUTOMATION_SUCCESS) { | 1008 if (result == AUTOMATION_SUCCESS) { |
1009 // NOTE: A potential problem here is that Uninitialize() may just have | 1009 // NOTE: A potential problem here is that Uninitialize() may just have |
1010 // been called so we need to be careful and check the automation_server_ | 1010 // been called so we need to be careful and check the automation_server_ |
1011 // pointer. | 1011 // pointer. |
1012 if (automation_server_ != NULL) { | 1012 if (automation_server_ != NULL) { |
1013 // If we have a valid tab_handle here it means that we are attaching to | 1013 // If we have a valid tab_handle here it means that we are attaching to |
1014 // an existing ExternalTabContainer instance, in which case we don't | 1014 // an existing ExternalTabContainer instance, in which case we don't |
1015 // want to create an external tab instance in Chrome. | 1015 // want to create an external tab instance in Chrome. |
1016 if (external_tab_cookie_ == 0) { | 1016 if (external_tab_cookie_ == 0) { |
1017 // Continue with Initialization - Create external tab | 1017 // Continue with Initialization - Create external tab |
1018 CreateExternalTab(); | 1018 CreateExternalTab(); |
1019 } else { | 1019 } else { |
1020 // Send a notification to Chrome that we are ready to connect to the | 1020 // Send a notification to Chrome that we are ready to connect to the |
1021 // ExternalTab. | 1021 // ExternalTab. |
1022 IPC::SyncMessage* message = | 1022 IPC::SyncMessage* message = |
1023 new AutomationMsg_ConnectExternalTab(0, external_tab_cookie_, true, | 1023 new AutomationMsg_ConnectExternalTab(0, external_tab_cookie_, true, |
1024 m_hWnd, NULL, NULL, NULL); | 1024 m_hWnd, NULL, NULL, NULL); |
1025 automation_server_->SendAsAsync(message, | 1025 automation_server_->SendAsAsync(message, |
1026 new CreateExternalTabContext(this), | 1026 new CreateExternalTabContext(this), |
1027 this); | 1027 this); |
1028 DLOG(INFO) << __FUNCTION__ << ": sending CreateExternalTabComplete"; | 1028 DVLOG(1) << __FUNCTION__ << ": sending CreateExternalTabComplete"; |
1029 } | 1029 } |
1030 } | 1030 } |
1031 } else { | 1031 } else { |
1032 // Launch failed. Note, we cannot delete proxy here. | 1032 // Launch failed. Note, we cannot delete proxy here. |
1033 PostTask(FROM_HERE, NewRunnableMethod(this, | 1033 PostTask(FROM_HERE, NewRunnableMethod(this, |
1034 &ChromeFrameAutomationClient::InitializeComplete, result)); | 1034 &ChromeFrameAutomationClient::InitializeComplete, result)); |
1035 } | 1035 } |
1036 } | 1036 } |
1037 | 1037 |
1038 void ChromeFrameAutomationClient::AutomationServerDied() { | 1038 void ChromeFrameAutomationClient::AutomationServerDied() { |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1441 const URLRequestStatus& status) { | 1441 const URLRequestStatus& status) { |
1442 automation_server_->Send(new AutomationMsg_RequestEnd(0, tab_->handle(), | 1442 automation_server_->Send(new AutomationMsg_RequestEnd(0, tab_->handle(), |
1443 request_id, status)); | 1443 request_id, status)); |
1444 } | 1444 } |
1445 | 1445 |
1446 void ChromeFrameAutomationClient::OnCookiesRetrieved(bool success, | 1446 void ChromeFrameAutomationClient::OnCookiesRetrieved(bool success, |
1447 const GURL& url, const std::string& cookie_string, int cookie_id) { | 1447 const GURL& url, const std::string& cookie_string, int cookie_id) { |
1448 automation_server_->Send(new AutomationMsg_GetCookiesHostResponse(0, | 1448 automation_server_->Send(new AutomationMsg_GetCookiesHostResponse(0, |
1449 tab_->handle(), success, url, cookie_string, cookie_id)); | 1449 tab_->handle(), success, url, cookie_string, cookie_id)); |
1450 } | 1450 } |
OLD | NEW |