15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CONTENT_PUBLIC_BROWSER_BROWSER_CHILD_PROCESS_HOST_DELEGATE_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CONTENT_PUBLIC_BROWSER_BROWSER_CHILD_PROCESS_HOST_DELEGATE_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/common/content_export.h"
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ipc/ipc_listener.h"
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content {
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Interface that all users of BrowserChildProcessHost need to provide.
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class CONTENT_EXPORT BrowserChildProcessHostDelegate : public IPC::Listener {
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ~BrowserChildProcessHostDelegate() {}
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Delegates return true if it's ok to shut down the child process (which is
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the default return value). The exception is if the host is in the middle of
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // sending a request to the process, in which case the other side might think
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // it's ok to shutdown, when really it's not.
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool CanShutdown();
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when the process has been started.
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnProcessLaunched() {}
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Called if the process failed to launch.  In this case the process never
285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // started so there is no available exit code.
295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void OnProcessLaunchFailed() {}
305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called if the process crashed. |exit_code| is the status returned when the
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // process crashed (for posix, as returned from waitpid(), for Windows, as
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // returned from GetExitCodeProcess()).
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnProcessCrashed(int exit_code) {}
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};  // namespace content
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CONTENT_PUBLIC_BROWSER_BROWSER_CHILD_PROCESS_HOST_DELEGATE_H_
40