Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_COMMON_CHILD_PROCESS_HOST_H_ | 5 #ifndef CHROME_COMMON_CHILD_PROCESS_HOST_H_ |
| 6 #define CHROME_COMMON_CHILD_PROCESS_HOST_H_ | 6 #define CHROME_COMMON_CHILD_PROCESS_HOST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 // On failure, returns an empty FilePath. | 51 // On failure, returns an empty FilePath. |
| 52 static FilePath GetChildPath(bool allow_self); | 52 static FilePath GetChildPath(bool allow_self); |
| 53 | 53 |
| 54 #if defined(OS_WIN) | 54 #if defined(OS_WIN) |
| 55 // See comments in the cc file. This is a common hack needed for a process | 55 // See comments in the cc file. This is a common hack needed for a process |
| 56 // hosting a sandboxed child process. Hence it lives in this file. | 56 // hosting a sandboxed child process. Hence it lives in this file. |
| 57 static void PreCacheFont(LOGFONT font); | 57 static void PreCacheFont(LOGFONT font); |
| 58 #endif // defined(OS_WIN) | 58 #endif // defined(OS_WIN) |
| 59 | 59 |
| 60 // IPC::Message::Sender implementation. | 60 // IPC::Message::Sender implementation. |
| 61 bool Send(IPC::Message* message); | 61 virtual bool Send(IPC::Message* message); |
| 62 | 62 |
| 63 protected: | 63 protected: |
| 64 ChildProcessHost(); | 64 ChildProcessHost(); |
| 65 | 65 |
| 66 // Adds an IPC message filter. A reference will be kept to the filter. | 66 // Adds an IPC message filter. A reference will be kept to the filter. |
| 67 void AddFilter(IPC::ChannelProxy::MessageFilter* filter); | 67 void AddFilter(IPC::ChannelProxy::MessageFilter* filter); |
| 68 | 68 |
| 69 // Derived classes return true if it's ok to shut down the child process. | 69 // Derived classes return true if it's ok to shut down the child process. |
| 70 virtual bool CanShutdown() = 0; | 70 virtual bool CanShutdown() = 0; |
| 71 | 71 |
| 72 // Send the shutdown message to the child process. | 72 // Send the shutdown message to the child process. |
| 73 // Does not check if CanShutdown is true. | 73 // Does not check if CanShutdown is true. |
| 74 virtual void ForceShutdown(); | 74 virtual void ForceShutdown(); |
| 75 | 75 |
| 76 // Creates the IPC channel. Returns true iff it succeeded. | 76 // Creates the IPC channel. Returns true iff it succeeded. |
| 77 virtual bool CreateChannel(); | 77 virtual bool CreateChannel(); |
| 78 | 78 |
| 79 // Notifies us that an instance has been created on this child process. | 79 // Notifies us that an instance has been created on this child process. |
| 80 virtual void InstanceCreated(); | 80 virtual void InstanceCreated(); |
| 81 | 81 |
| 82 // IPC::Channel::Listener implementation: | 82 // IPC::Channel::Listener implementation: |
| 83 virtual bool OnMessageReceived(const IPC::Message& msg) { return false; } | 83 virtual bool OnMessageReceived(const IPC::Message& msg); |
|
Nico
2011/01/27 03:55:17
these two. i will stop repeating this question.
| |
| 84 virtual void OnChannelConnected(int32 peer_pid) { } | 84 virtual void OnChannelConnected(int32 peer_pid); |
| 85 virtual void OnChannelError() { } | 85 virtual void OnChannelError(); |
| 86 | 86 |
| 87 bool opening_channel() { return opening_channel_; } | 87 bool opening_channel() { return opening_channel_; } |
| 88 const std::string& channel_id() { return channel_id_; } | 88 const std::string& channel_id() { return channel_id_; } |
| 89 IPC::Channel* channel() { return channel_.get(); } | 89 IPC::Channel* channel() { return channel_.get(); } |
| 90 | 90 |
| 91 // Called when the child process goes away. | 91 // Called when the child process goes away. |
| 92 virtual void OnChildDied(); | 92 virtual void OnChildDied(); |
| 93 // Notifies the derived class that we told the child process to kill itself. | 93 // Notifies the derived class that we told the child process to kill itself. |
| 94 virtual void ShutdownStarted() { } | 94 virtual void ShutdownStarted(); |
| 95 // Subclasses can implement specific notification methods. | 95 // Subclasses can implement specific notification methods. |
| 96 virtual void Notify(NotificationType type) { } | 96 virtual void Notify(NotificationType type); |
| 97 | 97 |
| 98 private: | 98 private: |
| 99 // By using an internal class as the IPC::Channel::Listener, we can intercept | 99 // By using an internal class as the IPC::Channel::Listener, we can intercept |
| 100 // OnMessageReceived/OnChannelConnected and do our own processing before | 100 // OnMessageReceived/OnChannelConnected and do our own processing before |
| 101 // calling the subclass' implementation. | 101 // calling the subclass' implementation. |
| 102 class ListenerHook : public IPC::Channel::Listener { | 102 class ListenerHook : public IPC::Channel::Listener { |
| 103 public: | 103 public: |
| 104 explicit ListenerHook(ChildProcessHost* host); | 104 explicit ListenerHook(ChildProcessHost* host); |
| 105 virtual bool OnMessageReceived(const IPC::Message& msg); | 105 virtual bool OnMessageReceived(const IPC::Message& msg); |
| 106 virtual void OnChannelConnected(int32 peer_pid); | 106 virtual void OnChannelConnected(int32 peer_pid); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 117 | 117 |
| 118 // Holds all the IPC message filters. Since this object lives on the IO | 118 // Holds all the IPC message filters. Since this object lives on the IO |
| 119 // thread, we don't have a IPC::ChannelProxy and so we manage filters | 119 // thread, we don't have a IPC::ChannelProxy and so we manage filters |
| 120 // manually. | 120 // manually. |
| 121 std::vector<scoped_refptr<IPC::ChannelProxy::MessageFilter> > filters_; | 121 std::vector<scoped_refptr<IPC::ChannelProxy::MessageFilter> > filters_; |
| 122 | 122 |
| 123 DISALLOW_COPY_AND_ASSIGN(ChildProcessHost); | 123 DISALLOW_COPY_AND_ASSIGN(ChildProcessHost); |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 #endif // CHROME_COMMON_CHILD_PROCESS_HOST_H_ | 126 #endif // CHROME_COMMON_CHILD_PROCESS_HOST_H_ |
| OLD | NEW |