Home | History | Annotate | Download | only in streams

Lines Matching refs:state

30 void OnCopyDataError(const std::shared_ptr<CopyDataState>& state,
32 state->error_callback.Run(std::move(state->in_stream),
33 std::move(state->out_stream), error);
37 void PerformRead(const std::shared_ptr<CopyDataState>& state);
41 void PerformWrite(const std::shared_ptr<CopyDataState>& state, size_t size) {
43 state->success_callback.Run(std::move(state->in_stream),
44 std::move(state->out_stream),
45 state->size_copied);
48 state->size_copied += size;
49 CHECK_GE(state->remaining_to_copy, size);
50 state->remaining_to_copy -= size;
53 bool success = state->out_stream->WriteAllAsync(
54 state->buffer.data(), size, base::Bind(&PerformRead, state),
55 base::Bind(&OnCopyDataError, state), &error);
58 OnCopyDataError(state, error.get());
64 void PerformRead(const std::shared_ptr<CopyDataState>& state) {
66 const uint64_t buffer_size = state->buffer.size();
70 static_cast<size_t>(std::min(buffer_size, state->remaining_to_copy));
72 return PerformWrite(state, 0); // Nothing more to read. Finish operation.
73 bool success = state->in_stream->ReadAsync(
74 state->buffer.data(), size_to_read, base::Bind(PerformWrite, state),
75 base::Bind(OnCopyDataError, state), &error);
78 OnCopyDataError(state, error.get());
203 auto state = std::make_shared<CopyDataState>();
204 state->in_stream = std::move(in_stream);
205 state->out_stream = std::move(out_stream);
206 state->buffer.resize(buffer_size);
207 state->remaining_to_copy = max_size_to_copy;
208 state->size_copied = 0;
209 state->success_callback = success_callback;
210 state->error_callback = error_callback;
212 base::Bind(&PerformRead, state));