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

Side by Side Diff: webkit/browser/blob/local_file_stream_reader_unittest.cc

Issue 16155009: Update webkit/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
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 "webkit/browser/blob/local_file_stream_reader.h" 5 #include "webkit/browser/blob/local_file_stream_reader.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 18 matching lines...) Expand all
29 std::string* data, size_t size, 29 std::string* data, size_t size,
30 int* result) { 30 int* result) {
31 ASSERT_TRUE(reader != NULL); 31 ASSERT_TRUE(reader != NULL);
32 ASSERT_TRUE(result != NULL); 32 ASSERT_TRUE(result != NULL);
33 *result = net::OK; 33 *result = net::OK;
34 net::TestCompletionCallback callback; 34 net::TestCompletionCallback callback;
35 size_t total_bytes_read = 0; 35 size_t total_bytes_read = 0;
36 while (total_bytes_read < size) { 36 while (total_bytes_read < size) {
37 scoped_refptr<net::IOBufferWithSize> buf( 37 scoped_refptr<net::IOBufferWithSize> buf(
38 new net::IOBufferWithSize(size - total_bytes_read)); 38 new net::IOBufferWithSize(size - total_bytes_read));
39 int rv = reader->Read(buf, buf->size(), callback.callback()); 39 int rv = reader->Read(buf.get(), buf->size(), callback.callback());
40 if (rv == net::ERR_IO_PENDING) 40 if (rv == net::ERR_IO_PENDING)
41 rv = callback.WaitForResult(); 41 rv = callback.WaitForResult();
42 if (rv < 0) 42 if (rv < 0)
43 *result = rv; 43 *result = rv;
44 if (rv <= 0) 44 if (rv <= 0)
45 break; 45 break;
46 total_bytes_read += rv; 46 total_bytes_read += rv;
47 data->append(buf->data(), rv); 47 data->append(buf->data(), rv);
48 } 48 }
49 } 49 }
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 ASSERT_EQ(&kTestData[3], data); 242 ASSERT_EQ(&kTestData[3], data);
243 } 243 }
244 244
245 TEST_F(LocalFileStreamReaderTest, DeleteWithUnfinishedRead) { 245 TEST_F(LocalFileStreamReaderTest, DeleteWithUnfinishedRead) {
246 scoped_ptr<LocalFileStreamReader> reader( 246 scoped_ptr<LocalFileStreamReader> reader(
247 CreateFileReader(test_path(), 0, base::Time())); 247 CreateFileReader(test_path(), 0, base::Time()));
248 248
249 net::TestCompletionCallback callback; 249 net::TestCompletionCallback callback;
250 scoped_refptr<net::IOBufferWithSize> buf( 250 scoped_refptr<net::IOBufferWithSize> buf(
251 new net::IOBufferWithSize(kTestDataSize)); 251 new net::IOBufferWithSize(kTestDataSize));
252 int rv = reader->Read(buf, buf->size(), base::Bind(&NeverCalled)); 252 int rv = reader->Read(buf.get(), buf->size(), base::Bind(&NeverCalled));
253 ASSERT_TRUE(rv == net::ERR_IO_PENDING || rv >= 0); 253 ASSERT_TRUE(rv == net::ERR_IO_PENDING || rv >= 0);
254 254
255 // Delete immediately. 255 // Delete immediately.
256 // Should not crash; nor should NeverCalled be callback. 256 // Should not crash; nor should NeverCalled be callback.
257 reader.reset(); 257 reader.reset();
258 EnsureFileTaskFinished(); 258 EnsureFileTaskFinished();
259 } 259 }
260 260
261 } // namespace webkit_blob 261 } // namespace webkit_blob
OLDNEW
« no previous file with comments | « webkit/browser/blob/local_file_stream_reader.cc ('k') | webkit/browser/blob/mock_blob_url_request_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698