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

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

Issue 9452040: net: Move the logic reading upload elements to UploadData::Element. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move resetoffset to init Created 8 years, 10 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_data.cc ('k') | net/base/upload_data_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 #ifndef NET_BASE_UPLOAD_DATA_STREAM_H_ 5 #ifndef NET_BASE_UPLOAD_DATA_STREAM_H_
6 #define NET_BASE_UPLOAD_DATA_STREAM_H_ 6 #define NET_BASE_UPLOAD_DATA_STREAM_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "net/base/net_export.h" 10 #include "net/base/net_export.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // stream. 62 // stream.
63 bool IsEOF() const; 63 bool IsEOF() const;
64 64
65 // Returns true if the upload data in the stream is entirely in memory. 65 // Returns true if the upload data in the stream is entirely in memory.
66 bool IsInMemory() const; 66 bool IsInMemory() const;
67 67
68 // This method is provided only to be used by unit tests. 68 // This method is provided only to be used by unit tests.
69 static void set_merge_chunks(bool merge) { merge_chunks_ = merge; } 69 static void set_merge_chunks(bool merge) { merge_chunks_ = merge; }
70 70
71 private: 71 private:
72 // Advances to the next element. Updates the internal states.
73 void AdvanceToNextElement();
74
75 scoped_refptr<UploadData> upload_data_; 72 scoped_refptr<UploadData> upload_data_;
76 73
77 // Index of the current upload element (i.e. the element currently being 74 // Index of the current upload element (i.e. the element currently being
78 // read). The index is used as a cursor to iterate over elements in 75 // read). The index is used as a cursor to iterate over elements in
79 // |upload_data_|. 76 // |upload_data_|.
80 size_t element_index_; 77 size_t element_index_;
81 78
82 // The byte offset into the current element's data buffer if the current
83 // element is a TYPE_BYTES or TYPE_DATA element.
84 size_t element_offset_;
85
86 // A stream to the currently open file, for the current element if the
87 // current element is a TYPE_FILE element.
88 scoped_ptr<FileStream> element_file_stream_;
89
90 // The number of bytes remaining to be read from the currently open file
91 // if the current element is of TYPE_FILE.
92 uint64 element_file_bytes_remaining_;
93
94 // Size and current read position within the upload data stream. 79 // Size and current read position within the upload data stream.
95 uint64 total_size_; 80 uint64 total_size_;
96 uint64 current_position_; 81 uint64 current_position_;
97 82
98 // True if the initialization was successful. 83 // True if the initialization was successful.
99 bool initialized_successfully_; 84 bool initialized_successfully_;
100 85
101 // TODO(satish): Remove this once we have a better way to unit test POST 86 // TODO(satish): Remove this once we have a better way to unit test POST
102 // requests with chunked uploads. 87 // requests with chunked uploads.
103 static bool merge_chunks_; 88 static bool merge_chunks_;
104 89
105 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); 90 DISALLOW_COPY_AND_ASSIGN(UploadDataStream);
106 }; 91 };
107 92
108 } // namespace net 93 } // namespace net
109 94
110 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ 95 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_
OLDNEW
« no previous file with comments | « net/base/upload_data.cc ('k') | net/base/upload_data_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698