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

Unified Diff: chrome/browser/automation/automation_event_queue.h

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: Addressed Nirnimesh's second round of comments. 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/automation_event_queue.h
diff --git a/chrome/browser/automation/automation_event_queue.h b/chrome/browser/automation/automation_event_queue.h
new file mode 100644
index 0000000000000000000000000000000000000000..32028accd78457c4f80fbc4495e6a5416b9cccd9
--- /dev/null
+++ b/chrome/browser/automation/automation_event_queue.h
@@ -0,0 +1,65 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_EVENT_QUEUE_H_
+#define CHROME_BROWSER_AUTOMATION_AUTOMATION_EVENT_QUEUE_H_
+
+#include <list>
+#include <map>
+
+#include "base/memory/scoped_ptr.h"
+#include "base/values.h"
+
+class AutomationEventObserver;
+class AutomationJSONReply;
+
+// AutomationEventQueue maintains a queue of unhandled automation events.
+class AutomationEventQueue {
+ public:
+ AutomationEventQueue();
+ virtual ~AutomationEventQueue();
+
+ // AutomationEvent stores return data dictionay for a single event.
+ class AutomationEvent {
+ public:
+ AutomationEvent(int observer_id, DictionaryValue* event_value);
+ virtual ~AutomationEvent() {}
+
+ int GetId() const { return observer_id_; }
+ DictionaryValue* GetValue() { return event_value_.get(); }
+ DictionaryValue* ReleaseValue() { return event_value_.release(); }
+
+ private:
+ scoped_ptr<DictionaryValue> event_value_;
+ int observer_id_;
+ };
+
+ void GetNextEvent(AutomationJSONReply* reply,
+ int observer_id,
+ bool blocking);
+ void NotifyEvent(AutomationEvent* event);
+ void Clear();
+ bool IsEmpty();
+ AutomationEvent* PopEvent();
+ AutomationEvent* PopEvent(int observer_id);
+
+ int AddObserver(AutomationEventObserver* observer);
+ bool RemoveObserver(int observer_id);
+
+ private:
+ void ClearEvents();
+ void ClearObservers();
+ bool CheckReturnEvent();
+
+ std::list<AutomationEvent*> event_queue_;
+ std::map<int, AutomationEventObserver*> observers_;
+ int observer_id_count_;
Nirnimesh 2012/02/29 03:22:08 why is this necessary? It's the same as observers_
craigdh 2012/02/29 22:53:43 Not exactly, it's only the same until observers ar
+
+ scoped_ptr<AutomationJSONReply> wait_automation_reply_;
Nirnimesh 2012/02/29 03:22:08 What is this for? Add comments
craigdh 2012/02/29 22:53:43 If there is not a matching event already waiting i
+ int wait_observer_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(AutomationEventQueue);
+};
+
+#endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_EVENT_QUEUE_H_

Powered by Google App Engine
This is Rietveld 408576698