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

Side by Side Diff: net/http/mock_http_cache.cc

Issue 11275088: Remove implicit scoped_refptr operator T* Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « net/http/http_transaction_unittest.cc ('k') | net/proxy/mock_proxy_resolver.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h" 8 #include "base/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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 return (rv == net::OK) ? static_cast<MockDiskCache*>(backend) : NULL; 503 return (rv == net::OK) ? static_cast<MockDiskCache*>(backend) : NULL;
504 } 504 }
505 505
506 bool MockHttpCache::ReadResponseInfo(disk_cache::Entry* disk_entry, 506 bool MockHttpCache::ReadResponseInfo(disk_cache::Entry* disk_entry,
507 net::HttpResponseInfo* response_info, 507 net::HttpResponseInfo* response_info,
508 bool* response_truncated) { 508 bool* response_truncated) {
509 int size = disk_entry->GetDataSize(0); 509 int size = disk_entry->GetDataSize(0);
510 510
511 net::TestCompletionCallback cb; 511 net::TestCompletionCallback cb;
512 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(size)); 512 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(size));
513 int rv = disk_entry->ReadData(0, 0, buffer, size, cb.callback()); 513 int rv = disk_entry->ReadData(0, 0, buffer.get(), size, cb.callback());
514 rv = cb.GetResult(rv); 514 rv = cb.GetResult(rv);
515 EXPECT_EQ(size, rv); 515 EXPECT_EQ(size, rv);
516 516
517 return net::HttpCache::ParseResponseInfo(buffer->data(), size, 517 return net::HttpCache::ParseResponseInfo(buffer->data(), size,
518 response_info, 518 response_info,
519 response_truncated); 519 response_truncated);
520 } 520 }
521 521
522 bool MockHttpCache::WriteResponseInfo( 522 bool MockHttpCache::WriteResponseInfo(
523 disk_cache::Entry* disk_entry, const net::HttpResponseInfo* response_info, 523 disk_cache::Entry* disk_entry, const net::HttpResponseInfo* response_info,
524 bool skip_transient_headers, bool response_truncated) { 524 bool skip_transient_headers, bool response_truncated) {
525 Pickle pickle; 525 Pickle pickle;
526 response_info->Persist( 526 response_info->Persist(
527 &pickle, skip_transient_headers, response_truncated); 527 &pickle, skip_transient_headers, response_truncated);
528 528
529 net::TestCompletionCallback cb; 529 net::TestCompletionCallback cb;
530 scoped_refptr<net::WrappedIOBuffer> data(new net::WrappedIOBuffer( 530 scoped_refptr<net::WrappedIOBuffer> data(new net::WrappedIOBuffer(
531 reinterpret_cast<const char*>(pickle.data()))); 531 reinterpret_cast<const char*>(pickle.data())));
532 int len = static_cast<int>(pickle.size()); 532 int len = static_cast<int>(pickle.size());
533 533
534 int rv = disk_entry->WriteData(0, 0, data, len, cb.callback(), true); 534 int rv = disk_entry->WriteData(0, 0, data.get(), len, cb.callback(), true);
535 rv = cb.GetResult(rv); 535 rv = cb.GetResult(rv);
536 return (rv == len); 536 return (rv == len);
537 } 537 }
538 538
539 bool MockHttpCache::OpenBackendEntry(const std::string& key, 539 bool MockHttpCache::OpenBackendEntry(const std::string& key,
540 disk_cache::Entry** entry) { 540 disk_cache::Entry** entry) {
541 net::TestCompletionCallback cb; 541 net::TestCompletionCallback cb;
542 int rv = disk_cache()->OpenEntry(key, entry, cb.callback()); 542 int rv = disk_cache()->OpenEntry(key, entry, cb.callback());
543 return (cb.GetResult(rv) == net::OK); 543 return (cb.GetResult(rv) == net::OK);
544 } 544 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 void MockBlockingBackendFactory::FinishCreation() { 609 void MockBlockingBackendFactory::FinishCreation() {
610 block_ = false; 610 block_ = false;
611 if (!callback_.is_null()) { 611 if (!callback_.is_null()) {
612 if (!fail_) 612 if (!fail_)
613 *backend_ = new MockDiskCache(); 613 *backend_ = new MockDiskCache();
614 net::CompletionCallback cb = callback_; 614 net::CompletionCallback cb = callback_;
615 callback_.Reset(); 615 callback_.Reset();
616 cb.Run(Result()); // This object can be deleted here. 616 cb.Run(Result()); // This object can be deleted here.
617 } 617 }
618 } 618 }
OLDNEW
« no previous file with comments | « net/http/http_transaction_unittest.cc ('k') | net/proxy/mock_proxy_resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698