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

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

Issue 10868064: net: Move data reading functionalities from UploadElement to UploadElementReader (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « net/base/upload_element.cc ('k') | net/base/upload_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_ELEMENT_READER_H_
6 #define NET_BASE_UPLOAD_ELEMENT_READER_H_
7
8 #include "base/basictypes.h"
9 #include "net/base/net_export.h"
10
11 namespace net {
12
13 class UploadElement;
14
15 // An interface to read an upload data element.
16 class NET_EXPORT UploadElementReader {
17 public:
18 UploadElementReader() {}
19 virtual ~UploadElementReader() {}
20
21 // Creates an appropriate UploadElementReader instance for the given element.
22 static UploadElementReader* Create(const UploadElement& element);
23
24 // Initializes the instance synchronously.
25 virtual int InitSync() = 0;
26
27 // Returns the byte-length of the element. For files that do not exist, 0
28 // is returned. This is done for consistency with Mozilla.
29 virtual uint64 GetContentLength() const = 0;
30
31 // Returns the number of bytes remaining to read.
32 virtual uint64 BytesRemaining() const = 0;
33
34 // Returns true if the upload element is entirely in memory.
35 // The default implementation returns false.
36 virtual bool IsInMemory() const;
37
38 // Reads up to |buf_length| bytes synchronously. Returns the number of bytes
39 // read. This function never fails. If there's less data to read than we
40 // initially observed, then pad with zero (this can happen with files).
41 // |buf_length| must be greater than 0.
42 virtual int ReadSync(char* buf, int buf_length) = 0;
43
44 private:
45 DISALLOW_COPY_AND_ASSIGN(UploadElementReader);
46 };
47
48 } // namespace net
49
50 #endif // NET_BASE_UPLOAD_ELEMENT_READER_H_
OLDNEW
« no previous file with comments | « net/base/upload_element.cc ('k') | net/base/upload_element_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698