-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path4fecaed71992312c829acb2ce5e12e7d149dc506.diff
104 lines (87 loc) · 3.44 KB
/
4fecaed71992312c829acb2ce5e12e7d149dc506.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
diff --git a/mojo/core/embedder/embedder.cc b/mojo/core/embedder/embedder.cc
index de999ee3c7d64..6902650d5dcf1 100644
--- a/mojo/core/embedder/embedder.cc
+++ b/mojo/core/embedder/embedder.cc
@@ -39,7 +39,12 @@
// BUILDFLAG(IS_ANDROID)
#endif // !BUILDFLAG(IS_NACL)
-namespace mojo::core {
+#if BUILDFLAG(IS_WIN)
+#include "base/win/windows_version.h"
+#endif
+
+namespace mojo {
+namespace core {
namespace {
@@ -95,19 +100,30 @@ void InitFeatures() {
#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
if (base::FeatureList::IsEnabled(kMojoIpcz)) {
- EnableMojoIpcz();
+ EnableMojoIpczIfSupported();
} else {
g_mojo_ipcz_enabled.store(false, std::memory_order_release);
}
#endif // !BUILDFLAG(IS_ANDROID)
g_enable_memv2 = base::FeatureList::IsEnabled(kMojoIpczMemV2);
}
-void EnableMojoIpcz() {
-#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
- g_mojo_ipcz_enabled.store(true, std::memory_order_release);
+void EnableMojoIpczIfSupported() {
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
+#if BUILDFLAG(IS_WIN)
+ // TODO(https://crbug.com/1299283): Sandboxed processes on Windows versions
+ // older than 8.1 require some extra (not yet implemented) setup for ipcz to
+ // work properly. This is omitted for early experimentation.
+ const bool kIsIpczSupported =
+ base::win::GetVersion() >= base::win::Version::WIN8_1;
+#else
+ const bool kIsIpczSupported = true;
+#endif
+ if (kIsIpczSupported) {
+ g_mojo_ipcz_enabled.store(true, std::memory_order_release);
+ }
#endif
}
void Init(const Configuration& configuration) {
@@ -193,4 +209,5 @@ IpczDriverHandle CreateIpczTransportFromEndpoint(
return ipcz_driver::ObjectBase::ReleaseAsHandle(std::move(transport));
}
-} // namespace mojo::core
+} // namespace core
+} // namespace mojo
diff --git a/mojo/core/embedder/embedder.h b/mojo/core/embedder/embedder.h
index 2d31ced82a815..88645eff1b4e5 100644
--- a/mojo/core/embedder/embedder.h
+++ b/mojo/core/embedder/embedder.h
@@ -17,7 +17,8 @@
#include "mojo/public/cpp/platform/platform_channel_endpoint.h"
#include "third_party/ipcz/include/ipcz/ipcz.h"
-namespace mojo::core {
+namespace mojo {
+namespace core {
// Basic configuration/initialization ------------------------------------------
@@ -50,13 +51,14 @@ scoped_refptr<base::SingleThreadTaskRunner> GetIOTaskRunner();
// base::Features inside of Mojo.
COMPONENT_EXPORT(MOJO_CORE_EMBEDDER) void InitFeatures();
-// Enables MojoIpcz. Called before Init() is called. Only call this if the
-// current program doesn't have base::FeatureList integration, since otherwise
-// InitFeatures() will do the work.
+// Enables MojoIpcz if it is supported on the current platform. Called before
+// Init() is called. Only call this if the current program doesn't have
+// base::FeatureList integration, since otherwise InitFeatures() will do the
+// work.
//
// TODO(crbug.com/40058840): Remove once MojoIpcz becomes the default
// implementation.
-COMPONENT_EXPORT(MOJO_CORE_EMBEDDER) void EnableMojoIpcz();
+COMPONENT_EXPORT(MOJO_CORE_EMBEDDER) void EnableMojoIpczIfSupported();
// Indicates whether the ipcz-based Mojo implementation is enabled. This can be
// done by enabling the MojoIpcz feature.
@@ -88,6 +90,7 @@ IpczDriverHandle CreateIpczTransportFromEndpoint(
const TransportEndpointTypes& endpoint_types,
base::Process remote_process = base::Process());
-} // namespace mojo::core
+} // namespace core
+} // namespace mojo
#endif // MOJO_CORE_EMBEDDER_EMBEDDER_H_