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

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

Issue 9372120: Implementation of AutomationEventQueue and associated framework to support generic non-blocking aut… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Made CompareEventId predicate class private to AutomationEventQueue. 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/testing_automation_provider.cc
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index afc251a4d660590022094a732d548c3ad5f630a6..9c92a0040943399e1086dbbeb5c7627e3420275d 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -2316,6 +2316,14 @@ void TestingAutomationProvider::SendJSONRequest(int handle,
handler_map["SetPrefs"] = &TestingAutomationProvider::SetPrefs;
handler_map["ExecuteJavascript"] =
&TestingAutomationProvider::ExecuteJavascriptJSON;
+ handler_map["AddDomRaisedEventObserver"] =
Nirnimesh 2012/03/01 10:34:12 See corresponding comment in pyauto.py
+ &TestingAutomationProvider::AddDomRaisedEventObserver;
+ handler_map["RemoveEventObserver"] =
+ &TestingAutomationProvider::RemoveEventObserver;
+ handler_map["GetNextEvent"] =
+ &TestingAutomationProvider::GetNextEvent;
+ handler_map["ClearEventQueue"] =
+ &TestingAutomationProvider::ClearEventQueue;
handler_map["ExecuteJavascriptInRenderView"] =
&TestingAutomationProvider::ExecuteJavascriptInRenderView;
handler_map["GoForward"] =
@@ -6443,6 +6451,81 @@ void TestingAutomationProvider::ExecuteJavascriptInRenderView(
rvh);
}
+void TestingAutomationProvider::AddDomRaisedEventObserver(
Nirnimesh 2012/03/01 10:34:12 you pass a lot of other args from the python side,
craigdh 2012/03/01 21:34:18 Those are left over from some point in the design
+ DictionaryValue* args,
+ IPC::Message* reply_message) {
+ if (SendErrorIfModalDialogActive(this, reply_message))
+ return;
+
+ AutomationJSONReply reply(this, reply_message);
+ std::string event_name;
+ if (!args->GetString("event_name", &event_name)) {
+ reply.SendError("'event_name' missing or invalid");
+ return;
+ }
+
+ if (!automation_event_queue_.get())
+ automation_event_queue_.reset(new AutomationEventQueue);
+
+ int observer_id = automation_event_queue_->AddObserver(
+ new DomRaisedEventObserver(automation_event_queue_.get(), event_name));
+ scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
+ return_value->SetInteger("observer_id", observer_id);
+ reply.SendSuccess(return_value.get());
+}
+
+void TestingAutomationProvider::RemoveEventObserver(
+ DictionaryValue* args,
+ IPC::Message* reply_message) {
+ AutomationJSONReply reply(this, reply_message);
+ int observer_id;
+ if (!args->GetInteger("observer_id", &observer_id)) {
+ reply.SendError("'observer_id' missing or invalid");
+ return;
+ }
+ if (automation_event_queue_->RemoveObserver(observer_id)) {
+ reply.SendSuccess(NULL);
+ return;
+ }
+ if (!automation_event_queue_.get()) {
Nirnimesh 2012/03/01 10:34:12 The if in line 6486 implies that this if will neve
craigdh 2012/03/01 21:34:18 Done.
+ reply.SendError("No observers have been created.");
+ return;
+ }
+ reply.SendError("Invalid observer id.");
+}
+
+void TestingAutomationProvider::ClearEventQueue(
+ DictionaryValue* args,
+ IPC::Message* reply_message) {
+ AutomationJSONReply reply(this, reply_message);
Nirnimesh 2012/03/01 10:34:12 remove
craigdh 2012/03/01 21:34:18 Done.
+ if (automation_event_queue_.get())
+ automation_event_queue_->Clear();
Nirnimesh 2012/03/01 10:34:12 Also free up automation_event_queue_?
craigdh 2012/03/01 21:34:18 Changed to just automation_event_queue_.reset() wh
+ reply.SendSuccess(NULL);
Nirnimesh 2012/03/01 10:34:12 AutomationJSONReply reply(this, reply_message).Sen
craigdh 2012/03/01 21:34:18 Done.
+}
+
+void TestingAutomationProvider::GetNextEvent(
+ DictionaryValue* args,
+ IPC::Message* reply_message) {
+ scoped_ptr<AutomationJSONReply> reply(
+ new AutomationJSONReply(this, reply_message));
+ int observer_id;
+ bool blocking;
+ if (!args->GetInteger("observer_id", &observer_id)) {
+ reply->SendError("'observer_id' missing or invalid");
+ return;
+ }
+ if (!args->GetBoolean("blocking", &blocking)) {
+ reply->SendError("'blocking' missing or invalid");
+ return;
+ }
+ if (!automation_event_queue_.get()) {
+ reply->SendError("No observers have been created.");
Nirnimesh 2012/03/01 10:34:12 Add: "Did you call AddDomRaisedEventObserver?"
craigdh 2012/03/01 21:34:18 Done. Added a comment to the same effect but a lit
+ return;
+ }
+
+ automation_event_queue_->GetNextEvent(reply.release(), observer_id, blocking);
Nirnimesh 2012/03/01 10:34:12 AutomationEventQueue::GetNextEvent takes Automatio
craigdh 2012/03/01 21:34:18 When a matching event is added to the queue and th
+}
+
void TestingAutomationProvider::GoForward(
DictionaryValue* args,
IPC::Message* reply_message) {

Powered by Google App Engine
This is Rietveld 408576698