Remove const WebMediaPlayer::didLoadingProgress() implementations.
[chromium-blink-merge.git] / content / common / child_process_host_impl.h
blob4ac660d185bf34aead0ae1473033464819d927d1
1 // Copyright (c) 2012 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_CHILD_PROCESS_HOST_IMPL_H_
6 #define CONTENT_COMMON_CHILD_PROCESS_HOST_IMPL_H_
8 #include <string>
9 #include <vector>
11 #include "build/build_config.h"
13 #include "base/basictypes.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/shared_memory.h"
16 #include "base/memory/singleton.h"
17 #include "base/strings/string16.h"
18 #include "content/public/common/child_process_host.h"
19 #include "ipc/ipc_listener.h"
21 namespace base {
22 class FilePath;
25 namespace gfx {
26 struct GpuMemoryBufferHandle;
29 namespace IPC {
30 class MessageFilter;
33 namespace content {
34 class ChildProcessHostDelegate;
36 // Provides common functionality for hosting a child process and processing IPC
37 // messages between the host and the child process. Users are responsible
38 // for the actual launching and terminating of the child processes.
39 class CONTENT_EXPORT ChildProcessHostImpl : public ChildProcessHost,
40 public IPC::Listener {
41 public:
42 virtual ~ChildProcessHostImpl();
44 // Public and static for reuse by RenderMessageFilter.
45 static void AllocateSharedMemory(
46 size_t buffer_size, base::ProcessHandle child_process,
47 base::SharedMemoryHandle* handle);
49 // Returns a unique ID to identify a child process. On construction, this
50 // function will be used to generate the id_, but it is also used to generate
51 // IDs for the RenderProcessHost, which doesn't inherit from us, and whose IDs
52 // must be unique for all child processes.
54 // This function is threadsafe since RenderProcessHost is on the UI thread,
55 // but normally this will be used on the IO thread.
57 // This will never return ChildProcessHost::kInvalidUniqueID.
58 static int GenerateChildProcessUniqueId();
60 // ChildProcessHost implementation
61 virtual bool Send(IPC::Message* message) OVERRIDE;
62 virtual void ForceShutdown() OVERRIDE;
63 virtual std::string CreateChannel() OVERRIDE;
64 virtual bool IsChannelOpening() OVERRIDE;
65 virtual void AddFilter(IPC::MessageFilter* filter) OVERRIDE;
66 #if defined(OS_POSIX)
67 virtual int TakeClientFileDescriptor() OVERRIDE;
68 #endif
70 private:
71 friend class ChildProcessHost;
73 explicit ChildProcessHostImpl(ChildProcessHostDelegate* delegate);
75 // IPC::Listener methods:
76 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
77 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
78 virtual void OnChannelError() OVERRIDE;
80 // Message handlers:
81 void OnShutdownRequest();
82 void OnAllocateSharedMemory(uint32 buffer_size,
83 base::SharedMemoryHandle* handle);
84 void OnAllocateGpuMemoryBuffer(uint32 width,
85 uint32 height,
86 uint32 internalformat,
87 uint32 usage,
88 gfx::GpuMemoryBufferHandle* handle);
90 ChildProcessHostDelegate* delegate_;
91 base::ProcessHandle peer_handle_;
92 bool opening_channel_; // True while we're waiting the channel to be opened.
93 scoped_ptr<IPC::Channel> channel_;
94 std::string channel_id_;
96 // Holds all the IPC message filters. Since this object lives on the IO
97 // thread, we don't have a IPC::ChannelProxy and so we manage filters
98 // manually.
99 std::vector<scoped_refptr<IPC::MessageFilter> > filters_;
101 DISALLOW_COPY_AND_ASSIGN(ChildProcessHostImpl);
104 } // namespace content
106 #endif // CONTENT_COMMON_CHILD_PROCESS_HOST_IMPL_H_