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. 4 5#ifndef CONTENT_PUBLIC_COMMON_CHILD_PROCESS_HOST_DELEGATE_H_ 6#define CONTENT_PUBLIC_COMMON_CHILD_PROCESS_HOST_DELEGATE_H_ 7 8#include <string> 9 10#include "base/process/process.h" 11#include "content/common/content_export.h" 12#include "ipc/ipc_listener.h" 13 14namespace content { 15 16// Interface that all users of ChildProcessHost need to provide. 17class ChildProcessHostDelegate : public IPC::Listener { 18 public: 19 virtual ~ChildProcessHostDelegate() {} 20 21 // Delegates return true if it's ok to shut down the child process (which is 22 // the default return value). The exception is if the host is in the middle of 23 // sending a request to the process, in which case the other side might think 24 // it's ok to shutdown, when really it's not. 25 CONTENT_EXPORT virtual bool CanShutdown(); 26 27 // Called when the child process unexpected closes the IPC channel. Delegates 28 // would normally delete the object in this case. 29 virtual void OnChildDisconnected() {} 30 31 // Returns the handle of the child process. This can be called only after 32 // OnProcessLaunched is called or it will be invalid and may crash. 33 virtual base::ProcessHandle GetHandle() const = 0; 34}; 35 36}; // namespace content 37 38#endif // CONTENT_PUBLIC_COMMON_CHILD_PROCESS_HOST_DELEGATE_H_ 39