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

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 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 AutomationProvider;
16
17 namespace IPC {
18 class Message;
19 }
20
21 // AutomationEventQueue maintains a queue of unhandled automation events.
22 class AutomationEventQueue {
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698