blob: b815bb1d9ea1021043f478f908d4155b3b3f688e [file] [log] [blame]
[email protected]c31af70db22011-08-18 23:13:011// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]d4799a32010-09-28 22:54:582// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "base/message_loop_proxy.h"
6
[email protected]c31af70db22011-08-18 23:13:017#include "base/bind.h"
[email protected]28376542011-10-14 17:30:378#include "base/compiler_specific.h"
[email protected]c62dd9d2011-09-21 18:05:419#include "base/location.h"
[email protected]28376542011-10-14 17:30:3710#include "base/threading/post_task_and_reply_impl.h"
[email protected]c31af70db22011-08-18 23:13:0111
[email protected]d4799a32010-09-28 22:54:5812namespace base {
13
[email protected]c31af70db22011-08-18 23:13:0114namespace {
15
[email protected]28376542011-10-14 17:30:3716class PostTaskAndReplyMessageLoopProxy : public internal::PostTaskAndReplyImpl {
[email protected]c31af70db22011-08-18 23:13:0117 public:
[email protected]28376542011-10-14 17:30:3718 PostTaskAndReplyMessageLoopProxy(MessageLoopProxy* destination)
19 : destination_(destination) {
[email protected]c31af70db22011-08-18 23:13:0120 }
21
22 private:
[email protected]28376542011-10-14 17:30:3723 virtual bool PostTask(const tracked_objects::Location& from_here,
24 const base::Closure& task) OVERRIDE {
25 return destination_->PostTask(from_here, task);
[email protected]c31af70db22011-08-18 23:13:0126 }
27
[email protected]28376542011-10-14 17:30:3728 // Non-owning.
29 MessageLoopProxy* destination_;
[email protected]c31af70db22011-08-18 23:13:0130};
31
32} // namespace
33
[email protected]d4799a32010-09-28 22:54:5834MessageLoopProxy::MessageLoopProxy() {
35}
36
37MessageLoopProxy::~MessageLoopProxy() {
38}
39
[email protected]c31af70db22011-08-18 23:13:0140bool MessageLoopProxy::PostTaskAndReply(
41 const tracked_objects::Location& from_here,
42 const Closure& task,
43 const Closure& reply) {
[email protected]28376542011-10-14 17:30:3744 return PostTaskAndReplyMessageLoopProxy(this).PostTaskAndReply(
45 from_here, task, reply);
[email protected]c31af70db22011-08-18 23:13:0146}
47
[email protected]00ed48f2010-10-22 22:19:2448void MessageLoopProxy::OnDestruct() const {
[email protected]d4799a32010-09-28 22:54:5849 delete this;
50}
51
[email protected]b1d183282011-12-30 04:32:5852bool MessageLoopProxy::DeleteSoonInternal(
53 const tracked_objects::Location& from_here,
54 void(*deleter)(const void*),
55 const void* object) {
56 return PostNonNestableTask(from_here, base::Bind(deleter, object));
57}
58
[email protected]c29985e2011-12-30 06:46:3059bool MessageLoopProxy::ReleaseSoonInternal(
60 const tracked_objects::Location& from_here,
61 void(*releaser)(const void*),
62 const void* object) {
63 return PostNonNestableTask(from_here, base::Bind(releaser, object));
64}
65
[email protected]d4799a32010-09-28 22:54:5866} // namespace base