gpu: Add memory tracing of GPU transfer buffers.
[chromium-blink-merge.git] / content / common / mojo / channel_init.h
blob2660a7bcbf285a155385f71bbad0e90b4b694dc2
1 // Copyright 2015 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 CONTENT_COMMON_MOJO_CHANNEL_INIT_H_
6 #define CONTENT_COMMON_MOJO_CHANNEL_INIT_H_
8 #include "base/files/file.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h"
11 #include "content/common/content_export.h"
12 #include "ipc/mojo/scoped_ipc_support.h"
13 #include "third_party/mojo/src/mojo/edk/embedder/channel_info_forward.h"
14 #include "third_party/mojo/src/mojo/public/cpp/system/message_pipe.h"
16 namespace base {
17 class TaskRunner;
20 namespace content {
22 // ChannelInit handles creation and destruction of the Mojo channel. It is not
23 // thread-safe, but may be used on any single thread with a MessageLoop.
24 class CONTENT_EXPORT ChannelInit {
25 public:
26 ChannelInit();
27 ~ChannelInit();
29 // Initializes the channel. This takes ownership of |file|. Returns the
30 // primordial MessagePipe for the channel.
31 mojo::ScopedMessagePipeHandle Init(
32 base::PlatformFile file,
33 scoped_refptr<base::TaskRunner> io_thread_task_runner);
35 // Notifies the channel that we (hence it) will soon be destroyed.
36 void WillDestroySoon();
38 // Shuts down the channel. Must be called from the IO thread.
39 void ShutdownOnIOThread();
41 private:
42 // Invoked on the thread on which this object lives once the channel has been
43 // established. This is a static method that takes a weak pointer to self,
44 // since we want to destroy the channel if we were destroyed first.
45 static void OnCreatedChannel(
46 base::WeakPtr<ChannelInit> self,
47 scoped_ptr<IPC::ScopedIPCSupport> ipc_support,
48 mojo::embedder::ChannelInfo* channel);
50 // If non-null the channel has been established.
51 mojo::embedder::ChannelInfo* channel_info_;
53 scoped_ptr<IPC::ScopedIPCSupport> ipc_support_;
54 base::WeakPtrFactory<ChannelInit> weak_factory_;
56 DISALLOW_COPY_AND_ASSIGN(ChannelInit);
59 } // namespace content
61 #endif // CONTENT_COMMON_MOJO_CHANNEL_INIT_H_