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

Unified Diff: net/http/disk_cache_based_quic_server_info_unittest.cc

Issue 786123002: Update from https://crrev.com/307330 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/disk_cache_based_quic_server_info.cc ('k') | net/http/http_auth_handler_negotiate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/disk_cache_based_quic_server_info_unittest.cc
diff --git a/net/http/disk_cache_based_quic_server_info_unittest.cc b/net/http/disk_cache_based_quic_server_info_unittest.cc
index 847b3d8a16e51132a4426c386953039dada124dd..ef69b43390d51a8e7694acac6fcda6bc67492c70 100644
--- a/net/http/disk_cache_based_quic_server_info_unittest.cc
+++ b/net/http/disk_cache_based_quic_server_info_unittest.cc
@@ -14,6 +14,8 @@
#include "net/quic/quic_server_id.h"
#include "testing/gtest/include/gtest/gtest.h"
+using std::string;
+
namespace net {
namespace {
@@ -48,6 +50,27 @@ const MockTransaction kHostInfoTransaction2 = {
0
};
+class DeleteCacheCompletionCallback : public net::TestCompletionCallbackBase {
+ public:
+ explicit DeleteCacheCompletionCallback(QuicServerInfo* server_info)
+ : server_info_(server_info),
+ callback_(base::Bind(&DeleteCacheCompletionCallback::OnComplete,
+ base::Unretained(this))) {}
+
+ const net::CompletionCallback& callback() const { return callback_; }
+
+ private:
+ void OnComplete(int result) {
+ delete server_info_;
+ SetResult(result);
+ }
+
+ QuicServerInfo* server_info_;
+ net::CompletionCallback callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(DeleteCacheCompletionCallback);
+};
+
} // namespace
// Tests that we can delete a DiskCacheBasedQuicServerInfo object in a
@@ -582,4 +605,24 @@ TEST(DiskCacheBasedQuicServerInfo, MultiplePersistsWithoutWaiting) {
RemoveMockTransaction(&kHostInfoTransaction1);
}
+// crbug.com/439209: test deletion of QuicServerInfo object in the callback
+// doesn't crash.
+TEST(DiskCacheBasedQuicServerInfo, DeleteServerInfoInCallback) {
+ // Use the blocking mock backend factory to force asynchronous completion
+ // of quic_server_info->WaitForDataReady(), so that the callback will run.
+ MockBlockingBackendFactory* factory = new MockBlockingBackendFactory();
+ MockHttpCache cache(factory);
+ QuicServerId server_id("www.verisign.com", 443, true, PRIVACY_MODE_DISABLED);
+ QuicServerInfo* quic_server_info =
+ new DiskCacheBasedQuicServerInfo(server_id, cache.http_cache());
+ // |cb| takes owndership and deletes |quic_server_info| when it is called.
+ DeleteCacheCompletionCallback cb(quic_server_info);
+ quic_server_info->Start();
+ int rv = quic_server_info->WaitForDataReady(cb.callback());
+ EXPECT_EQ(ERR_IO_PENDING, rv);
+ // Now complete the backend creation and let the callback run.
+ factory->FinishCreation();
+ EXPECT_EQ(OK, cb.GetResult(rv));
+}
+
} // namespace net
« no previous file with comments | « net/http/disk_cache_based_quic_server_info.cc ('k') | net/http/http_auth_handler_negotiate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698