OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_COMMON_CHILD_PROCESS_HOST_IMPL_H_ | 5 #ifndef CONTENT_COMMON_CHILD_PROCESS_HOST_IMPL_H_ |
6 #define CONTENT_COMMON_CHILD_PROCESS_HOST_IMPL_H_ | 6 #define CONTENT_COMMON_CHILD_PROCESS_HOST_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/shared_memory.h" | 15 #include "base/memory/shared_memory.h" |
16 #include "base/memory/singleton.h" | 16 #include "base/memory/singleton.h" |
17 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
18 #include "content/public/common/child_process_host.h" | 18 #include "content/public/common/child_process_host.h" |
19 #include "ipc/ipc_listener.h" | 19 #include "ipc/ipc_listener.h" |
20 | 20 |
21 namespace base { | 21 namespace base { |
22 class FilePath; | 22 class FilePath; |
23 } | 23 } |
24 | 24 |
25 namespace gfx { | 25 namespace gfx { |
26 struct GpuMemoryBufferHandle; | 26 struct GpuMemoryBufferHandle; |
27 } | 27 } |
28 | 28 |
| 29 namespace IPC { |
| 30 class MessageFilter; |
| 31 } |
| 32 |
29 namespace content { | 33 namespace content { |
30 class ChildProcessHostDelegate; | 34 class ChildProcessHostDelegate; |
31 | 35 |
32 // Provides common functionality for hosting a child process and processing IPC | 36 // Provides common functionality for hosting a child process and processing IPC |
33 // messages between the host and the child process. Users are responsible | 37 // messages between the host and the child process. Users are responsible |
34 // for the actual launching and terminating of the child processes. | 38 // for the actual launching and terminating of the child processes. |
35 class CONTENT_EXPORT ChildProcessHostImpl : public ChildProcessHost, | 39 class CONTENT_EXPORT ChildProcessHostImpl : public ChildProcessHost, |
36 public IPC::Listener { | 40 public IPC::Listener { |
37 public: | 41 public: |
38 virtual ~ChildProcessHostImpl(); | 42 virtual ~ChildProcessHostImpl(); |
(...skipping 12 matching lines...) Expand all Loading... |
51 // but normally this will be used on the IO thread. | 55 // but normally this will be used on the IO thread. |
52 // | 56 // |
53 // This will never return ChildProcessHost::kInvalidUniqueID. | 57 // This will never return ChildProcessHost::kInvalidUniqueID. |
54 static int GenerateChildProcessUniqueId(); | 58 static int GenerateChildProcessUniqueId(); |
55 | 59 |
56 // ChildProcessHost implementation | 60 // ChildProcessHost implementation |
57 virtual bool Send(IPC::Message* message) OVERRIDE; | 61 virtual bool Send(IPC::Message* message) OVERRIDE; |
58 virtual void ForceShutdown() OVERRIDE; | 62 virtual void ForceShutdown() OVERRIDE; |
59 virtual std::string CreateChannel() OVERRIDE; | 63 virtual std::string CreateChannel() OVERRIDE; |
60 virtual bool IsChannelOpening() OVERRIDE; | 64 virtual bool IsChannelOpening() OVERRIDE; |
61 virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter) OVERRIDE; | 65 virtual void AddFilter(IPC::MessageFilter* filter) OVERRIDE; |
62 #if defined(OS_POSIX) | 66 #if defined(OS_POSIX) |
63 virtual int TakeClientFileDescriptor() OVERRIDE; | 67 virtual int TakeClientFileDescriptor() OVERRIDE; |
64 #endif | 68 #endif |
65 | 69 |
66 private: | 70 private: |
67 friend class ChildProcessHost; | 71 friend class ChildProcessHost; |
68 | 72 |
69 explicit ChildProcessHostImpl(ChildProcessHostDelegate* delegate); | 73 explicit ChildProcessHostImpl(ChildProcessHostDelegate* delegate); |
70 | 74 |
71 // IPC::Listener methods: | 75 // IPC::Listener methods: |
(...skipping 12 matching lines...) Expand all Loading... |
84 | 88 |
85 ChildProcessHostDelegate* delegate_; | 89 ChildProcessHostDelegate* delegate_; |
86 base::ProcessHandle peer_handle_; | 90 base::ProcessHandle peer_handle_; |
87 bool opening_channel_; // True while we're waiting the channel to be opened. | 91 bool opening_channel_; // True while we're waiting the channel to be opened. |
88 scoped_ptr<IPC::Channel> channel_; | 92 scoped_ptr<IPC::Channel> channel_; |
89 std::string channel_id_; | 93 std::string channel_id_; |
90 | 94 |
91 // Holds all the IPC message filters. Since this object lives on the IO | 95 // Holds all the IPC message filters. Since this object lives on the IO |
92 // thread, we don't have a IPC::ChannelProxy and so we manage filters | 96 // thread, we don't have a IPC::ChannelProxy and so we manage filters |
93 // manually. | 97 // manually. |
94 std::vector<scoped_refptr<IPC::ChannelProxy::MessageFilter> > filters_; | 98 std::vector<scoped_refptr<IPC::MessageFilter> > filters_; |
95 | 99 |
96 DISALLOW_COPY_AND_ASSIGN(ChildProcessHostImpl); | 100 DISALLOW_COPY_AND_ASSIGN(ChildProcessHostImpl); |
97 }; | 101 }; |
98 | 102 |
99 } // namespace content | 103 } // namespace content |
100 | 104 |
101 #endif // CONTENT_COMMON_CHILD_PROCESS_HOST_IMPL_H_ | 105 #endif // CONTENT_COMMON_CHILD_PROCESS_HOST_IMPL_H_ |
OLD | NEW |