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

Side by Side Diff: content/browser/browser_child_process_host_impl.h

Issue 2224063002: Use persistent memory for receiving metrics from sub-processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed review comments by Alexei Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_IMPL_H_ 5 #ifndef CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_
6 #define CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_ 6 #define CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <list> 10 #include <list>
11 #include <memory> 11 #include <memory>
12 12
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/process/process.h" 16 #include "base/process/process.h"
17 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
18 #include "base/strings/string_piece.h"
18 #include "base/synchronization/waitable_event_watcher.h" 19 #include "base/synchronization/waitable_event_watcher.h"
19 #include "build/build_config.h" 20 #include "build/build_config.h"
20 #include "content/browser/child_process_launcher.h" 21 #include "content/browser/child_process_launcher.h"
21 #include "content/browser/power_monitor_message_broadcaster.h" 22 #include "content/browser/power_monitor_message_broadcaster.h"
22 #include "content/public/browser/browser_child_process_host.h" 23 #include "content/public/browser/browser_child_process_host.h"
23 #include "content/public/browser/child_process_data.h" 24 #include "content/public/browser/child_process_data.h"
24 #include "content/public/common/child_process_host_delegate.h" 25 #include "content/public/common/child_process_host_delegate.h"
25 26
26 #if defined(OS_WIN) 27 #if defined(OS_WIN)
27 #include "base/win/object_watcher.h" 28 #include "base/win/object_watcher.h"
(...skipping 19 matching lines...) Expand all
47 class CONTENT_EXPORT BrowserChildProcessHostImpl 48 class CONTENT_EXPORT BrowserChildProcessHostImpl
48 : public BrowserChildProcessHost, 49 : public BrowserChildProcessHost,
49 public NON_EXPORTED_BASE(ChildProcessHostDelegate), 50 public NON_EXPORTED_BASE(ChildProcessHostDelegate),
50 #if defined(OS_WIN) 51 #if defined(OS_WIN)
51 public base::win::ObjectWatcher::Delegate, 52 public base::win::ObjectWatcher::Delegate,
52 #endif 53 #endif
53 public ChildProcessLauncher::Client { 54 public ChildProcessLauncher::Client {
54 public: 55 public:
55 BrowserChildProcessHostImpl(content::ProcessType process_type, 56 BrowserChildProcessHostImpl(content::ProcessType process_type,
56 BrowserChildProcessHostDelegate* delegate, 57 BrowserChildProcessHostDelegate* delegate,
57 const std::string& mojo_child_token); 58 const std::string& mojo_child_token,
59 size_t shared_metrics_memory_size,
60 base::StringPiece shared_metrics_name);
58 ~BrowserChildProcessHostImpl() override; 61 ~BrowserChildProcessHostImpl() override;
59 62
60 // Terminates all child processes and deletes each BrowserChildProcessHost 63 // Terminates all child processes and deletes each BrowserChildProcessHost
61 // instance. 64 // instance.
62 static void TerminateAll(); 65 static void TerminateAll();
63 66
64 // Copies kEnableFeatures and kDisableFeatures to the command line. Generates 67 // Copies kEnableFeatures and kDisableFeatures to the command line. Generates
65 // them from the FeatureList override state, to take into account overrides 68 // them from the FeatureList override state, to take into account overrides
66 // from FieldTrials. 69 // from FieldTrials.
67 static void CopyFeatureAndFieldTrialFlags(base::CommandLine* cmd_line); 70 static void CopyFeatureAndFieldTrialFlags(base::CommandLine* cmd_line);
68 71
69 // BrowserChildProcessHost implementation: 72 // BrowserChildProcessHost implementation:
70 bool Send(IPC::Message* message) override; 73 bool Send(IPC::Message* message) override;
71 void Launch(SandboxedProcessLauncherDelegate* delegate, 74 void Launch(SandboxedProcessLauncherDelegate* delegate,
72 base::CommandLine* cmd_line, 75 base::CommandLine* cmd_line,
73 bool terminate_on_shutdown) override; 76 bool terminate_on_shutdown) override;
74 const ChildProcessData& GetData() const override; 77 const ChildProcessData& GetData() const override;
75 ChildProcessHost* GetHost() const override; 78 ChildProcessHost* GetHost() const override;
76 base::TerminationStatus GetTerminationStatus(bool known_dead, 79 base::TerminationStatus GetTerminationStatus(bool known_dead,
77 int* exit_code) override; 80 int* exit_code) override;
81 std::unique_ptr<base::SharedPersistentMemoryAllocator> TakeMetricsAllocator()
82 override;
78 void SetName(const base::string16& name) override; 83 void SetName(const base::string16& name) override;
79 void SetHandle(base::ProcessHandle handle) override; 84 void SetHandle(base::ProcessHandle handle) override;
80 shell::InterfaceProvider* GetRemoteInterfaces() override; 85 shell::InterfaceProvider* GetRemoteInterfaces() override;
81 86
82 // ChildProcessHostDelegate implementation: 87 // ChildProcessHostDelegate implementation:
83 bool CanShutdown() override; 88 bool CanShutdown() override;
84 void OnChildDisconnected() override; 89 void OnChildDisconnected() override;
85 const base::Process& GetProcess() const override; 90 const base::Process& GetProcess() const override;
86 bool OnMessageReceived(const IPC::Message& message) override; 91 bool OnMessageReceived(const IPC::Message& message) override;
87 void OnChannelConnected(int32_t peer_pid) override; 92 void OnChannelConnected(int32_t peer_pid) override;
(...skipping 20 matching lines...) Expand all
108 typedef std::list<BrowserChildProcessHostImpl*> BrowserChildProcessList; 113 typedef std::list<BrowserChildProcessHostImpl*> BrowserChildProcessList;
109 private: 114 private:
110 friend class BrowserChildProcessHostIterator; 115 friend class BrowserChildProcessHostIterator;
111 friend class BrowserChildProcessObserver; 116 friend class BrowserChildProcessObserver;
112 117
113 static BrowserChildProcessList* GetIterator(); 118 static BrowserChildProcessList* GetIterator();
114 119
115 static void AddObserver(BrowserChildProcessObserver* observer); 120 static void AddObserver(BrowserChildProcessObserver* observer);
116 static void RemoveObserver(BrowserChildProcessObserver* observer); 121 static void RemoveObserver(BrowserChildProcessObserver* observer);
117 122
123 // Passes the |metrics_allocator_|, if any, to the managed process. This
124 // requires the process to have been launched and the RPC channel to be
Alexei Svitkine (slow) 2016/08/18 15:57:28 Nit: RPC -> IPC (I think IPC is the term we use in
Alexei Svitkine (slow) 2016/08/19 16:31:56 Ping.
bcwhite 2016/08/19 17:19:46 Done.
125 // available.
126 void ShareMetricsAllocatorToProcess();
127
118 // ChildProcessLauncher::Client implementation. 128 // ChildProcessLauncher::Client implementation.
119 void OnProcessLaunched() override; 129 void OnProcessLaunched() override;
120 void OnProcessLaunchFailed(int error_code) override; 130 void OnProcessLaunchFailed(int error_code) override;
121 131
122 // Returns true if the process has successfully launched. Must only be called 132 // Returns true if the process has successfully launched. Must only be called
123 // on the IO thread. 133 // on the IO thread.
124 bool IsProcessLaunched() const; 134 bool IsProcessLaunched() const;
125 135
126 static void OnMojoError( 136 static void OnMojoError(
127 base::WeakPtr<BrowserChildProcessHostImpl> process, 137 base::WeakPtr<BrowserChildProcessHostImpl> process,
(...skipping 14 matching lines...) Expand all
142 152
143 PowerMonitorMessageBroadcaster power_monitor_message_broadcaster_; 153 PowerMonitorMessageBroadcaster power_monitor_message_broadcaster_;
144 154
145 #if defined(OS_WIN) 155 #if defined(OS_WIN)
146 // Watches to see if the child process exits before the IPC channel has 156 // Watches to see if the child process exits before the IPC channel has
147 // been connected. Thereafter, its exit is determined by an error on the 157 // been connected. Thereafter, its exit is determined by an error on the
148 // IPC channel. 158 // IPC channel.
149 base::win::ObjectWatcher early_exit_watcher_; 159 base::win::ObjectWatcher early_exit_watcher_;
150 #endif 160 #endif
151 161
162 // The memory allocator, if any, in which the process will write its metrics.
163 std::unique_ptr<base::SharedPersistentMemoryAllocator> metrics_allocator_;
164
152 bool is_channel_connected_; 165 bool is_channel_connected_;
153 bool notify_child_disconnected_; 166 bool notify_child_disconnected_;
154 167
155 base::WeakPtrFactory<BrowserChildProcessHostImpl> weak_factory_; 168 base::WeakPtrFactory<BrowserChildProcessHostImpl> weak_factory_;
156 }; 169 };
157 170
158 } // namespace content 171 } // namespace content
159 172
160 #endif // CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_ 173 #endif // CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698