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

Unified Diff: mojo/data_pipe_utils/data_pipe_drainer.h

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 years, 9 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 | « mojo/data_pipe_utils/BUILD.gn ('k') | mojo/data_pipe_utils/data_pipe_drainer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/data_pipe_utils/data_pipe_drainer.h
diff --git a/mojo/data_pipe_utils/data_pipe_drainer.h b/mojo/data_pipe_utils/data_pipe_drainer.h
new file mode 100644
index 0000000000000000000000000000000000000000..c6d3da360f6010597ecbff10294224ab2ab3f2d7
--- /dev/null
+++ b/mojo/data_pipe_utils/data_pipe_drainer.h
@@ -0,0 +1,47 @@
+// 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_DATA_PIPE_UTILS_DATA_PIPE_DRAINER_H_
+#define MOJO_DATA_PIPE_UTILS_DATA_PIPE_DRAINER_H_
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "mojo/message_pump/handle_watcher.h"
+#include "mojo/public/cpp/system/data_pipe.h"
+
+namespace mojo {
+namespace common {
+
+class DataPipeDrainer {
+ public:
+ class Client {
+ public:
+ virtual void OnDataAvailable(const void* data, size_t num_bytes) = 0;
+ virtual void OnDataComplete() = 0;
+
+ protected:
+ virtual ~Client() {}
+ };
+
+ DataPipeDrainer(Client*, mojo::ScopedDataPipeConsumerHandle source);
+ ~DataPipeDrainer();
+
+ private:
+ void ReadData();
+ void WaitForData();
+ void WaitComplete(MojoResult result);
+
+ Client* client_;
+ mojo::ScopedDataPipeConsumerHandle source_;
+ mojo::common::HandleWatcher handle_watcher_;
+
+ base::WeakPtrFactory<DataPipeDrainer> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(DataPipeDrainer);
+};
+
+} // namespace common
+} // namespace mojo
+
+#endif // MOJO_DATA_PIPE_UTILS_DATA_PIPE_DRAINER_H_
« no previous file with comments | « mojo/data_pipe_utils/BUILD.gn ('k') | mojo/data_pipe_utils/data_pipe_drainer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698