OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/http/http_cache.h" | 5 #include "net/http/http_cache.h" |
6 | 6 |
7 #include "base/hash_tables.h" | 7 #include "base/hash_tables.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 MockHttpRequest request(kSimpleGET_Transaction); | 669 MockHttpRequest request(kSimpleGET_Transaction); |
670 TestCompletionCallback callback; | 670 TestCompletionCallback callback; |
671 | 671 |
672 scoped_ptr<net::HttpTransaction> trans( | 672 scoped_ptr<net::HttpTransaction> trans( |
673 cache.http_cache()->CreateTransaction()); | 673 cache.http_cache()->CreateTransaction()); |
674 int rv = trans->Start(&request, &callback); | 674 int rv = trans->Start(&request, &callback); |
675 if (rv == net::ERR_IO_PENDING) | 675 if (rv == net::ERR_IO_PENDING) |
676 rv = callback.WaitForResult(); | 676 rv = callback.WaitForResult(); |
677 ASSERT_EQ(net::OK, rv); | 677 ASSERT_EQ(net::OK, rv); |
678 | 678 |
679 char buf[256]; | 679 scoped_refptr<net::IOBuffer> buf = new net::IOBuffer(256); |
680 rv = trans->Read(buf, sizeof(buf), &callback); | 680 rv = trans->Read(buf, 256, &callback); |
681 EXPECT_EQ(net::ERR_IO_PENDING, rv); | 681 EXPECT_EQ(net::ERR_IO_PENDING, rv); |
682 | 682 |
683 // Test that destroying the transaction while it is reading from the cache | 683 // Test that destroying the transaction while it is reading from the cache |
684 // works properly. | 684 // works properly. |
685 trans.reset(); | 685 trans.reset(); |
686 | 686 |
687 // Make sure we pump any pending events, which should include a call to | 687 // Make sure we pump any pending events, which should include a call to |
688 // HttpCache::Transaction::OnCacheReadCompleted. | 688 // HttpCache::Transaction::OnCacheReadCompleted. |
689 MessageLoop::current()->RunAllPending(); | 689 MessageLoop::current()->RunAllPending(); |
690 } | 690 } |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 | 1081 |
1082 scoped_ptr<net::HttpTransaction> trans( | 1082 scoped_ptr<net::HttpTransaction> trans( |
1083 cache.http_cache()->CreateTransaction()); | 1083 cache.http_cache()->CreateTransaction()); |
1084 ASSERT_TRUE(trans.get()); | 1084 ASSERT_TRUE(trans.get()); |
1085 | 1085 |
1086 int rv = trans->Start(&request, &callback); | 1086 int rv = trans->Start(&request, &callback); |
1087 if (rv == net::ERR_IO_PENDING) | 1087 if (rv == net::ERR_IO_PENDING) |
1088 rv = callback.WaitForResult(); | 1088 rv = callback.WaitForResult(); |
1089 ASSERT_EQ(net::ERR_CACHE_MISS, rv); | 1089 ASSERT_EQ(net::ERR_CACHE_MISS, rv); |
1090 } | 1090 } |
OLD | NEW |