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

Unified Diff: base/metrics/stats_table.h

Issue 224713017: Remove IPC dependency from base (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: unit tests Created 6 years, 8 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
« base/DEPS ('K') | « base/DEPS ('k') | base/metrics/stats_table.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/stats_table.h
diff --git a/base/metrics/stats_table.h b/base/metrics/stats_table.h
index 49ba79f88ba71a3692b3310ef3f6fa7bff8fc857..719e6304813243332e0b129cc1422d499a075c1e 100644
--- a/base/metrics/stats_table.h
+++ b/base/metrics/stats_table.h
@@ -28,24 +28,45 @@
#include "base/memory/shared_memory.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread_local_storage.h"
+#include "build/build_config.h"
+
+#if defined(OS_POSIX)
+#include "base/file_descriptor_posix.h"
+#endif
namespace base {
class BASE_EXPORT StatsTable {
public:
- // Create a new StatsTable.
- // If a StatsTable already exists with the specified name, this StatsTable
- // will use the same shared memory segment as the original. Otherwise,
- // a new StatsTable is created and all counters are zeroed.
+ // Identifies a StatsTable. We often want to share these between processes.
+ //
+ // On Windows, we use a named shared memory segment so the table identifier
+ // should be a relatively unique string identifying the table to use. An
+ // empty string can be used to use an anonymous shared memory segment for
+ // cases where the table does not need to be shared between processes.
//
- // name is the name of the StatsTable to use.
+ // Posix does not support named memory so we explicitly share file
+ // descriptors. On Posix, pass a default-constructed file descriptor if a
+ // handle doesn't already exist, and a new one will be created.
+ //
+ // If a table doesn't already exist with the given identifier, a new one will
+ // be created with zeroed counters.
+#if defined(OS_POSIX)
+ typedef FileDescriptor TableIdentifier;
+#elif defined(OS_WIN)
+ typedef std::string TableIdentifier;
+#endif
+
+ // Create a new StatsTable.
//
// max_threads is the maximum number of threads the table will support.
// If the StatsTable already exists, this number is ignored.
//
// max_counters is the maximum number of counters the table will support.
// If the StatsTable already exists, this number is ignored.
- StatsTable(const std::string& name, int max_threads, int max_counters);
+ StatsTable(const TableIdentifier& table,
+ int max_threads,
+ int max_counters);
// Destroys the StatsTable. When the last StatsTable is destroyed
// (across all processes), the StatsTable is removed from disk.
« base/DEPS ('K') | « base/DEPS ('k') | base/metrics/stats_table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698