Also include selected state when returning AXValue.
[chromium-blink-merge.git] / chrome_frame / task_marshaller.h
blob75d945e0c597c76ba5110a751b41867f9b8ea6fa
1 // Copyright (c) 2010 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.
5 #ifndef CHROME_FRAME_TASK_MARSHALLER_H_
6 #define CHROME_FRAME_TASK_MARSHALLER_H_
7 #pragma once
9 #include <windows.h>
10 #include <deque>
11 #include <queue>
13 #include "base/synchronization/lock.h"
14 #include "base/threading/non_thread_safe.h"
15 #include "base/time.h"
17 class Task;
18 namespace tracked_objects {
19 class Location;
22 // TaskMarshallerThroughMessageQueue is similar to base::MessageLoopForUI
23 // in cases where we do not control the thread lifetime and message retrieval
24 // and dispatching. It uses a HWND to ::PostMessage to it as a signal that
25 // the task queue is not empty.
26 class TaskMarshallerThroughMessageQueue : public base::NonThreadSafe {
27 public:
28 TaskMarshallerThroughMessageQueue();
29 ~TaskMarshallerThroughMessageQueue();
31 void SetWindow(HWND wnd, UINT msg) {
32 wnd_ = wnd;
33 msg_ = msg;
36 virtual void PostTask(const tracked_objects::Location& from_here,
37 Task* task);
38 virtual void PostDelayedTask(const tracked_objects::Location& source,
39 Task* task,
40 base::TimeDelta& delay);
41 // Called by the owner of the HWND.
42 BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
43 LRESULT& lResult, DWORD dwMsgMapID = 0);
44 private:
45 void DeleteAll();
46 inline Task* PopTask();
47 inline void ExecuteQueuedTasks();
48 void ExecuteDelayedTasks();
49 void RunTask(Task* task);
51 struct DelayedTask {
52 DelayedTask(Task* task, base::Time at) : run_at(at), task(task), seq(0) {}
53 base::Time run_at;
54 Task* task;
55 int seq;
56 // To support sorting based on time in priority_queue.
57 bool operator<(const DelayedTask& other) const;
60 std::priority_queue<DelayedTask> delayed_tasks_;
61 std::queue<Task*> pending_tasks_;
62 base::Lock lock_;
63 HWND wnd_;
64 UINT msg_;
65 int invoke_task_;
68 #endif // CHROME_FRAME_TASK_MARSHALLER_H_