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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_EVENT_QUEUE_H_
6 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_EVENT_QUEUE_H_
7
8 #include <list>
9 #include <map>
10
11 #include "base/memory/scoped_ptr.h"
12 #include "base/values.h"
13
14 class AutomationEventObserver;
15 class AutomationJSONReply;
16
17 // AutomationEventQueue maintains a queue of unhandled automation events.
18 class AutomationEventQueue {
19 public:
20 AutomationEventQueue();
21 virtual ~AutomationEventQueue();
22
23 // AutomationEvent stores return data dictionay for a single event.
24 class AutomationEvent {
25 public:
26 AutomationEvent(int observer_id, DictionaryValue* event_value);
27 virtual ~AutomationEvent() {}
28
29 int GetId() const { return observer_id_; }
30 DictionaryValue* GetValue() { return event_value_.get(); }
31 DictionaryValue* ReleaseValue() { return event_value_.release(); }
32
33 private:
34 scoped_ptr<DictionaryValue> event_value_;
35 int observer_id_;
36 };
37
38 void GetNextEvent(AutomationJSONReply* reply,
39 int observer_id,
40 bool blocking);
41 void NotifyEvent(AutomationEvent* event);
42 void Clear();
43 bool IsEmpty();
44 AutomationEvent* PopEvent();
45 AutomationEvent* PopEvent(int observer_id);
46
47 int AddObserver(AutomationEventObserver* observer);
48 bool RemoveObserver(int observer_id);
49
50 private:
51 void ClearEvents();
52 void ClearObservers();
53 bool CheckReturnEvent();
54
55 std::list<AutomationEvent*> event_queue_;
56 std::map<int, AutomationEventObserver*> observers_;
57 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
58
59 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
60 int wait_observer_id_;
61
62 DISALLOW_COPY_AND_ASSIGN(AutomationEventQueue);
63 };
64
65 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_EVENT_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698