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

Unified Diff: device/serial/data_source_sender.h

Issue 646063003: Change data pipe wrappers used by SerialConnection to use message pipe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
Index: device/serial/data_source_sender.h
diff --git a/device/serial/data_source_sender.h b/device/serial/data_source_sender.h
index 59782aafda85ac1a52f496ff42cf2473deb85519..ce888496cbb372baecddf1dea0d62bc2d298c190 100644
--- a/device/serial/data_source_sender.h
+++ b/device/serial/data_source_sender.h
@@ -7,14 +7,13 @@
#include "base/callback.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
#include "device/serial/buffer.h"
#include "device/serial/data_stream.mojom.h"
#include "mojo/public/cpp/system/data_pipe.h"
namespace device {
-class AsyncWaiter;
-
// A DataSourceSender is an interface between a source of data and a data pipe.
class DataSourceSender : public base::RefCounted<DataSourceSender>,
public mojo::InterfaceImpl<serial::DataSource> {
@@ -41,16 +40,14 @@ class DataSourceSender : public base::RefCounted<DataSourceSender>,
virtual ~DataSourceSender();
// mojo::InterfaceImpl<serial::DataSourceSender> overrides.
- virtual void Init(mojo::ScopedDataPipeProducerHandle handle) override;
+ virtual void Init(uint32_t buffer_size) override;
virtual void Resume() override;
+ virtual void AckData(uint32_t bytes_dispatched) override;
// Invoked in the event of a connection error. Calls DispatchFatalError().
virtual void OnConnectionError() override;
- // Starts waiting for |handle_| to be ready for writes.
- void StartWaiting();
-
- // Invoked when |handle_| is ready for writes.
- void OnDoneWaiting(MojoResult result);
+ // Gets more data to send to the DataSourceClient.
+ void GetMoreData();
// Reports a successful write of |bytes_written|.
void Done(uint32_t bytes_written);
@@ -65,10 +62,7 @@ class DataSourceSender : public base::RefCounted<DataSourceSender>,
// Reports a fatal error to the client and shuts down.
void DispatchFatalError();
- // The data connection to the data receiver.
- mojo::ScopedDataPipeProducerHandle handle_;
-
- // The callback to call when |handle_| is ready for more data.
+ // The callback to call when the client is ready for more data.
ReadyCallback ready_callback_;
// The callback to call if a fatal error occurs.
@@ -77,15 +71,15 @@ class DataSourceSender : public base::RefCounted<DataSourceSender>,
// The current pending send operation if there is one.
scoped_ptr<PendingSend> pending_send_;
- // A waiter used to wait until |handle_| is writable if we are waiting.
- scoped_ptr<AsyncWaiter> waiter_;
-
- // The number of bytes sent to the data receiver.
- uint32_t bytes_sent_;
+ // The number of bytes that have been sent to the client, but have not been
+ // acknowledged.
raymes 2014/10/17 04:04:45 Please see my other note on the similar comment in
Sam McNally 2014/10/20 05:12:59 Done.
+ uint32_t available_buffer_capacity_;
// Whether we have encountered a fatal error and shut down.
bool shut_down_;
+ base::WeakPtrFactory<DataSourceSender> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(DataSourceSender);
};

Powered by Google App Engine
This is Rietveld 408576698