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

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

Issue 9321003: net: Make UploadData::GetContentLength() asynchronous. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments 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_stream.cc ('k') | net/base/upload_data_unittest.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 #include "net/base/upload_data_stream.h" 5 #include "net/base/upload_data_stream.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h"
10 #include "base/file_path.h" 11 #include "base/file_path.h"
11 #include "base/file_util.h" 12 #include "base/file_util.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop.h"
13 #include "base/time.h" 15 #include "base/time.h"
14 #include "net/base/io_buffer.h" 16 #include "net/base/io_buffer.h"
15 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
16 #include "net/base/upload_data.h" 18 #include "net/base/upload_data.h"
17 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
18 #include "testing/platform_test.h" 20 #include "testing/platform_test.h"
19 21
20 namespace net { 22 namespace net {
21 23
22 namespace { 24 namespace {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 ASSERT_EQ(static_cast<int>(kTestDataSize), 73 ASSERT_EQ(static_cast<int>(kTestDataSize),
72 file_util::WriteFile(temp_file_path, kTestData, kTestDataSize)); 74 file_util::WriteFile(temp_file_path, kTestData, kTestDataSize));
73 const uint64 kFakeSize = kTestDataSize*2; 75 const uint64 kFakeSize = kTestDataSize*2;
74 76
75 std::vector<UploadData::Element> elements; 77 std::vector<UploadData::Element> elements;
76 UploadData::Element element; 78 UploadData::Element element;
77 element.SetToFilePath(temp_file_path); 79 element.SetToFilePath(temp_file_path);
78 element.SetContentLength(kFakeSize); 80 element.SetContentLength(kFakeSize);
79 elements.push_back(element); 81 elements.push_back(element);
80 upload_data_->SetElements(elements); 82 upload_data_->SetElements(elements);
81 EXPECT_EQ(kFakeSize, upload_data_->GetContentLength()); 83 EXPECT_EQ(kFakeSize, upload_data_->GetContentLengthSync());
82 84
83 scoped_ptr<UploadDataStream> stream(new UploadDataStream(upload_data_)); 85 scoped_ptr<UploadDataStream> stream(new UploadDataStream(upload_data_));
84 ASSERT_EQ(OK, stream->Init()); 86 ASSERT_EQ(OK, stream->Init());
85 ASSERT_TRUE(stream.get()); 87 ASSERT_TRUE(stream.get());
86 EXPECT_EQ(kFakeSize, stream->size()); 88 EXPECT_EQ(kFakeSize, stream->size());
87 EXPECT_EQ(0U, stream->position()); 89 EXPECT_EQ(0U, stream->position());
88 EXPECT_FALSE(stream->IsEOF()); 90 EXPECT_FALSE(stream->IsEOF());
89 uint64 read_counter = 0; 91 uint64 read_counter = 0;
90 scoped_refptr<IOBuffer> buf = new IOBuffer(kTestBufferSize); 92 scoped_refptr<IOBuffer> buf = new IOBuffer(kTestBufferSize);
91 while (!stream->IsEOF()) { 93 while (!stream->IsEOF()) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 138
137 // Test file changed. 139 // Test file changed.
138 FileChangedHelper(temp_file_path, 140 FileChangedHelper(temp_file_path,
139 file_info.last_modified - base::TimeDelta::FromSeconds(1), 141 file_info.last_modified - base::TimeDelta::FromSeconds(1),
140 true); 142 true);
141 143
142 file_util::Delete(temp_file_path, false); 144 file_util::Delete(temp_file_path, false);
143 } 145 }
144 146
145 } // namespace net 147 } // namespace net
OLDNEW
« no previous file with comments | « net/base/upload_data_stream.cc ('k') | net/base/upload_data_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698