summaryrefslogtreecommitdiffstats
path: root/mojo/embedder
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-15 15:50:31 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-15 15:51:43 +0000
commitd70654fa450225425f667a5a0c427c9f00a5212b (patch)
treed757a1b8d87b3478e1dfd3197fcf3d835de07d9a /mojo/embedder
parent08dddedfd37e16625a16eb23d8823ad604cd872a (diff)
downloadchromium_src-d70654fa450225425f667a5a0c427c9f00a5212b.zip
chromium_src-d70654fa450225425f667a5a0c427c9f00a5212b.tar.gz
chromium_src-d70654fa450225425f667a5a0c427c9f00a5212b.tar.bz2
Mojo: Add embedder::PlatformSupport and a simple implementation (and a bit of plumbing).
R=darin@chromium.org Review URL: https://codereview.chromium.org/475223002 Cr-Commit-Position: refs/heads/master@{#289878} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289878 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/embedder')
-rw-r--r--mojo/embedder/platform_support.h40
-rw-r--r--mojo/embedder/simple_platform_support.cc25
-rw-r--r--mojo/embedder/simple_platform_support.h37
3 files changed, 102 insertions, 0 deletions
diff --git a/mojo/embedder/platform_support.h b/mojo/embedder/platform_support.h
new file mode 100644
index 0000000..8b52fdc
--- /dev/null
+++ b/mojo/embedder/platform_support.h
@@ -0,0 +1,40 @@
+// Copyright 2014 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 MOJO_EMBEDDER_PLATFORM_SUPPORT_H_
+#define MOJO_EMBEDDER_PLATFORM_SUPPORT_H_
+
+#include <stddef.h>
+
+#include "base/macros.h"
+#include "mojo/embedder/scoped_platform_handle.h"
+#include "mojo/system/system_impl_export.h"
+
+namespace mojo {
+namespace embedder {
+
+class PlatformSharedBuffer;
+
+// This class is provided by the embedder to implement (typically
+// platform-dependent) things needed by the Mojo system implementation.
+class MOJO_SYSTEM_IMPL_EXPORT PlatformSupport {
+ public:
+ virtual ~PlatformSupport() {}
+
+ virtual PlatformSharedBuffer* CreateSharedBuffer(size_t num_bytes) = 0;
+ virtual PlatformSharedBuffer* CreateSharedBufferFromHandle(
+ size_t num_bytes,
+ ScopedPlatformHandle platform_handle) = 0;
+
+ protected:
+ PlatformSupport() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(PlatformSupport);
+};
+
+} // namespace embedder
+} // namespace mojo
+
+#endif // MOJO_EMBEDDER_PLATFORM_SUPPORT_H_
diff --git a/mojo/embedder/simple_platform_support.cc b/mojo/embedder/simple_platform_support.cc
new file mode 100644
index 0000000..1c7f82b
--- /dev/null
+++ b/mojo/embedder/simple_platform_support.cc
@@ -0,0 +1,25 @@
+// Copyright 2014 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.
+
+#include "mojo/embedder/simple_platform_support.h"
+
+#include "mojo/embedder/simple_platform_shared_buffer.h"
+
+namespace mojo {
+namespace embedder {
+
+PlatformSharedBuffer* SimplePlatformSupport::CreateSharedBuffer(
+ size_t num_bytes) {
+ return SimplePlatformSharedBuffer::Create(num_bytes);
+}
+
+PlatformSharedBuffer* SimplePlatformSupport::CreateSharedBufferFromHandle(
+ size_t num_bytes,
+ ScopedPlatformHandle platform_handle) {
+ return SimplePlatformSharedBuffer::CreateFromPlatformHandle(
+ num_bytes, platform_handle.Pass());
+}
+
+} // namespace embedder
+} // namespace mojo
diff --git a/mojo/embedder/simple_platform_support.h b/mojo/embedder/simple_platform_support.h
new file mode 100644
index 0000000..899c027
--- /dev/null
+++ b/mojo/embedder/simple_platform_support.h
@@ -0,0 +1,37 @@
+// Copyright 2014 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 MOJO_EMBEDDER_SIMPLE_PLATFORM_SUPPORT_H_
+#define MOJO_EMBEDDER_SIMPLE_PLATFORM_SUPPORT_H_
+
+#include "base/macros.h"
+#include "mojo/embedder/platform_support.h"
+#include "mojo/system/system_impl_export.h"
+
+namespace mojo {
+namespace embedder {
+
+// A simple implementation of |PlatformSupport|, when sandboxing and
+// multiprocess support are not issues (e.g., in most tests). Note: This class
+// has no state, and different instances of |SimplePlatformSupport| are mutually
+// compatible (i.e., you don't need to use a single instance of it everywhere --
+// you may simply create one whenever/wherever you need it).
+class MOJO_SYSTEM_IMPL_EXPORT SimplePlatformSupport : public PlatformSupport {
+ public:
+ SimplePlatformSupport() {}
+ virtual ~SimplePlatformSupport() {}
+
+ virtual PlatformSharedBuffer* CreateSharedBuffer(size_t num_bytes) OVERRIDE;
+ virtual PlatformSharedBuffer* CreateSharedBufferFromHandle(
+ size_t num_bytes,
+ ScopedPlatformHandle platform_handle) OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SimplePlatformSupport);
+};
+
+} // namespace embedder
+} // namespace mojo
+
+#endif // MOJO_EMBEDDER_SIMPLE_PLATFORM_SUPPORT_H_