OLD | NEW |
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 "net/http/mock_http_cache.h" | 5 #include "net/http/mock_http_cache.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "net/base/completion_callback.h" | 9 #include "net/base/completion_callback.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 EXPECT_EQ(size, rv); | 557 EXPECT_EQ(size, rv); |
558 | 558 |
559 return HttpCache::ParseResponseInfo(buffer->data(), size, response_info, | 559 return HttpCache::ParseResponseInfo(buffer->data(), size, response_info, |
560 response_truncated); | 560 response_truncated); |
561 } | 561 } |
562 | 562 |
563 bool MockHttpCache::WriteResponseInfo(disk_cache::Entry* disk_entry, | 563 bool MockHttpCache::WriteResponseInfo(disk_cache::Entry* disk_entry, |
564 const HttpResponseInfo* response_info, | 564 const HttpResponseInfo* response_info, |
565 bool skip_transient_headers, | 565 bool skip_transient_headers, |
566 bool response_truncated) { | 566 bool response_truncated) { |
567 Pickle pickle; | 567 base::Pickle pickle; |
568 response_info->Persist( | 568 response_info->Persist( |
569 &pickle, skip_transient_headers, response_truncated); | 569 &pickle, skip_transient_headers, response_truncated); |
570 | 570 |
571 TestCompletionCallback cb; | 571 TestCompletionCallback cb; |
572 scoped_refptr<WrappedIOBuffer> data( | 572 scoped_refptr<WrappedIOBuffer> data( |
573 new WrappedIOBuffer(reinterpret_cast<const char*>(pickle.data()))); | 573 new WrappedIOBuffer(reinterpret_cast<const char*>(pickle.data()))); |
574 int len = static_cast<int>(pickle.size()); | 574 int len = static_cast<int>(pickle.size()); |
575 | 575 |
576 int rv = disk_entry->WriteData(0, 0, data.get(), len, cb.callback(), true); | 576 int rv = disk_entry->WriteData(0, 0, data.get(), len, cb.callback(), true); |
577 rv = cb.GetResult(rv); | 577 rv = cb.GetResult(rv); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 if (!callback_.is_null()) { | 655 if (!callback_.is_null()) { |
656 if (!fail_) | 656 if (!fail_) |
657 backend_->reset(new MockDiskCache()); | 657 backend_->reset(new MockDiskCache()); |
658 CompletionCallback cb = callback_; | 658 CompletionCallback cb = callback_; |
659 callback_.Reset(); | 659 callback_.Reset(); |
660 cb.Run(Result()); // This object can be deleted here. | 660 cb.Run(Result()); // This object can be deleted here. |
661 } | 661 } |
662 } | 662 } |
663 | 663 |
664 } // namespace net | 664 } // namespace net |
OLD | NEW |