MessagePumpForUIEfl::MessagePumpForUIEfl()
: pipe_(ecore_pipe_add(&PipeCallback, this))
, schedule_delayed_work_timer_(NULL)
- , delegate_(base::MessageLoopForUI::current())
- , run_loop_(new RunLoop())
+ , run_loop_(NULL)
, work_scheduled_(false) {
- // Since the RunLoop was just created above, BeforeRun should be guaranteed to
- // return true (it only returns false if the RunLoop has been Quit already).
- bool result = run_loop_->BeforeRun();
- DCHECK(result);
}
MessagePumpForUIEfl::~MessagePumpForUIEfl() {
ecore_pipe_del(pipe_);
if (schedule_delayed_work_timer_)
ecore_timer_del(schedule_delayed_work_timer_);
- DCHECK(run_loop_->running());
- run_loop_->AfterRun();
- delete run_loop_;
- run_loop_ = NULL;
+ if (run_loop_) {
+ DCHECK(run_loop_->running());
+ run_loop_->AfterRun();
+ delete run_loop_;
+ run_loop_ = NULL;
+ }
pipe_ = NULL;
schedule_delayed_work_timer_ = NULL;
}
work_scheduled_ = false;
}
- bool more_work_is_plausible = delegate_->DoWork();
+ Delegate* delegate = base::MessageLoopForUI::current();
+ if (!run_loop_) {
+ run_loop_ = new RunLoop();
+ bool result = run_loop_->BeforeRun();
+ DCHECK(result);
+ }
+
+ bool more_work_is_plausible = delegate->DoWork();
base::TimeTicks delayed_work_time;
- more_work_is_plausible |= delegate_->DoDelayedWork(&delayed_work_time);
+ more_work_is_plausible |= delegate->DoDelayedWork(&delayed_work_time);
if (more_work_is_plausible) {
ScheduleWork();
return;
}
- more_work_is_plausible |= delegate_->DoIdleWork();
+ more_work_is_plausible |= delegate->DoIdleWork();
if (more_work_is_plausible) {
ScheduleWork();
return;
void MessagePumpForUIEfl::DoDelayedWork() {
base::TimeTicks next_delayed_work_time;
- delegate_->DoDelayedWork(&next_delayed_work_time);
+ base::MessageLoopForUI::current()->DoDelayedWork(&next_delayed_work_time);
if (!next_delayed_work_time.is_null())
ScheduleDelayedWork(next_delayed_work_time);