summaryrefslogtreecommitdiffstats
path: root/content/child/thread_safe_sender.h
blob: 9684785e42191c3fa5da19c9a92fe37f40da18fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_CHILD_THREAD_SAFE_SENDER_H_
#define CONTENT_CHILD_THREAD_SAFE_SENDER_H_

#include "base/memory/ref_counted.h"
#include "content/common/content_export.h"
#include "ipc/ipc_sender.h"

namespace base {
class SingleThreadTaskRunner;
}

namespace IPC {
class SyncMessageFilter;
}

namespace content {
class ChildThreadImpl;

// The class of Sender returned by ChildThreadImpl::thread_safe_sender().
class CONTENT_EXPORT ThreadSafeSender
    : public IPC::Sender,
      public base::RefCountedThreadSafe<ThreadSafeSender> {
 public:
  bool Send(IPC::Message* msg) override;

 protected:
  ThreadSafeSender(
      const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner,
      const scoped_refptr<IPC::SyncMessageFilter>& sync_filter);
  ~ThreadSafeSender() override;

 private:
  friend class ChildThreadImpl;  // for construction
  friend class IndexedDBDispatcherTest;
  friend class WebIDBCursorImplTest;
  friend class base::RefCountedThreadSafe<ThreadSafeSender>;

  scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
  scoped_refptr<IPC::SyncMessageFilter> sync_filter_;

  DISALLOW_COPY_AND_ASSIGN(ThreadSafeSender);
};

}  // namespace content

#endif  // CONTENT_CHILD_THREAD_SAFE_SENDER_H_