OLD | NEW |
---|---|
(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 AutomationProvider; | |
16 | |
17 namespace IPC { | |
18 class Message; | |
19 } | |
20 | |
21 // AutomationEventQueue maintains a queue of unhandled automation events. | |
22 class AutomationEventQueue { | |
Nirnimesh
2012/02/24 23:18:09
Should 'App' be added? or is this meant to be gene
craigdh
2012/02/27 22:43:38
Although the initial intention is to use the event
| |
23 public: | |
24 AutomationEventQueue(); | |
25 virtual ~AutomationEventQueue(); | |
26 | |
27 // AutomationEvent stores return data dictionay for a single event. | |
28 class AutomationEvent { | |
29 public: | |
30 AutomationEvent(int observer_id, DictionaryValue* event_value); | |
31 virtual ~AutomationEvent() {} | |
32 | |
33 void ReturnValue(AutomationProvider* automation, | |
34 IPC::Message* reply_message); | |
35 int GetId() const { return observer_id_; } | |
36 DictionaryValue* ReleaseValue() { return event_value_.release(); } | |
37 | |
38 private: | |
39 scoped_ptr<DictionaryValue> event_value_; | |
40 int observer_id_; | |
41 }; | |
42 | |
43 void GetEvent(AutomationProvider* automation, | |
44 IPC::Message* reply_message, | |
45 int observer_id, | |
46 bool blocking); | |
47 void NotifyEvent(AutomationEvent* event); | |
48 void Clear(); | |
49 bool IsEmpty(); | |
50 AutomationEvent* PopEvent(); | |
51 AutomationEvent* PopEvent(int observer_id); | |
52 | |
53 int AddObserver(AutomationEventObserver* observer); | |
54 void RemoveObserver(int observer_id); | |
55 void ClearObservers(); | |
56 | |
57 private: | |
58 bool CheckReturnEvent(); | |
59 void SetWait(AutomationProvider* automation, | |
60 IPC::Message* reply_message, | |
61 int observer_id); | |
62 void ClearWait(); | |
63 | |
64 std::list<AutomationEvent*> event_queue_; | |
65 std::map<int, AutomationEventObserver*> observers_; | |
66 int observer_id_count_; | |
67 | |
68 AutomationProvider* wait_automation_; | |
69 scoped_ptr<IPC::Message> wait_reply_message_; | |
70 int wait_observer_id_; | |
71 | |
72 DISALLOW_COPY_AND_ASSIGN(AutomationEventQueue); | |
73 }; | |
74 | |
75 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_EVENT_QUEUE_H_ | |
OLD | NEW |