2323#include " google/cloud/storage/internal/grpc/object_metadata_parser.h"
2424#include " google/cloud/storage/internal/grpc/object_request_parser.h"
2525#include " google/cloud/internal/make_status.h"
26+ #include " absl/strings/cord.h"
2627#include < cstddef>
2728#include < memory>
2829#include < mutex>
@@ -107,7 +108,7 @@ class AsyncWriterConnectionImpl::State
107108 return persisted_state_;
108109 }
109110
110- future<Status> Write (storage::WritePayload payload) {
111+ future<Status> Write (storage::WritePayload const & payload) {
111112 std::unique_lock<std::mutex> lk (mu_);
112113 google::storage::v2::BidiWriteObjectRequest write = MakeRequestLocked ();
113114 ++in_flight_;
@@ -119,15 +120,15 @@ class AsyncWriterConnectionImpl::State
119120 PartialUpload::Call (impl_, hash_function_, std::move (write),
120121 std::move (p), PartialUpload::kNone );
121122
122- return coro->Start ().then ([coro, size,
123- self = shared_from_this ()]( auto f) mutable {
123+ return coro->Start ().then ([coro, size, self = shared_from_this ()](
124+ future<StatusOr< bool >> f) mutable {
124125 coro.reset (); // breaks the cycle between the completion queue and coro
125126 return self->OnPartialUpload (size, f.get ());
126127 });
127128 }
128129
129130 future<StatusOr<google::storage::v2::Object>> Finalize (
130- storage::WritePayload payload) {
131+ storage::WritePayload const & payload) {
131132 std::unique_lock<std::mutex> lk (mu_);
132133 google::storage::v2::BidiWriteObjectRequest write = MakeRequestLocked ();
133134 ++in_flight_;
@@ -179,14 +180,14 @@ class AsyncWriterConnectionImpl::State
179180
180181 std::shared_ptr<PartialUpload> coro = PartialUpload::Call (
181182 impl_, hash_function_, std::move (write), std::move (p), action);
182- return coro->Start ().then ([coro, size,
183- self = shared_from_this ()]( auto f) mutable {
183+ return coro->Start ().then ([coro, size, self = shared_from_this ()](
184+ future<StatusOr< bool >> f) mutable {
184185 coro.reset (); // breaks the cycle between the completion queue and coro
185186 return self->OnFinalUpload (size, f.get ());
186187 });
187188 }
188189
189- future<Status> Flush (storage::WritePayload payload) {
190+ future<Status> Flush (storage::WritePayload const & payload) {
190191 std::unique_lock<std::mutex> lk (mu_);
191192 google::storage::v2::BidiWriteObjectRequest write = MakeRequestLocked ();
192193 ++in_flight_;
@@ -198,14 +199,14 @@ class AsyncWriterConnectionImpl::State
198199 PartialUpload::Call (impl_, hash_function_, std::move (write),
199200 std::move (p), PartialUpload::kFlush );
200201
201- return coro->Start ().then ([coro, size,
202- self = shared_from_this ()]( auto f) mutable {
202+ return coro->Start ().then ([coro, size, self = shared_from_this ()](
203+ future<StatusOr< bool >> f) mutable {
203204 coro.reset (); // breaks the cycle between the completion queue and coro
204205 return self->OnFlush (size, f.get ());
205206 });
206207 }
207208
208- future<Status> Close (storage::WritePayload payload) {
209+ future<Status> Close (storage::WritePayload const & payload) {
209210 std::unique_lock<std::mutex> lk (mu_);
210211 google::storage::v2::BidiWriteObjectRequest write = MakeRequestLocked ();
211212 ++in_flight_;
@@ -217,8 +218,8 @@ class AsyncWriterConnectionImpl::State
217218 PartialUpload::Call (impl_, hash_function_, std::move (write),
218219 std::move (p), PartialUpload::kFlushAndClose );
219220
220- return coro->Start ().then ([coro, size,
221- self = shared_from_this ()]( auto f) mutable {
221+ return coro->Start ().then ([coro, size, self = shared_from_this ()](
222+ future<StatusOr< bool >> f) mutable {
222223 coro.reset (); // breaks the cycle between the completion queue and coro
223224 return self->OnClose (size, f.get ());
224225 });
@@ -366,7 +367,7 @@ class AsyncWriterConnectionImpl::State
366367
367368 return impl_->Read ()
368369 .then (ConsumeLoop{impl_})
369- .then ([self = shared_from_this ()](auto f) {
370+ .then ([self = shared_from_this ()](future< void > f) {
370371 f.get ();
371372 return self->FinishAndCompleteOp ();
372373 });
@@ -423,10 +424,11 @@ class AsyncWriterConnectionImpl::State
423424
424425 return impl_->Read ()
425426 .then (ConsumeLoop{shared_from_this ()})
426- .then ([self = shared_from_this ()](auto f) {
427+ .then ([self = shared_from_this ()](future< void > f) {
427428 std::move (f).get ();
428429 return self->FinishAndCompleteOp ().then (
429- [self](auto f2) -> StatusOr<google::storage::v2::Object> {
430+ [self](
431+ future<Status> f2) -> StatusOr<google::storage::v2::Object> {
430432 Status status = f2.get ();
431433 if (!status.ok ()) return status;
432434 std::unique_lock<std::mutex> lk (self->mu_ );
@@ -481,12 +483,13 @@ class AsyncWriterConnectionImpl::State
481483
482484 // Extend the lifetime of `*this` (and therefore `impl_`) until
483485 // `impl_->Finish()` completes.
484- return impl_->Finish ().then ([self = shared_from_this ()](auto f) mutable {
485- // Break any ownership cycle between the completion queue and this
486- // callback.
487- self.reset ();
488- return f.get ();
489- });
486+ return impl_->Finish ().then (
487+ [self = shared_from_this ()](future<Status> f) mutable {
488+ // Break any ownership cycle between the completion queue and this
489+ // callback.
490+ self.reset ();
491+ return f.get ();
492+ });
490493 }
491494
492495 google::cloud::internal::ImmutableOptions const options_;
@@ -562,20 +565,20 @@ AsyncWriterConnectionImpl::PersistedState() const {
562565}
563566
564567future<Status> AsyncWriterConnectionImpl::Write (storage::WritePayload payload) {
565- return state_->Write (std::move ( payload) );
568+ return state_->Write (payload);
566569}
567570
568571future<StatusOr<google::storage::v2::Object>>
569572AsyncWriterConnectionImpl::Finalize (storage::WritePayload payload) {
570- return state_->Finalize (std::move ( payload) );
573+ return state_->Finalize (payload);
571574}
572575
573576future<Status> AsyncWriterConnectionImpl::Flush (storage::WritePayload payload) {
574- return state_->Flush (std::move ( payload) );
577+ return state_->Flush (payload);
575578}
576579
577580future<Status> AsyncWriterConnectionImpl::Close (storage::WritePayload payload) {
578- return state_->Close (std::move ( payload) );
581+ return state_->Close (payload);
579582}
580583
581584future<StatusOr<std::int64_t >> AsyncWriterConnectionImpl::Query () {
0 commit comments