| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ | 5 #ifndef CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ |
| 6 #define CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ | 6 #define CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 | 10 |
| 11 #include "content/browser/child_process_launcher.h" | 11 #include "content/browser/child_process_launcher.h" |
| 12 #include "content/common/child_process_host.h" | 12 #include "content/common/child_process_host.h" |
| 13 #include "content/common/child_process_info.h" | 13 #include "content/common/child_process_info.h" |
| 14 | 14 |
| 15 class ResourceDispatcherHost; | |
| 16 | |
| 17 // Plugins/workers and other child processes that live on the IO thread should | 15 // Plugins/workers and other child processes that live on the IO thread should |
| 18 // derive from this class. | 16 // derive from this class. |
| 19 // | 17 // |
| 20 // [Browser]RenderProcessHost is the main exception that doesn't derive from | 18 // [Browser]RenderProcessHost is the main exception that doesn't derive from |
| 21 // this class. That project lives on the UI thread. | 19 // this class. That project lives on the UI thread. |
| 22 class BrowserChildProcessHost : public ChildProcessHost, | 20 class BrowserChildProcessHost : public ChildProcessHost, |
| 23 public ChildProcessInfo, | 21 public ChildProcessInfo, |
| 24 public ChildProcessLauncher::Client { | 22 public ChildProcessLauncher::Client { |
| 25 public: | 23 public: |
| 26 virtual ~BrowserChildProcessHost(); | 24 virtual ~BrowserChildProcessHost(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 49 BrowserChildProcessHost* operator++(); | 47 BrowserChildProcessHost* operator++(); |
| 50 bool Done(); | 48 bool Done(); |
| 51 | 49 |
| 52 private: | 50 private: |
| 53 bool all_; | 51 bool all_; |
| 54 ChildProcessInfo::ProcessType type_; | 52 ChildProcessInfo::ProcessType type_; |
| 55 std::list<BrowserChildProcessHost*>::iterator iterator_; | 53 std::list<BrowserChildProcessHost*>::iterator iterator_; |
| 56 }; | 54 }; |
| 57 | 55 |
| 58 protected: | 56 protected: |
| 59 // DEPRECATED constructor. Do not use anymore. We are trying to eliminate | |
| 60 // using the default URLRequestContext. | |
| 61 BrowserChildProcessHost( | |
| 62 ChildProcessInfo::ProcessType type, | |
| 63 ResourceDispatcherHost* resource_dispatcher_host); | |
| 64 | |
| 65 explicit BrowserChildProcessHost(ChildProcessInfo::ProcessType type); | 57 explicit BrowserChildProcessHost(ChildProcessInfo::ProcessType type); |
| 66 | 58 |
| 67 // Derived classes call this to launch the child process asynchronously. | 59 // Derived classes call this to launch the child process asynchronously. |
| 68 void Launch( | 60 void Launch( |
| 69 #if defined(OS_WIN) | 61 #if defined(OS_WIN) |
| 70 const FilePath& exposed_dir, | 62 const FilePath& exposed_dir, |
| 71 #elif defined(OS_POSIX) | 63 #elif defined(OS_POSIX) |
| 72 bool use_zygote, | 64 bool use_zygote, |
| 73 const base::environment_vector& environ, | 65 const base::environment_vector& environ, |
| 74 #endif | 66 #endif |
| (...skipping 25 matching lines...) Expand all Loading... |
| 100 virtual base::TerminationStatus GetChildTerminationStatus(int* exit_code); | 92 virtual base::TerminationStatus GetChildTerminationStatus(int* exit_code); |
| 101 | 93 |
| 102 // Overrides from ChildProcessHost | 94 // Overrides from ChildProcessHost |
| 103 virtual void OnChildDied(); | 95 virtual void OnChildDied(); |
| 104 virtual void ShutdownStarted(); | 96 virtual void ShutdownStarted(); |
| 105 virtual void Notify(NotificationType type); | 97 virtual void Notify(NotificationType type); |
| 106 // Extends the base class implementation and removes this host from | 98 // Extends the base class implementation and removes this host from |
| 107 // the host list. Calls ChildProcessHost::ForceShutdown | 99 // the host list. Calls ChildProcessHost::ForceShutdown |
| 108 virtual void ForceShutdown(); | 100 virtual void ForceShutdown(); |
| 109 | 101 |
| 110 ResourceDispatcherHost* resource_dispatcher_host() { | |
| 111 return resource_dispatcher_host_; | |
| 112 } | |
| 113 | |
| 114 private: | 102 private: |
| 115 // By using an internal class as the ChildProcessLauncher::Client, we can | 103 // By using an internal class as the ChildProcessLauncher::Client, we can |
| 116 // intercept OnProcessLaunched and do our own processing before | 104 // intercept OnProcessLaunched and do our own processing before |
| 117 // calling the subclass' implementation. | 105 // calling the subclass' implementation. |
| 118 class ClientHook : public ChildProcessLauncher::Client { | 106 class ClientHook : public ChildProcessLauncher::Client { |
| 119 public: | 107 public: |
| 120 explicit ClientHook(BrowserChildProcessHost* host); | 108 explicit ClientHook(BrowserChildProcessHost* host); |
| 121 virtual void OnProcessLaunched(); | 109 virtual void OnProcessLaunched(); |
| 122 private: | 110 private: |
| 123 BrowserChildProcessHost* host_; | 111 BrowserChildProcessHost* host_; |
| 124 }; | 112 }; |
| 125 ClientHook client_; | 113 ClientHook client_; |
| 126 // May be NULL if this current process has no resource dispatcher host. | |
| 127 ResourceDispatcherHost* resource_dispatcher_host_; | |
| 128 scoped_ptr<ChildProcessLauncher> child_process_; | 114 scoped_ptr<ChildProcessLauncher> child_process_; |
| 129 }; | 115 }; |
| 130 | 116 |
| 131 #endif // CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ | 117 #endif // CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ |
| OLD | NEW |