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

Side by Side Diff: net/base/upload_data.cc

Issue 3108042: Support sending BlobData to browser process. Also support sending UploadData... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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_data.h ('k') | webkit/blob/blob_data.h » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "net/base/upload_data.h" 5 #include "net/base/upload_data.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 10
11 namespace net { 11 namespace net {
12 12
13 uint64 UploadData::GetContentLength() { 13 uint64 UploadData::GetContentLength() {
14 uint64 len = 0; 14 uint64 len = 0;
15 std::vector<Element>::iterator it = elements_.begin(); 15 std::vector<Element>::iterator it = elements_.begin();
16 for (; it != elements_.end(); ++it) 16 for (; it != elements_.end(); ++it)
17 len += (*it).GetContentLength(); 17 len += (*it).GetContentLength();
18 return len; 18 return len;
19 } 19 }
20 20
21 uint64 UploadData::Element::GetContentLength() { 21 uint64 UploadData::Element::GetContentLength() {
22 if (override_content_length_ || content_length_computed_) 22 if (override_content_length_ || content_length_computed_)
23 return content_length_; 23 return content_length_;
24 24
25 if (type_ == TYPE_BYTES) 25 if (type_ == TYPE_BYTES)
26 return static_cast<uint64>(bytes_.size()); 26 return static_cast<uint64>(bytes_.size());
27 else if (type_ == TYPE_BLOB)
28 // The blob reference will be resolved later.
29 return 0;
27 30
28 DCHECK_EQ(TYPE_FILE, type_); 31 DCHECK_EQ(TYPE_FILE, type_);
29 DCHECK(!file_stream_); 32 DCHECK(!file_stream_);
30 33
31 // TODO(darin): This size calculation could be out of sync with the state of 34 // TODO(darin): This size calculation could be out of sync with the state of
32 // the file when we get around to reading it. We should probably find a way 35 // the file when we get around to reading it. We should probably find a way
33 // to lock the file or somehow protect against this error condition. 36 // to lock the file or somehow protect against this error condition.
34 37
35 content_length_computed_ = true; 38 content_length_computed_ = true;
36 content_length_ = 0; 39 content_length_ = 0;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 << "\" to offset: " << file_range_offset_ << " (" << rv 83 << "\" to offset: " << file_range_offset_ << " (" << rv
81 << ")"; 84 << ")";
82 return NULL; 85 return NULL;
83 } 86 }
84 } 87 }
85 88
86 return file.release(); 89 return file.release();
87 } 90 }
88 91
89 } // namespace net 92 } // namespace net
OLDNEW
« no previous file with comments | « net/base/upload_data.h ('k') | webkit/blob/blob_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698