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

Unified Diff: chrome/profiling/memlog_connection_manager.h

Issue 2943733002: Add out-of-process memory logging stream parsing. (Closed)
Patch Set: Format Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/profiling/memlog_connection_manager.h
diff --git a/chrome/profiling/memlog_connection_manager.h b/chrome/profiling/memlog_connection_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..774974b1c9be9c003958e6f76c9a977ab2a526f2
--- /dev/null
+++ b/chrome/profiling/memlog_connection_manager.h
@@ -0,0 +1,58 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_PROFILING_MEMLOG_CONNECTION_MANAGER_H_
+#define CHROME_PROFILING_MEMLOG_CONNECTION_MANAGER_H_
+
+#include <string>
+
+#include "base/containers/flat_map.h"
+#include "base/macros.h"
+#include "build/build_config.h"
+#include "chrome/profiling/memlog_receiver_pipe_server.h"
+#include "chrome/profiling/stack_storage.h"
+
+namespace base {
+class SingleThreadTaskRunner;
+}
+
+namespace profiling {
+
+// Manages all connections and logging for each process. Pipes are supplied by
+// the pipe server and this class will connect them to a parser and logger.
+class MemlogConnectionManager {
+ public:
+ MemlogConnectionManager();
+ ~MemlogConnectionManager();
+
+ // Starts listening for connections.
+ void StartConnections(const std::string& pipe_id);
+
+ private:
+ struct Connection;
+
+ // Called by the pipe server when a new pipe is created.
+ void OnNewConnection(scoped_refptr<MemlogReceiverPipe> new_pipe);
+
+ // Notification that a connection is complete. Unlike OnNewConnection which
+ // is signaled by the pipe server, this is signaled by the allocation tracker
+ // to ensure that the pipeline for this process has been flushed of all
+ // messages.
+ void OnConnectionComplete(int process_id);
+
+ void OnConnectionCompleteThunk(
+ scoped_refptr<base::SingleThreadTaskRunner> main_loop,
+ int process_id);
+
+ scoped_refptr<MemlogReceiverPipeServer> server_;
+
+ // Maps process ID to the connection information for it.
+ base::flat_map<int, std::unique_ptr<Connection>> connections_;
+
+ DISALLOW_COPY_AND_ASSIGN(MemlogConnectionManager);
+};
+
+} // namespace profiling
+
+#endif // CHROME_PROFILING_MEMLOG_CONNECTION_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698