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

Unified Diff: base/metrics/field_trial.h

Issue 2862123002: Pass the GUID for the SharedMemoryHandle used by base::FieldTrialList. (Closed)
Patch Set: clang format Created 3 years, 7 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
« no previous file with comments | « no previous file | base/metrics/field_trial.cc » ('j') | base/metrics/field_trial.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/field_trial.h
diff --git a/base/metrics/field_trial.h b/base/metrics/field_trial.h
index 60a6592ce617a220cf6c6d1fb65936f6876b2fcf..d36a47c434dd922f4d7674fdb878081d1d34bcb5 100644
--- a/base/metrics/field_trial.h
+++ b/base/metrics/field_trial.h
@@ -72,6 +72,7 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/shared_memory.h"
+#include "base/memory/shared_memory_handle.h"
#include "base/metrics/persistent_memory_allocator.h"
#include "base/observer_list_threadsafe.h"
#include "base/pickle.h"
@@ -573,9 +574,9 @@ class BASE_EXPORT FieldTrialList {
#if defined(OS_POSIX) && !defined(OS_NACL)
// On POSIX, we also need to explicitly pass down this file descriptor that
- // should be shared with the child process. Returns kInvalidPlatformFile if no
- // handle exists or was not initialized properly.
- static PlatformFile GetFieldTrialHandle();
+ // should be shared with the child process. Returns an invalid handle if it
+ // was not initialized properly.
+ static base::SharedMemoryHandle GetFieldTrialHandle();
#endif
// Adds a switch to the command line containing the field trial state as a
@@ -645,19 +646,37 @@ class BASE_EXPORT FieldTrialList {
DoNotAddSimulatedFieldTrialsToAllocator);
FRIEND_TEST_ALL_PREFIXES(FieldTrialListTest, AssociateFieldTrialParams);
FRIEND_TEST_ALL_PREFIXES(FieldTrialListTest, ClearParamsFromSharedMemory);
+ FRIEND_TEST_ALL_PREFIXES(FieldTrialListTest,
+ SerializeSharedMemoryHandleMetadata);
+
+ // Serialization and deserialization doesn't actually transport the underlying
Alexei Svitkine (slow) 2017/05/05 18:02:16 Please start this comment explaining what serializ
erikchen 2017/05/05 19:41:51 Done.
+ // OS resource - that must be done by the Process launcher.
+ static std::string SerializeSharedMemoryHandleMetadata(
+ const SharedMemoryHandle& shm);
+#if defined(OS_WIN)
+ static SharedMemoryHandle DeserializeSharedMemoryHandleMetadata(
+ const std::string& switch_value);
+#elif defined(OS_POSIX) && !defined(OS_NACL)
+ static SharedMemoryHandle DeserializeSharedMemoryHandleMetadata(
+ int fd,
+ const std::string& switch_value);
+#endif
#if defined(OS_WIN)
// Takes in |handle_switch| from the command line which represents the shared
// memory handle for field trials, parses it, and creates the field trials.
// Returns true on success, false on failure.
- static bool CreateTrialsFromHandleSwitch(const std::string& handle_switch);
+ // |switch_value| also contains the serialized GUID.
+ static bool CreateTrialsFromSwitchValue(const std::string& switch_value);
#endif
#if defined(OS_POSIX) && !defined(OS_NACL)
// On POSIX systems that use the zygote, we look up the correct fd that backs
// the shared memory segment containing the field trials by looking it up via
// an fd key in GlobalDescriptors. Returns true on success, false on failure.
- static bool CreateTrialsFromDescriptor(int fd_key);
+ // |switch_value| also contains the serialized GUID.
+ static bool CreateTrialsFromDescriptor(int fd_key,
+ const std::string& switch_value);
#endif
// Takes an unmapped SharedMemoryHandle, creates a SharedMemory object from it
@@ -731,7 +750,7 @@ class BASE_EXPORT FieldTrialList {
// Readonly copy of the handle to the allocator. Needs to be a member variable
// because it's needed from both CopyFieldTrialStateToFlags() and
// AppendFieldTrialHandleIfNeeded().
- PlatformFile readonly_allocator_handle_ = kInvalidPlatformFile;
+ base::SharedMemoryHandle readonly_allocator_handle_;
// Tracks whether CreateTrialsFromCommandLine() has been called.
bool create_trials_from_command_line_called_ = false;
« no previous file with comments | « no previous file | base/metrics/field_trial.cc » ('j') | base/metrics/field_trial.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698