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

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

Issue 5755003: Fix pyauto flakiness by waiting for notification that the renderer process' (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 10 years 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/testing_automation_provider.cc
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index 96c52ec43eeec38178b137c5f7787069537dd520..31c277a79e6fd65530eb3801153cfc04ed039973 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -10,6 +10,8 @@
#include "base/json/json_writer.h"
#include "base/json/string_escape.h"
#include "base/path_service.h"
+#include "base/process.h"
+#include "base/process_util.h"
#include "base/stringprintf.h"
#include "base/thread_restrictions.h"
#include "base/time.h"
@@ -2132,6 +2134,9 @@ void TestingAutomationProvider::SendJSONRequest(int handle,
handler_map["RestoreAllNTPMostVisitedThumbnails"] =
&TestingAutomationProvider::RestoreAllNTPMostVisitedThumbnails;
+ handler_map["KillRendererProcess"] =
+ &TestingAutomationProvider::KillRendererProcess;
+
if (handler_map.find(std::string(command)) != handler_map.end()) {
(this->*handler_map[command])(browser, dict_value, reply_message);
} else {
@@ -4377,6 +4382,27 @@ void TestingAutomationProvider::RestoreAllNTPMostVisitedThumbnails(
reply.SendSuccess(NULL);
}
+void TestingAutomationProvider::KillRendererProcess(
+ Browser* browser,
+ DictionaryValue* args,
+ IPC::Message* reply_message) {
+ int pid;
+ if (!args->GetInteger("pid", &pid)) {
+ AutomationJSONReply(this, reply_message).
+ SendError("'pid' key missing or invalid.");
+ return;
+ }
+ base::ProcessHandle process;
+ if (!base::OpenProcessHandle(static_cast<base::ProcessId>(pid), &process)) {
+ AutomationJSONReply(this, reply_message).SendError(base::StringPrintf(
+ "Failed to open process handle for pid %d", pid));
+ return;
+ }
+ new RendererProcessClosedObserver(this, reply_message);
+ base::KillProcess(process, 0, false);
+ base::CloseProcessHandle(process);
+}
+
void TestingAutomationProvider::WaitForTabCountToBecome(
int browser_handle,
int target_tab_count,

Powered by Google App Engine
This is Rietveld 408576698