diff options
author | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-11 16:46:36 +0000 |
---|---|---|
committer | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-11 16:46:36 +0000 |
commit | cadac62e5c2b9f5fef59ce0326bb2cd79ffbe622 (patch) | |
tree | 7b95f103fce509de887c8c5e643604855b57c0ba /net | |
parent | 9f6e673c7f43f6ee414f72a74585dad8ebaceec3 (diff) | |
download | chromium_src-cadac62e5c2b9f5fef59ce0326bb2cd79ffbe622.zip chromium_src-cadac62e5c2b9f5fef59ce0326bb2cd79ffbe622.tar.gz chromium_src-cadac62e5c2b9f5fef59ce0326bb2cd79ffbe622.tar.bz2 |
Call scoped_refptr<T>::get() rather than relying on implicit "operator T*"
This upates calls to bound temporary objects to also use get().
While it has the same semantic equivalence to the existing code, this generally
represents a dangerous pattern - indeed, part of the whole motivation for this
change is to make this anti-pattern very visible to authors.
This change simply updates all of the call sites, to allow the "operator T*"
to be removed and preventing new instances. The existing instances will then be
reviewed for "suspicious" changes and updated to use/pass scoped_refptr<T>
rather than T*, as appropriate.
BUG=110610
TBR=darin
Review URL: https://codereview.chromium.org/15984016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205560 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
28 files changed, 313 insertions, 186 deletions
diff --git a/net/base/upload_data_stream_unittest.cc b/net/base/upload_data_stream_unittest.cc index 59b44af..a31dd5c 100644 --- a/net/base/upload_data_stream_unittest.cc +++ b/net/base/upload_data_stream_unittest.cc @@ -170,9 +170,12 @@ TEST_F(UploadDataStreamTest, File) { ASSERT_EQ(static_cast<int>(kTestDataSize), file_util::WriteFile(temp_file_path, kTestData, kTestDataSize)); - element_readers_.push_back(new UploadFileElementReader( - base::MessageLoopProxy::current(), - temp_file_path, 0, kuint64max, base::Time())); + element_readers_.push_back( + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + temp_file_path, + 0, + kuint64max, + base::Time())); TestCompletionCallback init_callback; UploadDataStream stream(&element_readers_, 0); @@ -205,9 +208,12 @@ TEST_F(UploadDataStreamTest, FileSmallerThanLength) { UploadFileElementReader::ScopedOverridingContentLengthForTests overriding_content_length(kFakeSize); - element_readers_.push_back(new UploadFileElementReader( - base::MessageLoopProxy::current(), - temp_file_path, 0, kuint64max, base::Time())); + element_readers_.push_back( + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + temp_file_path, + 0, + kuint64max, + base::Time())); TestCompletionCallback init_callback; UploadDataStream stream(&element_readers_, 0); @@ -318,9 +324,12 @@ TEST_F(UploadDataStreamTest, FileAndBytes) { const uint64 kFileRangeOffset = 1; const uint64 kFileRangeLength = 4; - element_readers_.push_back(new UploadFileElementReader( - base::MessageLoopProxy::current(), - temp_file_path, kFileRangeOffset, kFileRangeLength, base::Time())); + element_readers_.push_back( + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + temp_file_path, + kFileRangeOffset, + kFileRangeLength, + base::Time())); element_readers_.push_back(new UploadBytesElementReader( kTestData, kTestDataSize)); @@ -520,7 +529,7 @@ void UploadDataStreamTest::FileChangedHelper(const base::FilePath& file_path, // reusing element_readers_ is wrong. ScopedVector<UploadElementReader> element_readers; element_readers.push_back(new UploadFileElementReader( - base::MessageLoopProxy::current(), file_path, 1, 2, time)); + base::MessageLoopProxy::current().get(), file_path, 1, 2, time)); TestCompletionCallback init_callback; UploadDataStream stream(&element_readers, 0); @@ -561,9 +570,12 @@ TEST_F(UploadDataStreamTest, MultipleInit) { // Prepare data. element_readers_.push_back(new UploadBytesElementReader( kTestData, kTestDataSize)); - element_readers_.push_back(new UploadFileElementReader( - base::MessageLoopProxy::current(), - temp_file_path, 0, kuint64max, base::Time())); + element_readers_.push_back( + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + temp_file_path, + 0, + kuint64max, + base::Time())); UploadDataStream stream(&element_readers_, 0); std::string expected_data(kTestData, kTestData + kTestDataSize); @@ -603,9 +615,12 @@ TEST_F(UploadDataStreamTest, MultipleInitAsync) { // Prepare data. element_readers_.push_back(new UploadBytesElementReader( kTestData, kTestDataSize)); - element_readers_.push_back(new UploadFileElementReader( - base::MessageLoopProxy::current(), - temp_file_path, 0, kuint64max, base::Time())); + element_readers_.push_back( + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + temp_file_path, + 0, + kuint64max, + base::Time())); UploadDataStream stream(&element_readers_, 0); std::string expected_data(kTestData, kTestData + kTestDataSize); @@ -642,9 +657,12 @@ TEST_F(UploadDataStreamTest, InitToReset) { // Prepare data. element_readers_.push_back(new UploadBytesElementReader( kTestData, kTestDataSize)); - element_readers_.push_back(new UploadFileElementReader( - base::MessageLoopProxy::current(), - temp_file_path, 0, kuint64max, base::Time())); + element_readers_.push_back( + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + temp_file_path, + 0, + kuint64max, + base::Time())); UploadDataStream stream(&element_readers_, 0); std::vector<char> expected_data(kTestData, kTestData + kTestDataSize); @@ -696,9 +714,12 @@ TEST_F(UploadDataStreamTest, InitDuringAsyncInit) { // Prepare data. element_readers_.push_back(new UploadBytesElementReader( kTestData, kTestDataSize)); - element_readers_.push_back(new UploadFileElementReader( - base::MessageLoopProxy::current(), - temp_file_path, 0, kuint64max, base::Time())); + element_readers_.push_back( + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + temp_file_path, + 0, + kuint64max, + base::Time())); UploadDataStream stream(&element_readers_, 0); std::vector<char> expected_data(kTestData, kTestData + kTestDataSize); @@ -741,9 +762,12 @@ TEST_F(UploadDataStreamTest, InitDuringAsyncRead) { // Prepare data. element_readers_.push_back(new UploadBytesElementReader( kTestData, kTestDataSize)); - element_readers_.push_back(new UploadFileElementReader( - base::MessageLoopProxy::current(), - temp_file_path, 0, kuint64max, base::Time())); + element_readers_.push_back( + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + temp_file_path, + 0, + kuint64max, + base::Time())); UploadDataStream stream(&element_readers_, 0); std::vector<char> expected_data(kTestData, kTestData + kTestDataSize); diff --git a/net/base/upload_file_element_reader_unittest.cc b/net/base/upload_file_element_reader_unittest.cc index bd0594c..8224f7730 100644 --- a/net/base/upload_file_element_reader_unittest.cc +++ b/net/base/upload_file_element_reader_unittest.cc @@ -30,9 +30,12 @@ class UploadFileElementReaderTest : public PlatformTest { static_cast<int>(bytes_.size()), file_util::WriteFile(temp_file_path_, &bytes_[0], bytes_.size())); - reader_.reset(new UploadFileElementReader( - base::MessageLoopProxy::current(), - temp_file_path_, 0, kuint64max, base::Time())); + reader_.reset( + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + temp_file_path_, + 0, + kuint64max, + base::Time())); TestCompletionCallback callback; ASSERT_EQ(ERR_IO_PENDING, reader_->Init(callback.callback())); EXPECT_EQ(OK, callback.WaitForResult()); @@ -170,9 +173,12 @@ TEST_F(UploadFileElementReaderTest, InitDuringAsyncOperation) { TEST_F(UploadFileElementReaderTest, Range) { const uint64 kOffset = 2; const uint64 kLength = bytes_.size() - kOffset * 3; - reader_.reset(new UploadFileElementReader( - base::MessageLoopProxy::current(), - temp_file_path_, kOffset, kLength, base::Time())); + reader_.reset( + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + temp_file_path_, + kOffset, + kLength, + base::Time())); TestCompletionCallback init_callback; ASSERT_EQ(ERR_IO_PENDING, reader_->Init(init_callback.callback())); EXPECT_EQ(OK, init_callback.WaitForResult()); @@ -197,9 +203,12 @@ TEST_F(UploadFileElementReaderTest, FileChanged) { // Expect one second before the actual modification time to simulate change. const base::Time expected_modification_time = info.last_modified - base::TimeDelta::FromSeconds(1); - reader_.reset(new UploadFileElementReader( - base::MessageLoopProxy::current(), - temp_file_path_, 0, kuint64max, expected_modification_time)); + reader_.reset( + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + temp_file_path_, + 0, + kuint64max, + expected_modification_time)); TestCompletionCallback init_callback; ASSERT_EQ(ERR_IO_PENDING, reader_->Init(init_callback.callback())); EXPECT_EQ(ERR_UPLOAD_FILE_CHANGED, init_callback.WaitForResult()); @@ -207,9 +216,12 @@ TEST_F(UploadFileElementReaderTest, FileChanged) { TEST_F(UploadFileElementReaderTest, WrongPath) { const base::FilePath wrong_path(FILE_PATH_LITERAL("wrong_path")); - reader_.reset(new UploadFileElementReader( - base::MessageLoopProxy::current(), - wrong_path, 0, kuint64max, base::Time())); + reader_.reset( + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + wrong_path, + 0, + kuint64max, + base::Time())); TestCompletionCallback init_callback; ASSERT_EQ(ERR_IO_PENDING, reader_->Init(init_callback.callback())); EXPECT_EQ(OK, init_callback.WaitForResult()); diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc index 7c9c005..2b0a155 100644 --- a/net/disk_cache/backend_unittest.cc +++ b/net/disk_cache/backend_unittest.cc @@ -238,11 +238,16 @@ TEST_F(DiskCacheTest, CreateBackend) { cache = NULL; // Now test the public API. - int rv = disk_cache::CreateCacheBackend(net::DISK_CACHE, - net::CACHE_BACKEND_DEFAULT, - cache_path_, 0, false, - cache_thread.message_loop_proxy(), - NULL, &cache, cb.callback()); + int rv = + disk_cache::CreateCacheBackend(net::DISK_CACHE, + net::CACHE_BACKEND_DEFAULT, + cache_path_, + 0, + false, + cache_thread.message_loop_proxy().get(), + NULL, + &cache, + cb.callback()); ASSERT_EQ(net::OK, cb.GetResult(rv)); ASSERT_TRUE(cache); delete cache; @@ -273,7 +278,7 @@ TEST_F(DiskCacheBackendTest, CreateBackend_MissingFile) { bool prev = base::ThreadRestrictions::SetIOAllowed(false); disk_cache::BackendImpl* cache = new disk_cache::BackendImpl( - cache_path_, cache_thread.message_loop_proxy(), NULL); + cache_path_, cache_thread.message_loop_proxy().get(), NULL); int rv = cache->Init(cb.callback()); ASSERT_EQ(net::ERR_FAILED, cb.GetResult(rv)); base::ThreadRestrictions::SetIOAllowed(prev); @@ -476,9 +481,16 @@ TEST_F(DiskCacheTest, TruncatedIndex) { net::TestCompletionCallback cb; disk_cache::Backend* backend = NULL; - int rv = disk_cache::CreateCacheBackend( - net::DISK_CACHE, net::CACHE_BACKEND_BLOCKFILE, cache_path_, 0, false, - cache_thread.message_loop_proxy(), NULL, &backend, cb.callback()); + int rv = + disk_cache::CreateCacheBackend(net::DISK_CACHE, + net::CACHE_BACKEND_BLOCKFILE, + cache_path_, + 0, + false, + cache_thread.message_loop_proxy().get(), + NULL, + &backend, + cb.callback()); ASSERT_NE(net::OK, cb.GetResult(rv)); ASSERT_TRUE(backend == NULL); @@ -1677,7 +1689,7 @@ TEST_F(DiskCacheTest, WrongVersion) { net::TestCompletionCallback cb; disk_cache::BackendImpl* cache = new disk_cache::BackendImpl( - cache_path_, cache_thread.message_loop_proxy(), NULL); + cache_path_, cache_thread.message_loop_proxy().get(), NULL); int rv = cache->Init(cb.callback()); ASSERT_EQ(net::ERR_FAILED, cb.GetResult(rv)); @@ -1695,11 +1707,16 @@ TEST_F(DiskCacheBackendTest, DeleteOld) { net::TestCompletionCallback cb; bool prev = base::ThreadRestrictions::SetIOAllowed(false); base::FilePath path(cache_path_); - int rv = disk_cache::CreateCacheBackend(net::DISK_CACHE, - net::CACHE_BACKEND_BLOCKFILE, path, - 0, true, - cache_thread.message_loop_proxy(), - NULL, &cache_, cb.callback()); + int rv = + disk_cache::CreateCacheBackend(net::DISK_CACHE, + net::CACHE_BACKEND_BLOCKFILE, + path, + 0, + true, + cache_thread.message_loop_proxy().get(), + NULL, + &cache_, + cb.callback()); path.clear(); // Make sure path was captured by the previous call. ASSERT_EQ(net::OK, cb.GetResult(rv)); base::ThreadRestrictions::SetIOAllowed(prev); @@ -2456,8 +2473,7 @@ TEST_F(DiskCacheTest, Backend_UsageStats) { ASSERT_TRUE(CleanupCacheDir()); scoped_ptr<disk_cache::BackendImpl> cache; cache.reset(new disk_cache::BackendImpl( - cache_path_, base::MessageLoopProxy::current(), - NULL)); + cache_path_, base::MessageLoopProxy::current().get(), NULL)); ASSERT_TRUE(NULL != cache.get()); cache->SetUnitTestMode(); ASSERT_EQ(net::OK, cache->SyncInit()); @@ -2581,13 +2597,26 @@ TEST_F(DiskCacheTest, MultipleInstances) { const int kNumberOfCaches = 2; disk_cache::Backend* cache[kNumberOfCaches]; - int rv = disk_cache::CreateCacheBackend( - net::DISK_CACHE, net::CACHE_BACKEND_DEFAULT, store1.path(), 0, false, - cache_thread.message_loop_proxy(), NULL, &cache[0], cb.callback()); + int rv = + disk_cache::CreateCacheBackend(net::DISK_CACHE, + net::CACHE_BACKEND_DEFAULT, + store1.path(), + 0, + false, + cache_thread.message_loop_proxy().get(), + NULL, + &cache[0], + cb.callback()); ASSERT_EQ(net::OK, cb.GetResult(rv)); - rv = disk_cache::CreateCacheBackend( - net::MEDIA_CACHE, net::CACHE_BACKEND_DEFAULT, store2.path(), 0, false, - cache_thread.message_loop_proxy(), NULL, &cache[1], cb.callback()); + rv = disk_cache::CreateCacheBackend(net::MEDIA_CACHE, + net::CACHE_BACKEND_DEFAULT, + store2.path(), + 0, + false, + cache_thread.message_loop_proxy().get(), + NULL, + &cache[1], + cb.callback()); ASSERT_EQ(net::OK, cb.GetResult(rv)); ASSERT_TRUE(cache[0] != NULL && cache[1] != NULL); @@ -2989,8 +3018,10 @@ TEST_F(DiskCacheBackendTest, SimpleCacheOverBlockfileCache) { ASSERT_TRUE(cache_thread.StartWithOptions( base::Thread::Options(base::MessageLoop::TYPE_IO, 0))); disk_cache::SimpleBackendImpl* simple_cache = - new disk_cache::SimpleBackendImpl(cache_path_, 0, net::DISK_CACHE, - cache_thread.message_loop_proxy(), + new disk_cache::SimpleBackendImpl(cache_path_, + 0, + net::DISK_CACHE, + cache_thread.message_loop_proxy().get(), NULL); net::TestCompletionCallback cb; int rv = simple_cache->Init(cb.callback()); @@ -3020,7 +3051,7 @@ TEST_F(DiskCacheBackendTest, BlockfileCacheOverSimpleCache) { ASSERT_TRUE(cache_thread.StartWithOptions( base::Thread::Options(base::MessageLoop::TYPE_IO, 0))); disk_cache::BackendImpl* cache = new disk_cache::BackendImpl( - cache_path_, base::MessageLoopProxy::current(), NULL); + cache_path_, base::MessageLoopProxy::current().get(), NULL); cache->SetUnitTestMode(); net::TestCompletionCallback cb; int rv = cache->Init(cb.callback()); diff --git a/net/disk_cache/disk_cache_perftest.cc b/net/disk_cache/disk_cache_perftest.cc index f112cde..1d6bfd6 100644 --- a/net/disk_cache/disk_cache_perftest.cc +++ b/net/disk_cache/disk_cache_perftest.cc @@ -180,9 +180,16 @@ TEST_F(DiskCacheTest, CacheBackendPerformance) { ASSERT_TRUE(CleanupCacheDir()); net::TestCompletionCallback cb; disk_cache::Backend* cache; - int rv = disk_cache::CreateCacheBackend( - net::DISK_CACHE, net::CACHE_BACKEND_BLOCKFILE, cache_path_, 0, false, - cache_thread.message_loop_proxy(), NULL, &cache, cb.callback()); + int rv = + disk_cache::CreateCacheBackend(net::DISK_CACHE, + net::CACHE_BACKEND_BLOCKFILE, + cache_path_, + 0, + false, + cache_thread.message_loop_proxy().get(), + NULL, + &cache, + cb.callback()); ASSERT_EQ(net::OK, cb.GetResult(rv)); @@ -208,10 +215,15 @@ TEST_F(DiskCacheTest, CacheBackendPerformance) { ASSERT_TRUE(file_util::EvictFileFromSystemCache( cache_path_.AppendASCII("data_3"))); - rv = disk_cache::CreateCacheBackend( - net::DISK_CACHE, net::CACHE_BACKEND_BLOCKFILE, cache_path_, 0, false, - cache_thread.message_loop_proxy(), - NULL, &cache, cb.callback()); + rv = disk_cache::CreateCacheBackend(net::DISK_CACHE, + net::CACHE_BACKEND_BLOCKFILE, + cache_path_, + 0, + false, + cache_thread.message_loop_proxy().get(), + NULL, + &cache, + cb.callback()); ASSERT_EQ(net::OK, cb.GetResult(rv)); EXPECT_TRUE(TimeRead(num_entries, cache, entries, true)); diff --git a/net/disk_cache/disk_cache_test_base.cc b/net/disk_cache/disk_cache_test_base.cc index af47321..d6688bb 100644 --- a/net/disk_cache/disk_cache_test_base.cc +++ b/net/disk_cache/disk_cache_test_base.cc @@ -266,15 +266,15 @@ void DiskCacheTestWithCache::InitDiskCache() { void DiskCacheTestWithCache::CreateBackend(uint32 flags, base::Thread* thread) { base::MessageLoopProxy* runner; if (use_current_thread_) - runner = base::MessageLoopProxy::current(); + runner = base::MessageLoopProxy::current().get(); else - runner = thread->message_loop_proxy(); + runner = thread->message_loop_proxy().get(); if (simple_cache_mode_) { net::TestCompletionCallback cb; disk_cache::SimpleBackendImpl* simple_backend = - new disk_cache::SimpleBackendImpl(cache_path_, size_, type_, - make_scoped_refptr(runner), NULL); + new disk_cache::SimpleBackendImpl( + cache_path_, size_, type_, make_scoped_refptr(runner).get(), NULL); int rv = simple_backend->Init(cb.callback()); ASSERT_EQ(net::OK, cb.GetResult(rv)); cache_ = simple_cache_impl_ = simple_backend; diff --git a/net/disk_cache/disk_cache_test_util.cc b/net/disk_cache/disk_cache_test_util.cc index 0a622dc..8f334f0 100644 --- a/net/disk_cache/disk_cache_test_util.cc +++ b/net/disk_cache/disk_cache_test_util.cc @@ -63,7 +63,7 @@ bool DeleteCache(const base::FilePath& path) { bool CheckCacheIntegrity(const base::FilePath& path, bool new_eviction, uint32 mask) { scoped_ptr<disk_cache::BackendImpl> cache(new disk_cache::BackendImpl( - path, mask, base::MessageLoopProxy::current(), NULL)); + path, mask, base::MessageLoopProxy::current().get(), NULL)); if (!cache.get()) return false; if (new_eviction) diff --git a/net/disk_cache/entry_unittest.cc b/net/disk_cache/entry_unittest.cc index 971e719..01645dc 100644 --- a/net/disk_cache/entry_unittest.cc +++ b/net/disk_cache/entry_unittest.cc @@ -2865,13 +2865,15 @@ TEST_F(DiskCacheEntryTest, SimpleCacheOptimisticWriteReleases) { // operations. To ensure the queue is empty, we issue a write and wait until // it completes. EXPECT_EQ(kWriteSize, - WriteData(entry, 0, 0, buffer1, kWriteSize, false)); + WriteData(entry, 0, 0, buffer1.get(), kWriteSize, false)); EXPECT_TRUE(buffer1->HasOneRef()); // Finally, we should perform an optimistic write and confirm that all // references to the IO buffer have been released. - EXPECT_EQ(kWriteSize, entry->WriteData( - 1, 0, buffer1, kWriteSize, net::CompletionCallback(), false)); + EXPECT_EQ( + kWriteSize, + entry->WriteData( + 1, 0, buffer1.get(), kWriteSize, net::CompletionCallback(), false)); EXPECT_TRUE(buffer1->HasOneRef()); entry->Close(); } @@ -3218,7 +3220,7 @@ TEST_F(DiskCacheEntryTest, SimpleCacheReadCombineCRC) { ASSERT_EQ(net::OK, CreateEntry(key, &entry)); EXPECT_NE(null, entry); - EXPECT_EQ(kSize, WriteData(entry, 0, 0, buffer1, kSize, false)); + EXPECT_EQ(kSize, WriteData(entry, 0, 0, buffer1.get(), kSize, false)); entry->Close(); disk_cache::Entry* entry2 = NULL; @@ -3229,14 +3231,14 @@ TEST_F(DiskCacheEntryTest, SimpleCacheReadCombineCRC) { int offset = 0; int buf_len = kHalfSize; scoped_refptr<net::IOBuffer> buffer1_read1(new net::IOBuffer(buf_len)); - EXPECT_EQ(buf_len, ReadData(entry2, 0, offset, buffer1_read1, buf_len)); + EXPECT_EQ(buf_len, ReadData(entry2, 0, offset, buffer1_read1.get(), buf_len)); EXPECT_EQ(0, memcmp(buffer1->data(), buffer1_read1->data(), buf_len)); // Read the second half of the data. offset = buf_len; buf_len = kHalfSize; scoped_refptr<net::IOBuffer> buffer1_read2(new net::IOBuffer(buf_len)); - EXPECT_EQ(buf_len, ReadData(entry2, 0, offset, buffer1_read2, buf_len)); + EXPECT_EQ(buf_len, ReadData(entry2, 0, offset, buffer1_read2.get(), buf_len)); char* buffer1_data = buffer1->data() + offset; EXPECT_EQ(0, memcmp(buffer1_data, buffer1_read2->data(), buf_len)); @@ -3274,10 +3276,12 @@ TEST_F(DiskCacheEntryTest, SimpleCacheNonSequentialWrite) { int offset = kHalfSize; int buf_len = kHalfSize; - EXPECT_EQ(buf_len, WriteData(entry, 0, offset, buffer2, buf_len, false)); + EXPECT_EQ(buf_len, + WriteData(entry, 0, offset, buffer2.get(), buf_len, false)); offset = 0; buf_len = kHalfSize; - EXPECT_EQ(buf_len, WriteData(entry, 0, offset, buffer1, buf_len, false)); + EXPECT_EQ(buf_len, + WriteData(entry, 0, offset, buffer1.get(), buf_len, false)); entry->Close(); disk_cache::Entry* entry2 = NULL; @@ -3285,7 +3289,7 @@ TEST_F(DiskCacheEntryTest, SimpleCacheNonSequentialWrite) { EXPECT_EQ(entry, entry2); scoped_refptr<net::IOBuffer> buffer1_read1(new net::IOBuffer(kSize)); - EXPECT_EQ(kSize, ReadData(entry2, 0, 0, buffer1_read1, kSize)); + EXPECT_EQ(kSize, ReadData(entry2, 0, 0, buffer1_read1.get(), kSize)); EXPECT_EQ(0, memcmp(buffer1->data(), buffer1_read1->data(), kSize)); // Check that we are not leaking. diff --git a/net/disk_cache/simple/simple_backend_impl.cc b/net/disk_cache/simple/simple_backend_impl.cc index 1179153..4e74106 100644 --- a/net/disk_cache/simple/simple_backend_impl.cc +++ b/net/disk_cache/simple/simple_backend_impl.cc @@ -133,12 +133,11 @@ void RecordIndexLoad(base::TimeTicks constructed_since, int result) { namespace disk_cache { -SimpleBackendImpl::SimpleBackendImpl( - const FilePath& path, - int max_bytes, - net::CacheType type, - base::SingleThreadTaskRunner* cache_thread, - net::NetLog* net_log) +SimpleBackendImpl::SimpleBackendImpl(const FilePath& path, + int max_bytes, + net::CacheType type, + base::SingleThreadTaskRunner* cache_thread, + net::NetLog* net_log) : path_(path), index_(new SimpleIndex(MessageLoopProxy::current(), // io_thread path, diff --git a/net/disk_cache/simple/simple_index_unittest.cc b/net/disk_cache/simple/simple_index_unittest.cc index 0f6a799..7f023e8 100644 --- a/net/disk_cache/simple/simple_index_unittest.cc +++ b/net/disk_cache/simple/simple_index_unittest.cc @@ -53,7 +53,7 @@ class TestSimpleIndexFile : public SimpleIndexFile, scoped_refptr<base::SingleThreadTaskRunner> response_thread, const SimpleIndexFile::IndexCompletionCallback& completion_callback) OVERRIDE { - last_response_thread_ = response_thread; + last_response_thread_ = response_thread.get(); completion_callback_ = completion_callback; ++get_index_entries_calls_; } diff --git a/net/disk_cache/stress_cache.cc b/net/disk_cache/stress_cache.cc index b4129ef..ef257a7 100644 --- a/net/disk_cache/stress_cache.cc +++ b/net/disk_cache/stress_cache.cc @@ -111,9 +111,8 @@ void StressTheCache(int iteration) { base::Thread::Options(base::MessageLoop::TYPE_IO, 0))) return; - disk_cache::BackendImpl* cache = - new disk_cache::BackendImpl(path, mask, cache_thread.message_loop_proxy(), - NULL); + disk_cache::BackendImpl* cache = new disk_cache::BackendImpl( + path, mask, cache_thread.message_loop_proxy().get(), NULL); cache->SetMaxSize(cache_size); cache->SetFlags(disk_cache::kNoLoadProtection); diff --git a/net/http/http_network_transaction_spdy2_unittest.cc b/net/http/http_network_transaction_spdy2_unittest.cc index 6f5c955..d9cbb0a 100644 --- a/net/http/http_network_transaction_spdy2_unittest.cc +++ b/net/http/http_network_transaction_spdy2_unittest.cc @@ -7551,8 +7551,11 @@ TEST_F(HttpNetworkTransactionSpdy2Test, UploadFileSmallerThanLength) { ScopedVector<UploadElementReader> element_readers; element_readers.push_back( - new UploadFileElementReader(base::MessageLoopProxy::current(), - temp_file_path, 0, kuint64max, base::Time())); + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + temp_file_path, + 0, + kuint64max, + base::Time())); UploadDataStream upload_data_stream(&element_readers, 0); HttpRequestInfo request; @@ -7605,8 +7608,11 @@ TEST_F(HttpNetworkTransactionSpdy2Test, UploadUnreadableFile) { ScopedVector<UploadElementReader> element_readers; element_readers.push_back( - new UploadFileElementReader(base::MessageLoopProxy::current(), - temp_file, 0, kuint64max, base::Time())); + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + temp_file, + 0, + kuint64max, + base::Time())); UploadDataStream upload_data_stream(&element_readers, 0); HttpRequestInfo request; @@ -7662,8 +7668,11 @@ TEST_F(HttpNetworkTransactionSpdy2Test, UnreadableUploadFileAfterAuthRestart) { ScopedVector<UploadElementReader> element_readers; element_readers.push_back( - new UploadFileElementReader(base::MessageLoopProxy::current(), - temp_file, 0, kuint64max, base::Time())); + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + temp_file, + 0, + kuint64max, + base::Time())); UploadDataStream upload_data_stream(&element_readers, 0); HttpRequestInfo request; diff --git a/net/http/http_network_transaction_spdy3_unittest.cc b/net/http/http_network_transaction_spdy3_unittest.cc index af4fb72..7430808 100644 --- a/net/http/http_network_transaction_spdy3_unittest.cc +++ b/net/http/http_network_transaction_spdy3_unittest.cc @@ -7537,8 +7537,11 @@ TEST_F(HttpNetworkTransactionSpdy3Test, UploadFileSmallerThanLength) { ScopedVector<UploadElementReader> element_readers; element_readers.push_back( - new UploadFileElementReader(base::MessageLoopProxy::current(), - temp_file_path, 0, kuint64max, base::Time())); + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + temp_file_path, + 0, + kuint64max, + base::Time())); UploadDataStream upload_data_stream(&element_readers, 0); HttpRequestInfo request; @@ -7591,8 +7594,11 @@ TEST_F(HttpNetworkTransactionSpdy3Test, UploadUnreadableFile) { ScopedVector<UploadElementReader> element_readers; element_readers.push_back( - new UploadFileElementReader(base::MessageLoopProxy::current(), - temp_file, 0, kuint64max, base::Time())); + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + temp_file, + 0, + kuint64max, + base::Time())); UploadDataStream upload_data_stream(&element_readers, 0); HttpRequestInfo request; @@ -7648,8 +7654,11 @@ TEST_F(HttpNetworkTransactionSpdy3Test, UnreadableUploadFileAfterAuthRestart) { ScopedVector<UploadElementReader> element_readers; element_readers.push_back( - new UploadFileElementReader(base::MessageLoopProxy::current(), - temp_file, 0, kuint64max, base::Time())); + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + temp_file, + 0, + kuint64max, + base::Time())); UploadDataStream upload_data_stream(&element_readers, 0); HttpRequestInfo request; diff --git a/net/http/http_stream_factory_impl_job.cc b/net/http/http_stream_factory_impl_job.cc index 480a575..fa7eba5 100644 --- a/net/http/http_stream_factory_impl_job.cc +++ b/net/http/http_stream_factory_impl_job.cc @@ -391,8 +391,8 @@ int HttpStreamFactoryImpl::Job::OnHostResolution( // ClientSocketPoolManager will be destroyed in the same callback that // destroys the SpdySessionPool. bool has_session = - spdy_session_pool->GetIfExists(spdy_session_key, net_log) != NULL; - return has_session ? ERR_SPDY_SESSION_ALREADY_EXISTS : OK; + spdy_session_pool->GetIfExists(spdy_session_key, net_log).get() != NULL; + return has_session ? ERR_SPDY_SESSION_ALREADY_EXISTS : OK; } void HttpStreamFactoryImpl::Job::OnIOComplete(int result) { diff --git a/net/http/http_stream_parser_unittest.cc b/net/http/http_stream_parser_unittest.cc index 5d9bcfd..99a0803 100644 --- a/net/http/http_stream_parser_unittest.cc +++ b/net/http/http_stream_parser_unittest.cc @@ -125,8 +125,12 @@ TEST(HttpStreamParser, ShouldMergeRequestHeadersAndBody_FileBody) { ASSERT_TRUE(file_util::CreateTemporaryFileInDir(temp_dir.path(), &temp_file_path)); - element_readers.push_back(new UploadFileElementReader( - base::MessageLoopProxy::current(), temp_file_path, 0, 0, base::Time())); + element_readers.push_back( + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + temp_file_path, + 0, + 0, + base::Time())); scoped_ptr<UploadDataStream> body(new UploadDataStream(&element_readers, 0)); TestCompletionCallback callback; diff --git a/net/proxy/network_delegate_error_observer_unittest.cc b/net/proxy/network_delegate_error_observer_unittest.cc index 881e4bf6..cb32760 100644 --- a/net/proxy/network_delegate_error_observer_unittest.cc +++ b/net/proxy/network_delegate_error_observer_unittest.cc @@ -99,13 +99,14 @@ TEST(NetworkDelegateErrorObserverTest, CallOnThread) { base::Thread thread("test_thread"); thread.Start(); TestNetworkDelegate network_delegate; - NetworkDelegateErrorObserver - observer(&network_delegate, - base::MessageLoopProxy::current()); - thread.message_loop()->PostTask( - FROM_HERE, - base::Bind(&NetworkDelegateErrorObserver::OnPACScriptError, - base::Unretained(&observer), 42, base::string16())); + NetworkDelegateErrorObserver observer( + &network_delegate, base::MessageLoopProxy::current().get()); + thread.message_loop() + ->PostTask(FROM_HERE, + base::Bind(&NetworkDelegateErrorObserver::OnPACScriptError, + base::Unretained(&observer), + 42, + base::string16())); thread.Stop(); base::MessageLoop::current()->RunUntilIdle(); ASSERT_TRUE(network_delegate.got_pac_error()); @@ -115,12 +116,14 @@ TEST(NetworkDelegateErrorObserverTest, CallOnThread) { TEST(NetworkDelegateErrorObserverTest, NoDelegate) { base::Thread thread("test_thread"); thread.Start(); - NetworkDelegateErrorObserver - observer(NULL, base::MessageLoopProxy::current()); - thread.message_loop()->PostTask( - FROM_HERE, - base::Bind(&NetworkDelegateErrorObserver::OnPACScriptError, - base::Unretained(&observer), 42, base::string16())); + NetworkDelegateErrorObserver observer( + NULL, base::MessageLoopProxy::current().get()); + thread.message_loop() + ->PostTask(FROM_HERE, + base::Bind(&NetworkDelegateErrorObserver::OnPACScriptError, + base::Unretained(&observer), + 42, + base::string16())); thread.Stop(); base::MessageLoop::current()->RunUntilIdle(); // Shouldn't have crashed until here... diff --git a/net/proxy/proxy_config_service_linux_unittest.cc b/net/proxy/proxy_config_service_linux_unittest.cc index 5f0ebee..8f1ca8c 100644 --- a/net/proxy/proxy_config_service_linux_unittest.cc +++ b/net/proxy/proxy_config_service_linux_unittest.cc @@ -292,8 +292,8 @@ class SynchConfigGetter { DCHECK_EQ(base::MessageLoop::TYPE_IO, file_loop->type()); // We pass the mock IO thread as both the IO and file threads. config_service_->SetupAndFetchInitialConfig( - base::MessageLoopProxy::current(), - io_thread_.message_loop_proxy(), + base::MessageLoopProxy::current().get(), + io_thread_.message_loop_proxy().get(), static_cast<base::MessageLoopForIO*>(file_loop)); } // Synchronously gets the proxy config. diff --git a/net/proxy/proxy_service_v8.cc b/net/proxy/proxy_service_v8.cc index d5a3dd7..945719a 100644 --- a/net/proxy/proxy_service_v8.cc +++ b/net/proxy/proxy_service_v8.cc @@ -25,9 +25,8 @@ ProxyService* CreateProxyServiceUsingV8ProxyResolver( DCHECK(dhcp_proxy_script_fetcher); DCHECK(host_resolver); - ProxyResolverErrorObserver* error_observer = - new NetworkDelegateErrorObserver( - network_delegate, base::MessageLoopProxy::current()); + ProxyResolverErrorObserver* error_observer = new NetworkDelegateErrorObserver( + network_delegate, base::MessageLoopProxy::current().get()); ProxyResolver* proxy_resolver = new ProxyResolverV8Tracing(host_resolver, error_observer, net_log); diff --git a/net/quic/quic_http_stream_test.cc b/net/quic/quic_http_stream_test.cc index 7ccd404..d9919f0 100644 --- a/net/quic/quic_http_stream_test.cc +++ b/net/quic/quic_http_stream_test.cc @@ -351,7 +351,7 @@ TEST_F(QuicHttpStreamTest, GetRequest) { // Now that the headers have been processed, the callback will return. EXPECT_EQ(OK, callback_.WaitForResult()); - ASSERT_TRUE(response_.headers); + ASSERT_TRUE(response_.headers.get()); EXPECT_EQ(404, response_.headers->response_code()); EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); @@ -393,7 +393,7 @@ TEST_F(QuicHttpStreamTest, GetRequestFullResponseInSinglePacket) { // Now that the headers have been processed, the callback will return. EXPECT_EQ(OK, callback_.WaitForResult()); - ASSERT_TRUE(response_.headers); + ASSERT_TRUE(response_.headers.get()); EXPECT_EQ(200, response_.headers->response_code()); EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); @@ -443,7 +443,7 @@ TEST_F(QuicHttpStreamTest, SendPostRequest) { // Since the headers have already arrived, this should return immediately. EXPECT_EQ(OK, stream_->ReadResponseHeaders(callback_.callback())); - ASSERT_TRUE(response_.headers); + ASSERT_TRUE(response_.headers.get()); EXPECT_EQ(200, response_.headers->response_code()); EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); @@ -505,7 +505,7 @@ TEST_F(QuicHttpStreamTest, SendChunkedPostRequest) { // Since the headers have already arrived, this should return immediately. ASSERT_EQ(OK, stream_->ReadResponseHeaders(callback_.callback())); - ASSERT_TRUE(response_.headers); + ASSERT_TRUE(response_.headers.get()); EXPECT_EQ(200, response_.headers->response_code()); EXPECT_TRUE(response_.headers->HasHeaderValue("Content-Type", "text/plain")); diff --git a/net/quic/quic_stream_factory.cc b/net/quic/quic_stream_factory.cc index b314b78..303571b 100644 --- a/net/quic/quic_stream_factory.cc +++ b/net/quic/quic_stream_factory.cc @@ -377,8 +377,10 @@ QuicClientSession* QuicStreamFactory::CreateSession( socket->Connect(addr); QuicConnectionHelper* helper = new QuicConnectionHelper( - base::MessageLoop::current()->message_loop_proxy(), - clock_.get(), random_generator_, socket); + base::MessageLoop::current()->message_loop_proxy().get(), + clock_.get(), + random_generator_, + socket); QuicConnection* connection = new QuicConnection(guid, addr, helper, false); diff --git a/net/socket/ssl_client_socket_nss.cc b/net/socket/ssl_client_socket_nss.cc index 091f28e..c37d690 100644 --- a/net/socket/ssl_client_socket_nss.cc +++ b/net/socket/ssl_client_socket_nss.cc @@ -3111,7 +3111,7 @@ int SSLClientSocketNSS::Init() { } void SSLClientSocketNSS::InitCore() { - core_ = new Core(base::ThreadTaskRunnerHandle::Get(), + core_ = new Core(base::ThreadTaskRunnerHandle::Get().get(), nss_task_runner_.get(), transport_.get(), host_and_port_, @@ -3419,7 +3419,7 @@ int SSLClientSocketNSS::DoVerifyCert(int result) { core_->state().server_cert.get(), host_and_port_.host(), flags, - SSLConfigService::GetCRLSet(), + SSLConfigService::GetCRLSet().get(), &server_cert_verify_result_, base::Bind(&SSLClientSocketNSS::OnHandshakeIOComplete, base::Unretained(this)), diff --git a/net/spdy/spdy_network_transaction_spdy2_unittest.cc b/net/spdy/spdy_network_transaction_spdy2_unittest.cc index 35d4ea3..d71cee2 100644 --- a/net/spdy/spdy_network_transaction_spdy2_unittest.cc +++ b/net/spdy/spdy_network_transaction_spdy2_unittest.cc @@ -421,9 +421,12 @@ class SpdyNetworkTransactionSpdy2Test file_util::WriteFile(file_path, kUploadData, kUploadDataSize)); ScopedVector<UploadElementReader> element_readers; - element_readers.push_back(new UploadFileElementReader( - base::MessageLoopProxy::current(), - file_path, 0, kUploadDataSize, base::Time())); + element_readers.push_back( + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + file_path, + 0, + kUploadDataSize, + base::Time())); upload_data_stream_.reset(new UploadDataStream(&element_readers, 0)); google_post_request_.method = "POST"; @@ -448,9 +451,12 @@ class SpdyNetworkTransactionSpdy2Test ScopedVector<UploadElementReader> element_readers; element_readers.push_back( new UploadBytesElementReader(kUploadData, kFileRangeOffset)); - element_readers.push_back(new UploadFileElementReader( - base::MessageLoopProxy::current(), - file_path, kFileRangeOffset, kFileRangeLength, base::Time())); + element_readers.push_back( + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + file_path, + kFileRangeOffset, + kFileRangeLength, + base::Time())); element_readers.push_back(new UploadBytesElementReader( kUploadData + kFileRangeOffset + kFileRangeLength, kUploadDataSize - (kFileRangeOffset + kFileRangeLength))); diff --git a/net/spdy/spdy_network_transaction_spdy3_unittest.cc b/net/spdy/spdy_network_transaction_spdy3_unittest.cc index d7c1cc5..13b372d 100644 --- a/net/spdy/spdy_network_transaction_spdy3_unittest.cc +++ b/net/spdy/spdy_network_transaction_spdy3_unittest.cc @@ -423,9 +423,12 @@ class SpdyNetworkTransactionSpdy3Test file_util::WriteFile(file_path, kUploadData, kUploadDataSize)); ScopedVector<UploadElementReader> element_readers; - element_readers.push_back(new UploadFileElementReader( - base::MessageLoopProxy::current(), - file_path, 0, kUploadDataSize, base::Time())); + element_readers.push_back( + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + file_path, + 0, + kUploadDataSize, + base::Time())); upload_data_stream_.reset(new UploadDataStream(&element_readers, 0)); google_post_request_.method = "POST"; @@ -450,9 +453,12 @@ class SpdyNetworkTransactionSpdy3Test ScopedVector<UploadElementReader> element_readers; element_readers.push_back( new UploadBytesElementReader(kUploadData, kFileRangeOffset)); - element_readers.push_back(new UploadFileElementReader( - base::MessageLoopProxy::current(), - file_path, kFileRangeOffset, kFileRangeLength, base::Time())); + element_readers.push_back( + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + file_path, + kFileRangeOffset, + kFileRangeLength, + base::Time())); element_readers.push_back(new UploadBytesElementReader( kUploadData + kFileRangeOffset + kFileRangeLength, kUploadDataSize - (kFileRangeOffset + kFileRangeLength))); diff --git a/net/tools/crash_cache/crash_cache.cc b/net/tools/crash_cache/crash_cache.cc index f59863e..5613d0d 100644 --- a/net/tools/crash_cache/crash_cache.cc +++ b/net/tools/crash_cache/crash_cache.cc @@ -138,8 +138,8 @@ bool CreateCache(const base::FilePath& path, disk_cache::Backend** cache, net::TestCompletionCallback* cb) { int size = 1024 * 1024; - disk_cache::BackendImpl* backend = - new disk_cache::BackendImpl(path, thread->message_loop_proxy(), NULL); + disk_cache::BackendImpl* backend = new disk_cache::BackendImpl( + path, thread->message_loop_proxy().get(), NULL); backend->SetMaxSize(size); backend->SetType(net::DISK_CACHE); backend->SetFlags(disk_cache::kNoRandom); @@ -265,7 +265,7 @@ int LoadOperations(const base::FilePath& path, RankCrashes action, // Work with a tiny index table (16 entries). disk_cache::BackendImpl* cache = new disk_cache::BackendImpl( - path, 0xf, cache_thread->message_loop_proxy(), NULL); + path, 0xf, cache_thread->message_loop_proxy().get(), NULL); if (!cache || !cache->SetMaxSize(0x100000)) return GENERIC; diff --git a/net/tools/dump_cache/simple_cache_dumper.cc b/net/tools/dump_cache/simple_cache_dumper.cc index 4e846cb..42429cd 100644 --- a/net/tools/dump_cache/simple_cache_dumper.cc +++ b/net/tools/dump_cache/simple_cache_dumper.cc @@ -125,9 +125,15 @@ int SimpleCacheDumper::DoCreateCache() { DCHECK(!cache_); state_ = STATE_CREATE_CACHE_COMPLETE; return disk_cache::CreateCacheBackend( - DISK_CACHE, CACHE_BACKEND_DEFAULT, input_path_, 0, false, - cache_thread_->message_loop_proxy(), - NULL, &cache_, io_callback_); + DISK_CACHE, + CACHE_BACKEND_DEFAULT, + input_path_, + 0, + false, + cache_thread_->message_loop_proxy().get(), + NULL, + &cache_, + io_callback_); } int SimpleCacheDumper::DoCreateCacheComplete(int rv) { diff --git a/net/tools/net_watcher/net_watcher.cc b/net/tools/net_watcher/net_watcher.cc index c2a7766..18fd41d 100644 --- a/net/tools/net_watcher/net_watcher.cc +++ b/net/tools/net_watcher/net_watcher.cc @@ -171,8 +171,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS // Use the network loop as the file loop also. scoped_ptr<net::ProxyConfigService> proxy_config_service( net::ProxyService::CreateSystemProxyConfigService( - network_loop.message_loop_proxy(), - &network_loop)); + network_loop.message_loop_proxy().get(), &network_loop)); // Uses |network_change_notifier|. net::NetworkChangeNotifier::AddIPAddressObserver(&net_watcher); diff --git a/net/url_request/url_fetcher_impl_unittest.cc b/net/url_request/url_fetcher_impl_unittest.cc index c0b1573..9f31580 100644 --- a/net/url_request/url_fetcher_impl_unittest.cc +++ b/net/url_request/url_fetcher_impl_unittest.cc @@ -164,7 +164,7 @@ class URLFetcherMockDnsTest : public URLFetcherTest { void URLFetcherTest::CreateFetcher(const GURL& url) { fetcher_ = new URLFetcherImpl(url, URLFetcher::GET, this); fetcher_->SetRequestContext(new ThrottlingTestURLRequestContextGetter( - io_message_loop_proxy(), request_context())); + io_message_loop_proxy().get(), request_context())); fetcher_->Start(); } @@ -217,7 +217,7 @@ void URLFetcherMockDnsTest::SetUp() { void URLFetcherMockDnsTest::CreateFetcher(const GURL& url) { fetcher_ = new URLFetcherImpl(url, URLFetcher::GET, this); fetcher_->SetRequestContext(new ThrottlingTestURLRequestContextGetter( - io_message_loop_proxy(), request_context())); + io_message_loop_proxy().get(), request_context())); } void URLFetcherMockDnsTest::OnURLFetchComplete(const URLFetcher* source) { @@ -522,9 +522,8 @@ class URLFetcherFileTest : public URLFetcherTest { void URLFetcherPostTest::CreateFetcher(const GURL& url) { fetcher_ = new URLFetcherImpl(url, URLFetcher::POST, this); fetcher_->SetRequestContext(new ThrottlingTestURLRequestContextGetter( - io_message_loop_proxy(), request_context())); - fetcher_->SetUploadData("application/x-www-form-urlencoded", - "bobsyeruncle"); + io_message_loop_proxy().get(), request_context())); + fetcher_->SetUploadData("application/x-www-form-urlencoded", "bobsyeruncle"); fetcher_->Start(); } @@ -548,7 +547,7 @@ URLFetcherPostFileTest::URLFetcherPostFileTest() void URLFetcherPostFileTest::CreateFetcher(const GURL& url) { fetcher_ = new URLFetcherImpl(url, URLFetcher::POST, this); fetcher_->SetRequestContext(new ThrottlingTestURLRequestContextGetter( - io_message_loop_proxy(), request_context())); + io_message_loop_proxy().get(), request_context())); fetcher_->SetUploadFilePath("application/x-www-form-urlencoded", path_, range_offset_, @@ -594,7 +593,7 @@ void URLFetcherEmptyPostTest::OnURLFetchComplete(const URLFetcher* source) { void URLFetcherDownloadProgressTest::CreateFetcher(const GURL& url) { fetcher_ = new URLFetcherImpl(url, URLFetcher::GET, this); fetcher_->SetRequestContext(new ThrottlingTestURLRequestContextGetter( - io_message_loop_proxy(), request_context())); + io_message_loop_proxy().get(), request_context())); fetcher_->Start(); } @@ -611,7 +610,7 @@ void URLFetcherDownloadProgressTest::OnURLFetchDownloadProgress( void URLFetcherDownloadProgressCancelTest::CreateFetcher(const GURL& url) { fetcher_ = new URLFetcherImpl(url, URLFetcher::GET, this); fetcher_->SetRequestContext(new ThrottlingTestURLRequestContextGetter( - io_message_loop_proxy(), request_context())); + io_message_loop_proxy().get(), request_context())); cancelled_ = false; fetcher_->Start(); } @@ -635,7 +634,7 @@ void URLFetcherDownloadProgressCancelTest::OnURLFetchComplete( void URLFetcherUploadProgressTest::CreateFetcher(const GURL& url) { fetcher_ = new URLFetcherImpl(url, URLFetcher::POST, this); fetcher_->SetRequestContext(new ThrottlingTestURLRequestContextGetter( - io_message_loop_proxy(), request_context())); + io_message_loop_proxy().get(), request_context())); previous_progress_ = 0; // Large enough data to require more than one read from UploadDataStream. chunk_.assign(1<<16, 'a'); @@ -692,7 +691,7 @@ URLFetcherStopOnRedirectTest::~URLFetcherStopOnRedirectTest() { void URLFetcherStopOnRedirectTest::CreateFetcher(const GURL& url) { fetcher_ = new URLFetcherImpl(url, URLFetcher::GET, this); fetcher_->SetRequestContext(new ThrottlingTestURLRequestContextGetter( - io_message_loop_proxy(), request_context())); + io_message_loop_proxy().get(), request_context())); fetcher_->SetStopOnRedirect(true); fetcher_->Start(); } @@ -710,7 +709,7 @@ void URLFetcherStopOnRedirectTest::OnURLFetchComplete( void URLFetcherProtectTest::CreateFetcher(const GURL& url) { fetcher_ = new URLFetcherImpl(url, URLFetcher::GET, this); fetcher_->SetRequestContext(new ThrottlingTestURLRequestContextGetter( - io_message_loop_proxy(), request_context())); + io_message_loop_proxy().get(), request_context())); start_time_ = Time::Now(); fetcher_->SetMaxRetriesOn5xx(11); fetcher_->Start(); @@ -732,9 +731,8 @@ void URLFetcherProtectTest::OnURLFetchComplete(const URLFetcher* source) { static int count = 0; count++; if (count < 20) { - fetcher_->SetRequestContext( - new ThrottlingTestURLRequestContextGetter( - io_message_loop_proxy(), request_context())); + fetcher_->SetRequestContext(new ThrottlingTestURLRequestContextGetter( + io_message_loop_proxy().get(), request_context())); fetcher_->Start(); } else { // We have already sent 20 requests continuously. And we expect that @@ -748,7 +746,7 @@ void URLFetcherProtectTest::OnURLFetchComplete(const URLFetcher* source) { void URLFetcherProtectTestPassedThrough::CreateFetcher(const GURL& url) { fetcher_ = new URLFetcherImpl(url, URLFetcher::GET, this); fetcher_->SetRequestContext(new ThrottlingTestURLRequestContextGetter( - io_message_loop_proxy(), request_context())); + io_message_loop_proxy().get(), request_context())); fetcher_->SetAutomaticallyRetryOn5xx(false); start_time_ = Time::Now(); fetcher_->SetMaxRetriesOn5xx(11); @@ -807,8 +805,7 @@ void URLFetcherBadHTTPSTest::OnURLFetchComplete( void URLFetcherCancelTest::CreateFetcher(const GURL& url) { fetcher_ = new URLFetcherImpl(url, URLFetcher::GET, this); CancelTestURLRequestContextGetter* context_getter = - new CancelTestURLRequestContextGetter(io_message_loop_proxy(), - url); + new CancelTestURLRequestContextGetter(io_message_loop_proxy().get(), url); fetcher_->SetRequestContext(context_getter); fetcher_->SetMaxRetriesOn5xx(2); fetcher_->Start(); @@ -842,7 +839,7 @@ void URLFetcherMultipleAttemptTest::OnURLFetchComplete( if (!data.empty() && data_.empty()) { data_ = data; fetcher_->SetRequestContext(new ThrottlingTestURLRequestContextGetter( - io_message_loop_proxy(), request_context())); + io_message_loop_proxy().get(), request_context())); fetcher_->Start(); } else { EXPECT_EQ(data, data_); @@ -854,7 +851,7 @@ void URLFetcherFileTest::CreateFetcherForFile(const GURL& url, const base::FilePath& file_path) { fetcher_ = new URLFetcherImpl(url, URLFetcher::GET, this); fetcher_->SetRequestContext(new ThrottlingTestURLRequestContextGetter( - io_message_loop_proxy(), request_context())); + io_message_loop_proxy().get(), request_context())); // Use the IO message loop to do the file operations in this test. fetcher_->SaveResponseToFileAtPath(file_path, io_message_loop_proxy()); @@ -864,7 +861,7 @@ void URLFetcherFileTest::CreateFetcherForFile(const GURL& url, void URLFetcherFileTest::CreateFetcherForTempFile(const GURL& url) { fetcher_ = new URLFetcherImpl(url, URLFetcher::GET, this); fetcher_->SetRequestContext(new ThrottlingTestURLRequestContextGetter( - io_message_loop_proxy(), request_context())); + io_message_loop_proxy().get(), request_context())); // Use the IO message loop to do the file operations in this test. fetcher_->SaveResponseToTemporaryFile(io_message_loop_proxy()); diff --git a/net/url_request/url_request_context_builder.cc b/net/url_request/url_request_context_builder.cc index 7940b04..ee35572 100644 --- a/net/url_request/url_request_context_builder.cc +++ b/net/url_request/url_request_context_builder.cc @@ -274,12 +274,12 @@ URLRequestContext* URLRequestContextBuilder::Build() { HttpCache::BackendFactory* http_cache_backend = NULL; if (http_cache_params_.type == HttpCacheParams::DISK) { context->StartCacheThread(); - http_cache_backend = - new HttpCache::DefaultBackend(DISK_CACHE, - net::CACHE_BACKEND_DEFAULT, - http_cache_params_.path, - http_cache_params_.max_size, - context->cache_message_loop_proxy()); + http_cache_backend = new HttpCache::DefaultBackend( + DISK_CACHE, + net::CACHE_BACKEND_DEFAULT, + http_cache_params_.path, + http_cache_params_.max_size, + context->cache_message_loop_proxy().get()); } else { http_cache_backend = HttpCache::DefaultBackend::InMemory(http_cache_params_.max_size); diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc index 7b2f867..d57deec 100644 --- a/net/url_request/url_request_unittest.cc +++ b/net/url_request/url_request_unittest.cc @@ -3657,15 +3657,21 @@ TEST_F(URLRequestTestHTTP, PostFileTest) { path = path.Append(FILE_PATH_LITERAL("data")); path = path.Append(FILE_PATH_LITERAL("url_request_unittest")); path = path.Append(FILE_PATH_LITERAL("with-headers.html")); - element_readers.push_back(new UploadFileElementReader( - base::MessageLoopProxy::current(), path, 0, kuint64max, base::Time())); + element_readers.push_back( + new UploadFileElementReader(base::MessageLoopProxy::current().get(), + path, + 0, + kuint64max, + base::Time())); // This file should just be ignored in the upload stream. element_readers.push_back(new UploadFileElementReader( - base::MessageLoopProxy::current(), + base::MessageLoopProxy::current().get(), base::FilePath(FILE_PATH_LITERAL( "c:\\path\\to\\non\\existant\\file.randomness.12345")), - 0, kuint64max, base::Time())); + 0, + kuint64max, + base::Time())); r.set_upload(make_scoped_ptr(new UploadDataStream(&element_readers, 0))); r.Start(); |