| 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 "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/synchronization/waitable_event_watcher.h" | 12 #include "base/synchronization/waitable_event_watcher.h" |
| 13 #include "content/browser/child_process_launcher.h" | 13 #include "content/browser/child_process_launcher.h" |
| 14 #include "content/common/child_process_host.h" | 14 #include "content/common/child_process_host.h" |
| 15 #include "content/common/child_process_info.h" | 15 #include "content/common/child_process_info.h" |
| 16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
| 17 #include "content/public/common/process_type.h" |
| 17 | 18 |
| 18 namespace base { | 19 namespace base { |
| 19 class WaitableEvent; | 20 class WaitableEvent; |
| 20 } | 21 } |
| 21 | 22 |
| 22 // Plugins/workers and other child processes that live on the IO thread should | 23 // Plugins/workers and other child processes that live on the IO thread should |
| 23 // derive from this class. | 24 // derive from this class. |
| 24 // | 25 // |
| 25 // [Browser]RenderProcessHost is the main exception that doesn't derive from | 26 // [Browser]RenderProcessHost is the main exception that doesn't derive from |
| 26 // this class. That project lives on the UI thread. | 27 // this class. That project lives on the UI thread. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 39 static void TerminateAll(); | 40 static void TerminateAll(); |
| 40 | 41 |
| 41 // The Iterator class allows iteration through either all child processes, or | 42 // The Iterator class allows iteration through either all child processes, or |
| 42 // ones of a specific type, depending on which constructor is used. Note that | 43 // ones of a specific type, depending on which constructor is used. Note that |
| 43 // this should be done from the IO thread and that the iterator should not be | 44 // this should be done from the IO thread and that the iterator should not be |
| 44 // kept around as it may be invalidated on subsequent event processing in the | 45 // kept around as it may be invalidated on subsequent event processing in the |
| 45 // event loop. | 46 // event loop. |
| 46 class CONTENT_EXPORT Iterator { | 47 class CONTENT_EXPORT Iterator { |
| 47 public: | 48 public: |
| 48 Iterator(); | 49 Iterator(); |
| 49 explicit Iterator(ChildProcessInfo::ProcessType type); | 50 explicit Iterator(content::ProcessType type); |
| 50 BrowserChildProcessHost* operator->() { return *iterator_; } | 51 BrowserChildProcessHost* operator->() { return *iterator_; } |
| 51 BrowserChildProcessHost* operator*() { return *iterator_; } | 52 BrowserChildProcessHost* operator*() { return *iterator_; } |
| 52 BrowserChildProcessHost* operator++(); | 53 BrowserChildProcessHost* operator++(); |
| 53 bool Done(); | 54 bool Done(); |
| 54 | 55 |
| 55 private: | 56 private: |
| 56 bool all_; | 57 bool all_; |
| 57 ChildProcessInfo::ProcessType type_; | 58 content::ProcessType type_; |
| 58 std::list<BrowserChildProcessHost*>::iterator iterator_; | 59 std::list<BrowserChildProcessHost*>::iterator iterator_; |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 protected: | 62 protected: |
| 62 explicit BrowserChildProcessHost(ChildProcessInfo::ProcessType type); | 63 explicit BrowserChildProcessHost(content::ProcessType type); |
| 63 | 64 |
| 64 // Derived classes call this to launch the child process asynchronously. | 65 // Derived classes call this to launch the child process asynchronously. |
| 65 void Launch( | 66 void Launch( |
| 66 #if defined(OS_WIN) | 67 #if defined(OS_WIN) |
| 67 const FilePath& exposed_dir, | 68 const FilePath& exposed_dir, |
| 68 #elif defined(OS_POSIX) | 69 #elif defined(OS_POSIX) |
| 69 bool use_zygote, | 70 bool use_zygote, |
| 70 const base::environment_vector& environ, | 71 const base::environment_vector& environ, |
| 71 #endif | 72 #endif |
| 72 CommandLine* cmd_line); | 73 CommandLine* cmd_line); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 scoped_ptr<ChildProcessLauncher> child_process_; | 128 scoped_ptr<ChildProcessLauncher> child_process_; |
| 128 #if defined(OS_WIN) | 129 #if defined(OS_WIN) |
| 129 base::WaitableEventWatcher child_watcher_; | 130 base::WaitableEventWatcher child_watcher_; |
| 130 #else | 131 #else |
| 131 base::WeakPtrFactory<BrowserChildProcessHost> task_factory_; | 132 base::WeakPtrFactory<BrowserChildProcessHost> task_factory_; |
| 132 #endif | 133 #endif |
| 133 bool disconnect_was_alive_; | 134 bool disconnect_was_alive_; |
| 134 }; | 135 }; |
| 135 | 136 |
| 136 #endif // CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ | 137 #endif // CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ |
| OLD | NEW |