I discovered that MessageLoop::DeleteSoon does not delete the object if the message loop is destroyed before it has a chance to run. This is because the MessageLoop destructor does not run the pending tasks, just pops them off the work queue.
Although the comment near the destructor seems to suggest that DeleteSoon might be run: "Clean up any unprocessed tasks, but take care: deleting a task could result in the addition of more tasks (e.g., via DeleteSoon)"
I want to ensure that an object gets deleted when MessageLoop is destroyed. One of the ways I can think of is:
void DoNothing(const void* obj) {}
message_loop.PostTask(FROM_HERE, base::Bind(&DoNothing, base::Owned(obj));
Is there another way other than manually running the message loop? Or should DeleteSoon ensure that objects be destroyed?