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

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

Issue 15829004: Update net/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: license twerk Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_vary_data_unittest.cc ('k') | net/http/proxy_client_socket.cc » ('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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 return (rv == net::OK) ? static_cast<MockDiskCache*>(backend) : NULL; 504 return (rv == net::OK) ? static_cast<MockDiskCache*>(backend) : NULL;
505 } 505 }
506 506
507 bool MockHttpCache::ReadResponseInfo(disk_cache::Entry* disk_entry, 507 bool MockHttpCache::ReadResponseInfo(disk_cache::Entry* disk_entry,
508 net::HttpResponseInfo* response_info, 508 net::HttpResponseInfo* response_info,
509 bool* response_truncated) { 509 bool* response_truncated) {
510 int size = disk_entry->GetDataSize(0); 510 int size = disk_entry->GetDataSize(0);
511 511
512 net::TestCompletionCallback cb; 512 net::TestCompletionCallback cb;
513 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(size)); 513 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(size));
514 int rv = disk_entry->ReadData(0, 0, buffer, size, cb.callback()); 514 int rv = disk_entry->ReadData(0, 0, buffer.get(), size, cb.callback());
515 rv = cb.GetResult(rv); 515 rv = cb.GetResult(rv);
516 EXPECT_EQ(size, rv); 516 EXPECT_EQ(size, rv);
517 517
518 return net::HttpCache::ParseResponseInfo(buffer->data(), size, 518 return net::HttpCache::ParseResponseInfo(buffer->data(), size,
519 response_info, 519 response_info,
520 response_truncated); 520 response_truncated);
521 } 521 }
522 522
523 bool MockHttpCache::WriteResponseInfo( 523 bool MockHttpCache::WriteResponseInfo(
524 disk_cache::Entry* disk_entry, const net::HttpResponseInfo* response_info, 524 disk_cache::Entry* disk_entry, const net::HttpResponseInfo* response_info,
525 bool skip_transient_headers, bool response_truncated) { 525 bool skip_transient_headers, bool response_truncated) {
526 Pickle pickle; 526 Pickle pickle;
527 response_info->Persist( 527 response_info->Persist(
528 &pickle, skip_transient_headers, response_truncated); 528 &pickle, skip_transient_headers, response_truncated);
529 529
530 net::TestCompletionCallback cb; 530 net::TestCompletionCallback cb;
531 scoped_refptr<net::WrappedIOBuffer> data(new net::WrappedIOBuffer( 531 scoped_refptr<net::WrappedIOBuffer> data(new net::WrappedIOBuffer(
532 reinterpret_cast<const char*>(pickle.data()))); 532 reinterpret_cast<const char*>(pickle.data())));
533 int len = static_cast<int>(pickle.size()); 533 int len = static_cast<int>(pickle.size());
534 534
535 int rv = disk_entry->WriteData(0, 0, data, len, cb.callback(), true); 535 int rv = disk_entry->WriteData(0, 0, data.get(), len, cb.callback(), true);
536 rv = cb.GetResult(rv); 536 rv = cb.GetResult(rv);
537 return (rv == len); 537 return (rv == len);
538 } 538 }
539 539
540 bool MockHttpCache::OpenBackendEntry(const std::string& key, 540 bool MockHttpCache::OpenBackendEntry(const std::string& key,
541 disk_cache::Entry** entry) { 541 disk_cache::Entry** entry) {
542 net::TestCompletionCallback cb; 542 net::TestCompletionCallback cb;
543 int rv = disk_cache()->OpenEntry(key, entry, cb.callback()); 543 int rv = disk_cache()->OpenEntry(key, entry, cb.callback());
544 return (cb.GetResult(rv) == net::OK); 544 return (cb.GetResult(rv) == net::OK);
545 } 545 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 void MockBlockingBackendFactory::FinishCreation() { 610 void MockBlockingBackendFactory::FinishCreation() {
611 block_ = false; 611 block_ = false;
612 if (!callback_.is_null()) { 612 if (!callback_.is_null()) {
613 if (!fail_) 613 if (!fail_)
614 *backend_ = new MockDiskCache(); 614 *backend_ = new MockDiskCache();
615 net::CompletionCallback cb = callback_; 615 net::CompletionCallback cb = callback_;
616 callback_.Reset(); 616 callback_.Reset();
617 cb.Run(Result()); // This object can be deleted here. 617 cb.Run(Result()); // This object can be deleted here.
618 } 618 }
619 } 619 }
OLDNEW
« no previous file with comments | « net/http/http_vary_data_unittest.cc ('k') | net/http/proxy_client_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698