Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: chrome/browser/child_process_host.h

Issue 1625015: Refactor ChildProcess and related classes to create a framework outside of br... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/child_process_context.cc ('k') | chrome/browser/child_process_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/child_process_host.h
===================================================================
--- chrome/browser/child_process_host.h (revision 44239)
+++ chrome/browser/child_process_host.h (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -12,8 +12,10 @@
#include "ipc/ipc_logging.h"
#include "base/basictypes.h"
+#include "base/mp/mp_child_process_host.h"
+#include "base/mp/mp_child_process_launcher.h"
#include "base/scoped_ptr.h"
-#include "chrome/browser/child_process_launcher.h"
+#include "chrome/browser/child_process_context.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
#include "ipc/ipc_channel.h"
@@ -26,8 +28,7 @@
// [Browser]RenderProcessHost is the main exception that doesn't derive from
// this class. That project lives on the UI thread.
class ChildProcessHost : public ResourceDispatcherHost::Receiver,
- public IPC::Channel::Listener,
- public ChildProcessLauncher::Client {
+ public base::MpChildProcessHost {
public:
virtual ~ChildProcessHost();
@@ -83,76 +84,20 @@
ChildProcessHost(ProcessType type,
ResourceDispatcherHost* resource_dispatcher_host);
- // Derived classes call this to launch the child process asynchronously.
- void Launch(
-#if defined(OS_WIN)
- const FilePath& exposed_dir,
-#elif defined(OS_POSIX)
- bool use_zygote,
- const base::environment_vector& environ,
-#endif
- CommandLine* cmd_line);
-
- // Derived classes return true if it's ok to shut down the child process.
- virtual bool CanShutdown() = 0;
-
- // Send the shutdown message to the child process, and remove this host from
- // the host list. Does not check if CanShutdown is true.
- void ForceShutdown();
-
- // Creates the IPC channel. Returns true iff it succeeded.
- bool CreateChannel();
-
- // Notifies us that an instance has been created on this child process.
- void InstanceCreated();
-
- // IPC::Channel::Listener implementation:
- virtual void OnMessageReceived(const IPC::Message& msg) { }
- virtual void OnChannelConnected(int32 peer_pid) { }
- virtual void OnChannelError() { }
-
- // ChildProcessLauncher::Client implementation.
- virtual void OnProcessLaunched() {}
-
- // Derived classes can override this to know if the process crashed.
- virtual void OnProcessCrashed() {}
-
- bool opening_channel() { return opening_channel_; }
- const std::string& channel_id() { return channel_id_; }
-
- virtual bool DidChildCrash();
-
- // Called when the child process goes away.
- virtual void OnChildDied();
-
private:
- // Sends the given notification to the notification service on the UI thread.
- void Notify(NotificationType type);
+ // base::MpChildProcessHost implementation:
+ virtual void Notify(base::MpChildProcessHost::MpNotificationType type);
- // By using an internal class as the IPC::Channel::Listener, we can intercept
- // OnMessageReceived/OnChannelConnected and do our own processing before
- // calling the subclass' implementation.
- class ListenerHook : public IPC::Channel::Listener,
- public ChildProcessLauncher::Client {
- public:
- explicit ListenerHook(ChildProcessHost* host);
- virtual void OnMessageReceived(const IPC::Message& msg);
- virtual void OnChannelConnected(int32 peer_pid);
- virtual void OnChannelError();
- virtual void OnProcessLaunched();
- private:
- ChildProcessHost* host_;
- };
+ virtual bool OnDispatchMessageReceived(const IPC::Message& msg,
+ bool *msg_is_ok);
- ListenerHook listener_;
+ virtual void OnProcessLaunched();
+ virtual int GetType();
+
// May be NULL if this current process has no resource dispatcher host.
ResourceDispatcherHost* resource_dispatcher_host_;
-
- bool opening_channel_; // True while we're waiting the channel to be opened.
- scoped_ptr<IPC::Channel> channel_;
- std::string channel_id_;
- scoped_ptr<ChildProcessLauncher> child_process_;
+ ChildProcessContext context_;
};
#endif // CHROME_BROWSER_CHILD_PROCESS_HOST_H_
« no previous file with comments | « chrome/browser/child_process_context.cc ('k') | chrome/browser/child_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698