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

Side by Side Diff: net/base/upload_bytes_element_reader.h

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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 unified diff | Download patch
« no previous file with comments | « net/base/trace_net_log_observer_unittest.cc ('k') | net/base/upload_bytes_element_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef NET_BASE_UPLOAD_BYTES_ELEMENT_READER_H_
6 #define NET_BASE_UPLOAD_BYTES_ELEMENT_READER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "net/base/upload_element_reader.h"
14
15 namespace net {
16
17 // An UploadElementReader implementation for bytes.
18 // |data| should outlive this class because this class does not take the
19 // ownership of the data.
20 class NET_EXPORT UploadBytesElementReader : public UploadElementReader {
21 public:
22 UploadBytesElementReader(const char* bytes, uint64 length);
23 ~UploadBytesElementReader() override;
24
25 const char* bytes() const { return bytes_; }
26 uint64 length() const { return length_; }
27
28 // UploadElementReader overrides:
29 const UploadBytesElementReader* AsBytesReader() const override;
30 int Init(const CompletionCallback& callback) override;
31 uint64 GetContentLength() const override;
32 uint64 BytesRemaining() const override;
33 bool IsInMemory() const override;
34 int Read(IOBuffer* buf,
35 int buf_length,
36 const CompletionCallback& callback) override;
37
38 private:
39 const char* const bytes_;
40 const uint64 length_;
41 uint64 offset_;
42
43 DISALLOW_COPY_AND_ASSIGN(UploadBytesElementReader);
44 };
45
46 // A subclass of UplodBytesElementReader which owns the data given as a vector.
47 class NET_EXPORT UploadOwnedBytesElementReader
48 : public UploadBytesElementReader {
49 public:
50 // |data| is cleared by this ctor.
51 explicit UploadOwnedBytesElementReader(std::vector<char>* data);
52 ~UploadOwnedBytesElementReader() override;
53
54 // Creates UploadOwnedBytesElementReader with a string.
55 static UploadOwnedBytesElementReader* CreateWithString(
56 const std::string& string);
57
58 private:
59 std::vector<char> data_;
60
61 DISALLOW_COPY_AND_ASSIGN(UploadOwnedBytesElementReader);
62 };
63
64 } // namespace net
65
66 #endif // NET_BASE_UPLOAD_BYTES_ELEMENT_READER_H_
OLDNEW
« no previous file with comments | « net/base/trace_net_log_observer_unittest.cc ('k') | net/base/upload_bytes_element_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698