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

Side by Side Diff: content/renderer/browser_render_view_browsertest.cc

Issue 1873783003: Convert //content/renderer from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // Browser tests targeted at the RenderView that run in browser context. 5 // Browser tests targeted at the RenderView that run in browser context.
6 // Note that these tests rely on single-process mode, and hence may be 6 // Note that these tests rely on single-process mode, and hence may be
7 // disabled in some configurations (check gyp files). 7 // disabled in some configurations (check gyp files).
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 bool latest_error_stale_copy_in_cache_; 77 bool latest_error_stale_copy_in_cache_;
78 }; 78 };
79 79
80 // Must be called on IO thread. 80 // Must be called on IO thread.
81 void InterceptNetworkTransactions(net::URLRequestContextGetter* getter, 81 void InterceptNetworkTransactions(net::URLRequestContextGetter* getter,
82 net::Error error) { 82 net::Error error) {
83 DCHECK_CURRENTLY_ON(BrowserThread::IO); 83 DCHECK_CURRENTLY_ON(BrowserThread::IO);
84 net::HttpCache* cache( 84 net::HttpCache* cache(
85 getter->GetURLRequestContext()->http_transaction_factory()->GetCache()); 85 getter->GetURLRequestContext()->http_transaction_factory()->GetCache());
86 DCHECK(cache); 86 DCHECK(cache);
87 scoped_ptr<net::FailingHttpTransactionFactory> factory( 87 std::unique_ptr<net::FailingHttpTransactionFactory> factory(
88 new net::FailingHttpTransactionFactory(cache->GetSession(), error)); 88 new net::FailingHttpTransactionFactory(cache->GetSession(), error));
89 // Throw away old version; since this is a browser test, there is no 89 // Throw away old version; since this is a browser test, there is no
90 // need to restore the old state. 90 // need to restore the old state.
91 cache->SetHttpNetworkTransactionFactoryForTesting(std::move(factory)); 91 cache->SetHttpNetworkTransactionFactoryForTesting(std::move(factory));
92 } 92 }
93 93
94 void CallOnUIThreadValidatingReturn(const base::Closure& callback, 94 void CallOnUIThreadValidatingReturn(const base::Closure& callback,
95 int rv) { 95 int rv) {
96 DCHECK_EQ(net::OK, rv); 96 DCHECK_EQ(net::OK, rv);
97 BrowserThread::PostTask( 97 BrowserThread::PostTask(
98 BrowserThread::UI, FROM_HERE, callback); 98 BrowserThread::UI, FROM_HERE, callback);
99 } 99 }
100 100
101 // Must be called on IO thread. The callback will be called on 101 // Must be called on IO thread. The callback will be called on
102 // completion of cache clearing on the UI thread. 102 // completion of cache clearing on the UI thread.
103 void BackendClearCache(scoped_ptr<disk_cache::Backend*> backend, 103 void BackendClearCache(std::unique_ptr<disk_cache::Backend*> backend,
104 const base::Closure& callback, 104 const base::Closure& callback,
105 int rv) { 105 int rv) {
106 DCHECK(*backend); 106 DCHECK(*backend);
107 DCHECK_EQ(net::OK, rv); 107 DCHECK_EQ(net::OK, rv);
108 (*backend)->DoomAllEntries( 108 (*backend)->DoomAllEntries(
109 base::Bind(&CallOnUIThreadValidatingReturn, callback)); 109 base::Bind(&CallOnUIThreadValidatingReturn, callback));
110 } 110 }
111 111
112 // Must be called on IO thread. The callback will be called on 112 // Must be called on IO thread. The callback will be called on
113 // completion of cache clearing on the UI thread. 113 // completion of cache clearing on the UI thread.
114 void ClearCache(net::URLRequestContextGetter* getter, 114 void ClearCache(net::URLRequestContextGetter* getter,
115 const base::Closure& callback) { 115 const base::Closure& callback) {
116 DCHECK_CURRENTLY_ON(BrowserThread::IO); 116 DCHECK_CURRENTLY_ON(BrowserThread::IO);
117 net::HttpCache* cache( 117 net::HttpCache* cache(
118 getter->GetURLRequestContext()->http_transaction_factory()->GetCache()); 118 getter->GetURLRequestContext()->http_transaction_factory()->GetCache());
119 DCHECK(cache); 119 DCHECK(cache);
120 scoped_ptr<disk_cache::Backend*> backend(new disk_cache::Backend*); 120 std::unique_ptr<disk_cache::Backend*> backend(new disk_cache::Backend*);
121 *backend = NULL; 121 *backend = NULL;
122 disk_cache::Backend** backend_ptr = backend.get(); 122 disk_cache::Backend** backend_ptr = backend.get();
123 123
124 net::CompletionCallback backend_callback(base::Bind( 124 net::CompletionCallback backend_callback(base::Bind(
125 &BackendClearCache, base::Passed(std::move(backend)), callback)); 125 &BackendClearCache, base::Passed(std::move(backend)), callback));
126 126
127 // backend_ptr is valid until all copies of backend_callback go out 127 // backend_ptr is valid until all copies of backend_callback go out
128 // of scope. 128 // of scope.
129 if (net::OK == cache->GetBackend(backend_ptr, backend_callback)) { 129 if (net::OK == cache->GetBackend(backend_ptr, backend_callback)) {
130 // The call completed synchronously, so GetBackend didn't run the callback. 130 // The call completed synchronously, so GetBackend didn't run the callback.
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 234
235 error_code = net::OK; 235 error_code = net::OK;
236 stale_cache_entry_present = true; 236 stale_cache_entry_present = true;
237 ASSERT_TRUE(GetLatestErrorFromRendererClient( 237 ASSERT_TRUE(GetLatestErrorFromRendererClient(
238 &error_code, &stale_cache_entry_present)); 238 &error_code, &stale_cache_entry_present));
239 EXPECT_EQ(net::ERR_FAILED, error_code); 239 EXPECT_EQ(net::ERR_FAILED, error_code);
240 EXPECT_FALSE(stale_cache_entry_present); 240 EXPECT_FALSE(stale_cache_entry_present);
241 } 241 }
242 242
243 } // namespace content 243 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin_manager.cc ('k') | content/renderer/cache_storage/cache_storage_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698