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

Unified Diff: mojo/edk/system/parent_token_serializer_win.h

Issue 1387963004: Create a broker interface for the new Mojo EDK so that the browser can create and duplicate messa... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: presubmit whitespace error Created 5 years, 1 month 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: mojo/edk/system/parent_token_serializer_win.h
diff --git a/mojo/edk/system/parent_token_serializer_win.h b/mojo/edk/system/parent_token_serializer_win.h
new file mode 100644
index 0000000000000000000000000000000000000000..e185832372dabf140c407a50500965502b574ebe
--- /dev/null
+++ b/mojo/edk/system/parent_token_serializer_win.h
@@ -0,0 +1,59 @@
+// Copyright 2015 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_EDK_SYSTEM_PARENT_TOKEN_SERIALIZER_WIN_H_
+#define MOJO_EDK_SYSTEM_PARENT_TOKEN_SERIALIZER_WIN_H_
+
+#include <vector>
+
+#include "base/compiler_specific.h"
+#include "base/message_loop/message_loop.h"
+#include "mojo/edk/embedder/scoped_platform_handle.h"
+#include "mojo/edk/system/system_impl_export.h"
+
+namespace mojo {
+namespace edk {
+
+// Responds to requests from a child process to exchange handles to tokens and
+// vice versa. There is one object of this class per child process host object.
+// This object will delete itself when it notices that the pipe is broken.
+class MOJO_SYSTEM_IMPL_EXPORT ParentTokenSerializer
+ : NON_EXPORTED_BASE(public base::MessageLoopForIO::IOHandler) {
+ public:
+ // |child_process| is a handle to the child process. It's not owned by this
+ // class but is guaranteed to be alive as long as the child process is
+ // running. |pipe| is a handle to the communication pipe to the child process,
+ // which is generated inside mojo::edk::ChildProcessLaunched. It is owned by
+ // this class.
+ ParentTokenSerializer(HANDLE child_process, ScopedPlatformHandle pipe);
+
+ private:
+ virtual ~ParentTokenSerializer();
+
+ void RegisterIOHandler();
+ void BeginRead();
+
+ void OnIOCompleted(base::MessageLoopForIO::IOContext* context,
+ DWORD bytes_transferred,
+ DWORD error) override;
+
+ // Helper wrappers around DuplicateHandle.
+ HANDLE DuplicateToChild(HANDLE handle);
+ HANDLE DuplicateFromChild(HANDLE handle);
+
+ HANDLE child_process_;
+ ScopedPlatformHandle pipe_;
+ base::MessageLoopForIO::IOContext read_context_;
+ base::MessageLoopForIO::IOContext write_context_;
+
+ std::vector<char> read_data_;
+ // How many bytes in read_data_ we already read.
+ uint32_t num_bytes_read_;
+ std::vector<char> write_data_;
+};
+
+} // namespace edk
+} // namespace mojo
+
+#endif // MOJO_EDK_SYSTEM_PARENT_TOKEN_SERIALIZER_WIN_H_

Powered by Google App Engine
This is Rietveld 408576698