OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/services/network/url_loader_impl.h" | 5 #include "mojo/services/network/url_loader_impl.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include <utility> | 10 #include <utility> |
8 #include <vector> | 11 #include <vector> |
9 | 12 |
| 13 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
11 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
12 #include "mojo/common/common_type_converters.h" | 16 #include "mojo/common/common_type_converters.h" |
13 #include "mojo/common/url_type_converters.h" | 17 #include "mojo/common/url_type_converters.h" |
14 #include "mojo/services/network/net_adapters.h" | 18 #include "mojo/services/network/net_adapters.h" |
15 #include "mojo/services/network/network_context.h" | 19 #include "mojo/services/network/network_context.h" |
16 #include "net/base/elements_upload_data_stream.h" | 20 #include "net/base/elements_upload_data_stream.h" |
17 #include "net/base/io_buffer.h" | 21 #include "net/base/io_buffer.h" |
18 #include "net/base/load_flags.h" | 22 #include "net/base/load_flags.h" |
19 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 23 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 UploadDataPipeElementReader(ScopedDataPipeConsumerHandle pipe) | 104 UploadDataPipeElementReader(ScopedDataPipeConsumerHandle pipe) |
101 : pipe_(std::move(pipe)), num_bytes_(0) {} | 105 : pipe_(std::move(pipe)), num_bytes_(0) {} |
102 ~UploadDataPipeElementReader() override {} | 106 ~UploadDataPipeElementReader() override {} |
103 | 107 |
104 // UploadElementReader overrides: | 108 // UploadElementReader overrides: |
105 int Init(const net::CompletionCallback& callback) override { | 109 int Init(const net::CompletionCallback& callback) override { |
106 offset_ = 0; | 110 offset_ = 0; |
107 ReadDataRaw(pipe_.get(), nullptr, &num_bytes_, MOJO_READ_DATA_FLAG_QUERY); | 111 ReadDataRaw(pipe_.get(), nullptr, &num_bytes_, MOJO_READ_DATA_FLAG_QUERY); |
108 return net::OK; | 112 return net::OK; |
109 } | 113 } |
110 uint64 GetContentLength() const override { return num_bytes_; } | 114 uint64_t GetContentLength() const override { return num_bytes_; } |
111 uint64 BytesRemaining() const override { return num_bytes_ - offset_; } | 115 uint64_t BytesRemaining() const override { return num_bytes_ - offset_; } |
112 bool IsInMemory() const override { return false; } | 116 bool IsInMemory() const override { return false; } |
113 int Read(net::IOBuffer* buf, | 117 int Read(net::IOBuffer* buf, |
114 int buf_length, | 118 int buf_length, |
115 const net::CompletionCallback& callback) override { | 119 const net::CompletionCallback& callback) override { |
116 uint32_t bytes_read = | 120 uint32_t bytes_read = |
117 std::min(static_cast<uint32_t>(BytesRemaining()), | 121 std::min(static_cast<uint32_t>(BytesRemaining()), |
118 static_cast<uint32_t>(buf_length)); | 122 static_cast<uint32_t>(buf_length)); |
119 if (bytes_read > 0) { | 123 if (bytes_read > 0) { |
120 ReadDataRaw(pipe_.get(), buf->data(), &bytes_read, | 124 ReadDataRaw(pipe_.get(), buf->data(), &bytes_read, |
121 MOJO_READ_DATA_FLAG_NONE); | 125 MOJO_READ_DATA_FLAG_NONE); |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 | 417 |
414 void URLLoaderImpl::ListenForPeerClosed() { | 418 void URLLoaderImpl::ListenForPeerClosed() { |
415 handle_watcher_.Start(response_body_stream_.get(), | 419 handle_watcher_.Start(response_body_stream_.get(), |
416 MOJO_HANDLE_SIGNAL_PEER_CLOSED, | 420 MOJO_HANDLE_SIGNAL_PEER_CLOSED, |
417 MOJO_DEADLINE_INDEFINITE, | 421 MOJO_DEADLINE_INDEFINITE, |
418 base::Bind(&URLLoaderImpl::OnResponseBodyStreamClosed, | 422 base::Bind(&URLLoaderImpl::OnResponseBodyStreamClosed, |
419 base::Unretained(this))); | 423 base::Unretained(this))); |
420 } | 424 } |
421 | 425 |
422 } // namespace mojo | 426 } // namespace mojo |
OLD | NEW |